fixes for txin.make_witness:
- add witness_sizehint - fix make_unsigned_transaction - do not remove witness_script in tx.finalize()
This commit is contained in:
@@ -913,6 +913,10 @@ class Transaction:
|
||||
if not txin.is_segwit():
|
||||
return construct_witness([])
|
||||
|
||||
if estimate_size and hasattr(txin, 'make_witness'):
|
||||
sig_dummy = b'\x00' * 71 # DER-encoded ECDSA sig, with low S and low R
|
||||
txin.witness_sizehint = len(txin.make_witness(sig_dummy))
|
||||
|
||||
if estimate_size and txin.witness_sizehint is not None:
|
||||
return bytes(txin.witness_sizehint)
|
||||
|
||||
@@ -1739,7 +1743,8 @@ class PartialTxInput(TxInput, PSBTSection):
|
||||
self.sighash = None
|
||||
self.bip32_paths = {}
|
||||
self.redeem_script = None
|
||||
self.witness_script = None
|
||||
# FIXME: side effect interfers with make_witness
|
||||
# self.witness_script = None
|
||||
|
||||
if self.script_sig is not None and self.witness is not None:
|
||||
clear_fields_when_finalized()
|
||||
|
||||
@@ -1876,8 +1876,13 @@ class Abstract_Wallet(ABC, Logger, EventListener):
|
||||
# make sure we don't try to spend change from the tx-to-be-replaced:
|
||||
coins = [c for c in coins if c.prevout.txid.hex() != base_tx.txid()]
|
||||
is_local = self.adb.get_tx_height(base_tx.txid()).height == TX_HEIGHT_LOCAL
|
||||
base_tx = PartialTransaction.from_tx(base_tx)
|
||||
base_tx.add_info_from_wallet(self)
|
||||
if not isinstance(base_tx, PartialTransaction):
|
||||
base_tx = PartialTransaction.from_tx(base_tx)
|
||||
base_tx.add_info_from_wallet(self)
|
||||
else:
|
||||
# don't cast PartialTransaction, because it removes make_witness
|
||||
for txin in base_tx.inputs():
|
||||
txin.witness = None
|
||||
base_tx_fee = base_tx.get_fee()
|
||||
base_feerate = Decimal(base_tx_fee)/base_tx.estimated_size()
|
||||
relayfeerate = Decimal(self.relayfee()) / 1000
|
||||
|
||||
Reference in New Issue
Block a user