From be57c71c9c470fbcd12a2ca752edc610d7837555 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Wed, 18 Nov 2020 19:42:12 +0100 Subject: [PATCH] wallet: fix incorrect namespace name This commit fixes a panic introduced with #718 that was caused by looking up addresses in the wrong namespace. --- wallet/wallet.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wallet/wallet.go b/wallet/wallet.go index df84611..e4d7172 100644 --- a/wallet/wallet.go +++ b/wallet/wallet.go @@ -3468,7 +3468,7 @@ func (w *Wallet) reliablyPublishTransaction(tx *wire.MsgTx, // the transaction. var ourAddrs []btcutil.Address err = walletdb.Update(w.db, func(dbTx walletdb.ReadWriteTx) error { - txmgrNs := dbTx.ReadWriteBucket(wtxmgrNamespaceKey) + addrmgrNs := dbTx.ReadWriteBucket(waddrmgrNamespaceKey) for _, txOut := range tx.TxOut { _, addrs, _, err := txscript.ExtractPkScriptAddrs( txOut.PkScript, w.chainParams, @@ -3481,7 +3481,7 @@ func (w *Wallet) reliablyPublishTransaction(tx *wire.MsgTx, for _, addr := range addrs { // Skip any addresses which are not relevant to // us. - _, err := w.Manager.Address(txmgrNs, addr) + _, err := w.Manager.Address(addrmgrNs, addr) if waddrmgr.IsError(err, waddrmgr.ErrAddressNotFound) { continue } @@ -3503,6 +3503,7 @@ func (w *Wallet) reliablyPublishTransaction(tx *wire.MsgTx, // If there is a label we should write, get the namespace key // and record it in the tx store. + txmgrNs := dbTx.ReadWriteBucket(wtxmgrNamespaceKey) return w.TxStore.PutTxLabel(txmgrNs, tx.TxHash(), label) }) if err != nil {