Browse Source

address review of @PulpCattel

master
Adam Gibson 3 years ago
parent
commit
db71d30b80
No known key found for this signature in database
GPG Key ID: 141001A1AF77F20B
  1. 10
      jmbitcoin/jmbitcoin/secp256k1_transaction.py
  2. 8
      jmclient/jmclient/taker_utils.py

10
jmbitcoin/jmbitcoin/secp256k1_transaction.py

@ -106,13 +106,13 @@ def human_readable_output(txoutput):
pass # non standard script
return outdict
def there_is_one_segwit_input(x):
def there_is_one_segwit_input(input_types):
# note that we need separate input types for
# any distinct types of scripthash inputs supported,
# since each may have a different size of witness; in
# that case, the internal list in this list comprehension
# will need updating.
return any([y in ["p2sh-p2wpkh", "p2wpkh", "p2wsh"] for y in x])
return any(y in ["p2sh-p2wpkh", "p2wpkh", "p2wsh"] for y in input_types)
def estimate_tx_size(ins, outs):
'''Estimate transaction size.
@ -174,16 +174,14 @@ def estimate_tx_size(ins, outs):
for i in ins:
if i not in inmults:
raise NotImplementedError(
"Script type not supported for transaction size "
"estimation: {}".format(i))
f"Script type not supported for transaction size estimation: {i}")
inmult = inmults[i]
nwsize += inmult["nw"]
wsize += inmult["w"]
for o in outs:
if o not in outmults:
raise NotImplementedError(
"Script type not supported for transaction size "
"estimation: {}".format(o))
f"Script type not supported for transaction size estimation: {o}")
nwsize += outmults[o]
if not tx_is_segwit:

8
jmclient/jmclient/taker_utils.py

@ -26,8 +26,8 @@ def get_utxo_scripts(wallet: BaseWallet, utxos):
# as passed from `get_utxos_by_mixdepth` at one mixdepth,
# return the list of script types for each utxo
script_types = []
for k, v in utxos.items():
script_types.append(wallet.get_outtype(v["address"]))
for utxo in utxos.values():
script_types.append(wallet.get_outtype(utxo["address"]))
return script_types
def direct_send(wallet_service, amount, mixdepth, destination, answeryes=False,
@ -110,13 +110,13 @@ def direct_send(wallet_service, amount, mixdepth, destination, answeryes=False,
fee_est = estimate_tx_fee(len(utxos), 1, txtype=script_types, outtype=outtype)
outs = [{"address": destination, "value": total_inputs_val - fee_est}]
else:
change_type = wallet_service.get_txtype()
change_type = txtype
if custom_change_addr:
change_type = wallet_service.get_outtype(custom_change_addr)
if change_type is None:
# we don't recognize this type; best we can do is revert to default,
# even though it may be inaccurate:
change_type = wallet_service.get_txtype()
change_type = txtype
outtypes = [change_type, outtype]
# not doing a sweep; we will have change.
# 8 inputs to be conservative; note we cannot account for the possibility

Loading…
Cancel
Save