1
0

Add rbf_merge_txid to PartialTransaction, instead of calling

get_unconfirmed_base_tx_for_batching a second time from GUI.
This commit is contained in:
ThomasV
2023-03-07 18:09:34 +01:00
parent 18cf546aab
commit 3253e4904b
3 changed files with 7 additions and 2 deletions

View File

@@ -567,8 +567,7 @@ class TxEditor(WindowModalDialog):
if any(txin.block_height<=0 for txin in self.tx.inputs()):
warnings.append(_('This transaction spends unconfirmed coins.'))
# warn if we merge from mempool
base_tx = self.wallet.get_unconfirmed_base_tx_for_batching()
if self.config.get('batch_rbf', False) and base_tx:
if self.tx.rbf_merge_txid:
warnings.append(_('This payment was merged with another existing transaction.'))
# TODO: warn if we send change back to input address
self.warning = _('Warning') + ': ' + '\n'.join(warnings) if warnings else ''

View File

@@ -1651,6 +1651,7 @@ class PartialTransaction(Transaction):
self._inputs = [] # type: List[PartialTxInput]
self._outputs = [] # type: List[PartialTxOutput]
self._unknown = {} # type: Dict[bytes, bytes]
self.rbf_merge_txid = None
def to_json(self) -> dict:
d = super().to_json()

View File

@@ -1664,6 +1664,9 @@ class Abstract_Wallet(ABC, Logger, EventListener):
else:
raise Exception(f'Invalid argument fee: {fee}')
# set if we merge with another transaction
rbf_merge_txid = None
if len(i_max) == 0:
# Let the coin chooser select the coins to spend
coin_chooser = coinchooser.get_coin_chooser(self.config)
@@ -1686,6 +1689,7 @@ class Abstract_Wallet(ABC, Logger, EventListener):
txi = base_tx.inputs()
txo = list(filter(lambda o: not self.is_change(o.address), base_tx.outputs()))
old_change_addrs = [o.address for o in base_tx.outputs() if self.is_change(o.address)]
rbf_merge_txid = base_tx.txid()
else:
txi = []
txo = []
@@ -1727,6 +1731,7 @@ class Abstract_Wallet(ABC, Logger, EventListener):
# Timelock tx to current height.
tx.locktime = get_locktime_for_new_transaction(self.network)
tx.rbf_merge_txid = rbf_merge_txid
tx.set_rbf(rbf)
tx.add_info_from_wallet(self)
run_hook('make_unsigned_transaction', self, tx)