mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 01:43:16 +01:00
routing: deep copy any transaciton we obtain from GetBlock
call.
This commit is contained in:
parent
2f04ce7c6e
commit
99908ed2dc
@ -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
|
||||
|
@ -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),
|
||||
|
@ -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),
|
||||
|
@ -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),
|
||||
|
@ -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
|
||||
|
@ -264,7 +264,7 @@ func (b *BitcoindFilteredChainView) chainFilterer() {
|
||||
continue
|
||||
}
|
||||
|
||||
filteredTxns = append(filteredTxns, tx)
|
||||
filteredTxns = append(filteredTxns, tx.Copy())
|
||||
txAlreadyFiltered = true
|
||||
}
|
||||
}
|
||||
|
@ -283,7 +283,7 @@ func (b *BtcdFilteredChainView) chainFilterer() {
|
||||
continue
|
||||
}
|
||||
|
||||
filteredTxns = append(filteredTxns, tx)
|
||||
filteredTxns = append(filteredTxns, tx.Copy())
|
||||
txAlreadyFiltered = true
|
||||
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user