diff --git a/chainntnfs/bitcoindnotify/bitcoind.go b/chainntnfs/bitcoindnotify/bitcoind.go index bbda6fe4b..18615fae4 100644 --- a/chainntnfs/bitcoindnotify/bitcoind.go +++ b/chainntnfs/bitcoindnotify/bitcoind.go @@ -613,7 +613,7 @@ func (b *BitcoindNotifier) confDetailsManually(confRequest chainntnfs.ConfReques } return &chainntnfs.TxConfirmation{ - Tx: tx, + Tx: tx.Copy(), BlockHash: blockHash, BlockHeight: height, TxIndex: uint32(txIndex), @@ -874,11 +874,13 @@ func (b *BitcoindNotifier) historicalSpendDetails( continue } - txHash := tx.TxHash() + txCopy := tx.Copy() + txHash := txCopy.TxHash() + spendOutPoint := &txCopy.TxIn[inputIdx].PreviousOutPoint return &chainntnfs.SpendDetail{ - SpentOutPoint: &tx.TxIn[inputIdx].PreviousOutPoint, + SpentOutPoint: spendOutPoint, SpenderTxHash: &txHash, - SpendingTx: tx, + SpendingTx: txCopy, SpenderInputIndex: inputIdx, SpendingHeight: int32(height), }, nil diff --git a/chainntnfs/btcdnotify/btcd.go b/chainntnfs/btcdnotify/btcd.go index 5ad03fa6b..3025a8346 100644 --- a/chainntnfs/btcdnotify/btcd.go +++ b/chainntnfs/btcdnotify/btcd.go @@ -667,7 +667,7 @@ func (b *BtcdNotifier) confDetailsManually(confRequest chainntnfs.ConfRequest, } return &chainntnfs.TxConfirmation{ - Tx: tx, + Tx: tx.Copy(), BlockHash: blockHash, BlockHeight: height, TxIndex: uint32(txIndex), diff --git a/chainntnfs/interface.go b/chainntnfs/interface.go index aaefee9ca..d8e325fb2 100644 --- a/chainntnfs/interface.go +++ b/chainntnfs/interface.go @@ -788,7 +788,7 @@ func ConfDetailsFromTxIndex(chainConn TxIndexConn, r ConfRequest, } return &TxConfirmation{ - Tx: &tx, + Tx: tx.Copy(), BlockHash: blockHash, BlockHeight: uint32(blockHeight), TxIndex: uint32(txIndex), diff --git a/chainntnfs/neutrinonotify/neutrino.go b/chainntnfs/neutrinonotify/neutrino.go index 87735a167..3faf8528b 100644 --- a/chainntnfs/neutrinonotify/neutrino.go +++ b/chainntnfs/neutrinonotify/neutrino.go @@ -635,7 +635,7 @@ func (n *NeutrinoNotifier) historicalConfDetails(confRequest chainntnfs.ConfRequ } return &chainntnfs.TxConfirmation{ - Tx: tx.MsgTx(), + Tx: tx.MsgTx().Copy(), BlockHash: blockHash, BlockHeight: scanHeight, TxIndex: uint32(i), diff --git a/lnwallet/test/test_interface.go b/lnwallet/test/test_interface.go index aea0aa15e..b33349119 100644 --- a/lnwallet/test/test_interface.go +++ b/lnwallet/test/test_interface.go @@ -1168,10 +1168,12 @@ func testListTransactionDetails(miner *rpctest.Harness, t.Fatalf("err fetching block: %s", err) } - transactions := - make(map[chainhash.Hash][]*wire.TxOut, len(fetchedBlock.Transactions)) + transactions := make( + map[chainhash.Hash][]*wire.TxOut, + len(fetchedBlock.Transactions), + ) for _, tx := range fetchedBlock.Transactions { - transactions[tx.TxHash()] = tx.TxOut + transactions[tx.TxHash()] = tx.Copy().TxOut } blockTxOuts[fetchedBlock.BlockHash()] = transactions diff --git a/routing/chainview/bitcoind.go b/routing/chainview/bitcoind.go index c38c4df8f..337f18262 100644 --- a/routing/chainview/bitcoind.go +++ b/routing/chainview/bitcoind.go @@ -264,7 +264,7 @@ func (b *BitcoindFilteredChainView) chainFilterer() { continue } - filteredTxns = append(filteredTxns, tx) + filteredTxns = append(filteredTxns, tx.Copy()) txAlreadyFiltered = true } } diff --git a/routing/chainview/btcd.go b/routing/chainview/btcd.go index c0234386a..876940693 100644 --- a/routing/chainview/btcd.go +++ b/routing/chainview/btcd.go @@ -283,7 +283,7 @@ func (b *BtcdFilteredChainView) chainFilterer() { continue } - filteredTxns = append(filteredTxns, tx) + filteredTxns = append(filteredTxns, tx.Copy()) txAlreadyFiltered = true } diff --git a/routing/chainview/neutrino.go b/routing/chainview/neutrino.go index 8bba71a7e..d5b4ca647 100644 --- a/routing/chainview/neutrino.go +++ b/routing/chainview/neutrino.go @@ -296,7 +296,7 @@ func (c *CfFilteredChainView) FilterBlock(blockHash *chainhash.Hash) (*FilteredB if ok { filteredBlock.Transactions = append( filteredBlock.Transactions, - tx.MsgTx(), + tx.MsgTx().Copy(), ) c.filterMtx.Lock() diff --git a/routing/notifications_test.go b/routing/notifications_test.go index 5d6695010..48b0a2766 100644 --- a/routing/notifications_test.go +++ b/routing/notifications_test.go @@ -378,7 +378,7 @@ func (m *mockChainView) FilterBlock(blockHash *chainhash.Hash) (*chainview.Filte prevOp := txIn.PreviousOutPoint if _, ok := m.filter[prevOp]; ok { filteredBlock.Transactions = append( - filteredBlock.Transactions, tx, + filteredBlock.Transactions, tx.Copy(), ) m.Lock() diff --git a/routing/router.go b/routing/router.go index 80f647807..f514907b5 100644 --- a/routing/router.go +++ b/routing/router.go @@ -1894,7 +1894,7 @@ func (r *ChannelRouter) fetchFundingTx( chanID.TxIndex, numTxns-1, chanID) } - return fundingBlock.Transactions[chanID.TxIndex], nil + return fundingBlock.Transactions[chanID.TxIndex].Copy(), nil } // routingMsg couples a routing related routing topology update to the diff --git a/watchtower/lookout/lookout.go b/watchtower/lookout/lookout.go index 22966ae93..280221b6a 100644 --- a/watchtower/lookout/lookout.go +++ b/watchtower/lookout/lookout.go @@ -165,7 +165,7 @@ func (l *Lookout) processEpoch(epoch *chainntnfs.BlockEpoch, hint := blob.NewBreachHintFromHash(&hash) txHints = append(txHints, hint) - hintToTx[hint] = tx + hintToTx[hint] = tx.Copy() } // Query the database to see if any of the breach hints cause a match