Browse Source

fix refactor bugs in sendpayment

master
Adam Gibson 9 years ago
parent
commit
c1eb37af23
No known key found for this signature in database
GPG Key ID: B3AE09F1E9A3197A
  1. 46
      scripts/sendpayment.py

46
scripts/sendpayment.py

@ -48,6 +48,8 @@ import threading
from optparse import OptionParser from optparse import OptionParser
from twisted.internet import reactor from twisted.internet import reactor
import time import time
import os
import pprint
from jmclient import (Taker, load_program_config, get_schedule, from jmclient import (Taker, load_program_config, get_schedule,
JMTakerClientProtocolFactory, start_reactor, JMTakerClientProtocolFactory, start_reactor,
@ -252,36 +254,40 @@ def main():
if not options.userpcwallet: if not options.userpcwallet:
max_mix_depth = max([mixdepth, options.amtmixdepths]) max_mix_depth = max([mixdepth, options.amtmixdepths])
try: if not os.path.exists(os.path.join('wallets', wallet_name)):
pwd = get_password("Enter wallet decryption passphrase: ") wallet = Wallet(wallet_name, None, max_mix_depth, options.gaplimit)
wallet = Wallet(wallet_name, pwd, max_mix_depth, options.gaplimit) else:
except WalletError: while True:
print("Wrong password, try again.") try:
continue pwd = get_password("Enter wallet decryption passphrase: ")
except Exception as e: wallet = Wallet(wallet_name, pwd, max_mix_depth, options.gaplimit)
print("Failed to load wallet, error message: " + repr(e)) except WalletError:
sys.exit(0) print("Wrong password, try again.")
break continue
except Exception as e:
print("Failed to load wallet, error message: " + repr(e))
sys.exit(0)
break
else: else:
wallet = BitcoinCoreWallet(fromaccount=wallet_name) wallet = BitcoinCoreWallet(fromaccount=wallet_name)
sync_wallet(wallet, fast=options.fastsync) sync_wallet(wallet, fast=options.fastsync)
def filter_orders_callback(orders_fees, cjamount): def filter_orders_callback(orders_fees, cjamount):
orders, total_cj_fee = orders_fees orders, total_cj_fee = orders_fees
jlog.info("Chose these orders: " +pprint.pformat(orders)) log.info("Chose these orders: " +pprint.pformat(orders))
jlog.info('total cj fee = ' + str(total_cj_fee)) log.info('total cj fee = ' + str(total_cj_fee))
total_fee_pc = 1.0 * total_cj_fee / cjamount total_fee_pc = 1.0 * total_cj_fee / cjamount
jlog.info('total coinjoin fee = ' + str(float('%.3g' % ( log.info('total coinjoin fee = ' + str(float('%.3g' % (
100.0 * total_fee_pc))) + '%') 100.0 * total_fee_pc))) + '%')
WARNING_THRESHOLD = 0.02 # 2% WARNING_THRESHOLD = 0.02 # 2%
if total_fee_pc > WARNING_THRESHOLD: if total_fee_pc > WARNING_THRESHOLD:
jlog.info('\n'.join(['=' * 60] * 3)) log.info('\n'.join(['=' * 60] * 3))
jlog.info('WARNING ' * 6) log.info('WARNING ' * 6)
jlog.info('\n'.join(['=' * 60] * 1)) log.info('\n'.join(['=' * 60] * 1))
jlog.info('OFFERED COINJOIN FEE IS UNUSUALLY HIGH. DOUBLE/TRIPLE CHECK.') log.info('OFFERED COINJOIN FEE IS UNUSUALLY HIGH. DOUBLE/TRIPLE CHECK.')
jlog.info('\n'.join(['=' * 60] * 1)) log.info('\n'.join(['=' * 60] * 1))
jlog.info('WARNING ' * 6) log.info('WARNING ' * 6)
jlog.info('\n'.join(['=' * 60] * 3)) log.info('\n'.join(['=' * 60] * 3))
if not options.answeryes: if not options.answeryes:
if raw_input('send with these orders? (y/n):')[0] != 'y': if raw_input('send with these orders? (y/n):')[0] != 'y':
return False return False

Loading…
Cancel
Save