adb.get_tx_height: return "LOCAL" height if missing full signed tx
get_tx_height previously did not consider whether the walletDB has the full tx for the corresponding txid, and could consider a tx even "mined" and spv-ed, even if we were missing the raw tx. Now if the full tx is missing or the tx in the db is partial, get_tx_height considers it to be LOCAL. In particular the txbatcher, in `run_iteration`, - first saves a tx as local *unsigned* (to reserve UTXOs), - then signs it and tries to broadcast it. The history tx will later transition to local and signed, after we get back the broadcasted tx via the Synchronizer dance. In the meantime there is a race where we have an unsigned tx in the history, but the txid could already transition to mempool or even to mined, before we download the full raw tx from the server. During that time window, it makes the adb state more consistent to just consider the history tx to be local, as done here.
This commit is contained in:
@@ -221,7 +221,7 @@ class TxBatcher(Logger):
|
||||
|
||||
class TxBatch(Logger):
|
||||
|
||||
def __init__(self, wallet, storage: StoredDict):
|
||||
def __init__(self, wallet: 'Abstract_Wallet', storage: StoredDict):
|
||||
Logger.__init__(self)
|
||||
self.wallet = wallet
|
||||
self.storage = storage
|
||||
@@ -404,6 +404,9 @@ class TxBatch(Logger):
|
||||
return
|
||||
|
||||
# add tx to wallet, in order to reserve utxos
|
||||
# note: This saves the tx as local *unsigned*.
|
||||
# It will transition to local and signed, after we broadcast
|
||||
# the signed tx and get it back via the Synchronizer dance.
|
||||
self.wallet.adb.add_transaction(tx)
|
||||
# await password
|
||||
if not await self.sign_transaction(tx):
|
||||
|
||||
Reference in New Issue
Block a user