Skip to content

Commit

Permalink
wallet: fix how leafdatas are fetched
Browse files Browse the repository at this point in the history
When the mempool didn't have caching built in, it used to have the full
udata attached to the tx. But since this is not the case anymore,
watchonly wallet panics as it tries to access something that no longer
exists.

We change the code to fetch the leafdatas from the mempool directly as
it can now be fetched from there.
  • Loading branch information
kcalvinalvin committed May 7, 2024
1 parent 69d6be7 commit 2a63a4c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions wallet/watchonly.go
Original file line number Diff line number Diff line change
Expand Up @@ -1334,9 +1334,14 @@ func (m *WatchOnlyWalletManager) NotifyNewTransactions(txns []*mempool.TxDesc) {
txHash := tx.Tx.Hash()
log.Debugf("NotifyNewTransactions: received new tx: %s\n", txHash.String())

lds := tx.Tx.MsgTx().UData.LeafDatas
// Fetch the leaf datas for this tx.
lds, err := m.config.TxMemPool.FetchLeafDatas(txHash)
if err != nil {
log.Warnf("NotifyNewTransactions: failed to fetch leafdatas for tx %s", txHash.String())
continue
}
if lds == nil {
log.Warnf("NotifyNewTransactions: received tx %s with no Udata", txHash.String())
log.Warnf("NotifyNewTransactions: fetch nil leafdatas for tx %s", txHash.String())
continue
}
if len(lds) != len(tx.Tx.MsgTx().TxIn) {
Expand Down

0 comments on commit 2a63a4c

Please sign in to comment.