diff --git a/jmclient/jmclient/taker_utils.py b/jmclient/jmclient/taker_utils.py index 450aab4..5227c76 100644 --- a/jmclient/jmclient/taker_utils.py +++ b/jmclient/jmclient/taker_utils.py @@ -59,7 +59,7 @@ def direct_send(wallet, amount, mixdepth, destaddr, answeryes=False, initial_fee_est = estimate_tx_fee(8,2, txtype=txtype) utxos = wallet.select_utxos(mixdepth, amount + initial_fee_est) if len(utxos) < 8: - fee_est = estimate_tx_fee(len(utxos), 2) + fee_est = estimate_tx_fee(len(utxos), 2, txtype=txtype) else: fee_est = initial_fee_est total_inputs_val = sum([va['value'] for u, va in utxos.iteritems()]) @@ -79,7 +79,8 @@ def direct_send(wallet, amount, mixdepth, destaddr, answeryes=False, ins['outpoint']['index']) addr = utxos[utxo]['address'] signing_amount = utxos[utxo]['value'] - tx = sign(tx, index, wallet.get_key_from_addr(addr), amount=signing_amount) + amount = signing_amount if isinstance(wallet, SegwitWallet) else None + tx = sign(tx, index, wallet.get_key_from_addr(addr), amount=amount) txsigned = deserialize(tx) log.info("Got signed transaction:\n") log.info(tx + "\n") diff --git a/jmclient/jmclient/wallet.py b/jmclient/jmclient/wallet.py index 3d639d8..aeb01d3 100644 --- a/jmclient/jmclient/wallet.py +++ b/jmclient/jmclient/wallet.py @@ -189,6 +189,10 @@ class Wallet(AbstractWallet): """for base/legacy wallet type, this is a passthrough. for bip39 style wallets, this will convert from one to the other """ + #Feature for testnet testing: if we are using direct command line + #brainwallets (as we do for regtest), strip the flag. + if entropy.startswith("FAKESEED"): + entropy = entropy[8:] return entropy def get_txtype(self): diff --git a/scripts/sendpayment.py b/scripts/sendpayment.py index 1da84ed..6e75d19 100644 --- a/scripts/sendpayment.py +++ b/scripts/sendpayment.py @@ -57,7 +57,8 @@ def main(): parser = get_sendpayment_parser() (options, args) = parser.parse_args() load_program_config() - + walletclass = SegwitWallet if jm_single().config.get( + "POLICY", "segwit") == "true" else Wallet if options.schedule == '' and len(args) < 3: parser.error('Needs a wallet, amount and destination address') sys.exit(0) @@ -124,12 +125,12 @@ def main(): if not options.userpcwallet: max_mix_depth = max([mixdepth, options.amtmixdepths]) if not os.path.exists(os.path.join('wallets', wallet_name)): - wallet = SegwitWallet(wallet_name, None, max_mix_depth, options.gaplimit) + wallet = walletclass(wallet_name, None, max_mix_depth, options.gaplimit) else: while True: try: pwd = get_password("Enter wallet decryption passphrase: ") - wallet = SegwitWallet(wallet_name, pwd, max_mix_depth, options.gaplimit) + wallet = walletclass(wallet_name, pwd, max_mix_depth, options.gaplimit) except WalletError: print("Wrong password, try again.") continue @@ -147,6 +148,11 @@ def main(): direct_send(wallet, amount, mixdepth, destaddr, options.answeryes) return + if walletclass == Wallet: + print("Only direct sends (use -N 0) are supported for " + "legacy (non-segwit) wallets.") + return + def filter_orders_callback(orders_fees, cjamount): orders, total_cj_fee = orders_fees log.info("Chose these orders: " +pprint.pformat(orders))