mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-04 09:48:19 +01:00
Merge pull request #8372 from mohamedawnallah/deep-copy-transactions-GetBlock
routing: deep copy any transaction we obtain from `GetBlock` call.
This commit is contained in:
commit
26c466aa80
11 changed files with 20 additions and 16 deletions
|
@ -613,7 +613,7 @@ func (b *BitcoindNotifier) confDetailsManually(confRequest chainntnfs.ConfReques
|
||||||
}
|
}
|
||||||
|
|
||||||
return &chainntnfs.TxConfirmation{
|
return &chainntnfs.TxConfirmation{
|
||||||
Tx: tx,
|
Tx: tx.Copy(),
|
||||||
BlockHash: blockHash,
|
BlockHash: blockHash,
|
||||||
BlockHeight: height,
|
BlockHeight: height,
|
||||||
TxIndex: uint32(txIndex),
|
TxIndex: uint32(txIndex),
|
||||||
|
@ -874,11 +874,13 @@ func (b *BitcoindNotifier) historicalSpendDetails(
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
txHash := tx.TxHash()
|
txCopy := tx.Copy()
|
||||||
|
txHash := txCopy.TxHash()
|
||||||
|
spendOutPoint := &txCopy.TxIn[inputIdx].PreviousOutPoint
|
||||||
return &chainntnfs.SpendDetail{
|
return &chainntnfs.SpendDetail{
|
||||||
SpentOutPoint: &tx.TxIn[inputIdx].PreviousOutPoint,
|
SpentOutPoint: spendOutPoint,
|
||||||
SpenderTxHash: &txHash,
|
SpenderTxHash: &txHash,
|
||||||
SpendingTx: tx,
|
SpendingTx: txCopy,
|
||||||
SpenderInputIndex: inputIdx,
|
SpenderInputIndex: inputIdx,
|
||||||
SpendingHeight: int32(height),
|
SpendingHeight: int32(height),
|
||||||
}, nil
|
}, nil
|
||||||
|
|
|
@ -667,7 +667,7 @@ func (b *BtcdNotifier) confDetailsManually(confRequest chainntnfs.ConfRequest,
|
||||||
}
|
}
|
||||||
|
|
||||||
return &chainntnfs.TxConfirmation{
|
return &chainntnfs.TxConfirmation{
|
||||||
Tx: tx,
|
Tx: tx.Copy(),
|
||||||
BlockHash: blockHash,
|
BlockHash: blockHash,
|
||||||
BlockHeight: height,
|
BlockHeight: height,
|
||||||
TxIndex: uint32(txIndex),
|
TxIndex: uint32(txIndex),
|
||||||
|
|
|
@ -788,7 +788,7 @@ func ConfDetailsFromTxIndex(chainConn TxIndexConn, r ConfRequest,
|
||||||
}
|
}
|
||||||
|
|
||||||
return &TxConfirmation{
|
return &TxConfirmation{
|
||||||
Tx: &tx,
|
Tx: tx.Copy(),
|
||||||
BlockHash: blockHash,
|
BlockHash: blockHash,
|
||||||
BlockHeight: uint32(blockHeight),
|
BlockHeight: uint32(blockHeight),
|
||||||
TxIndex: uint32(txIndex),
|
TxIndex: uint32(txIndex),
|
||||||
|
|
|
@ -635,7 +635,7 @@ func (n *NeutrinoNotifier) historicalConfDetails(confRequest chainntnfs.ConfRequ
|
||||||
}
|
}
|
||||||
|
|
||||||
return &chainntnfs.TxConfirmation{
|
return &chainntnfs.TxConfirmation{
|
||||||
Tx: tx.MsgTx(),
|
Tx: tx.MsgTx().Copy(),
|
||||||
BlockHash: blockHash,
|
BlockHash: blockHash,
|
||||||
BlockHeight: scanHeight,
|
BlockHeight: scanHeight,
|
||||||
TxIndex: uint32(i),
|
TxIndex: uint32(i),
|
||||||
|
|
|
@ -1168,10 +1168,12 @@ func testListTransactionDetails(miner *rpctest.Harness,
|
||||||
t.Fatalf("err fetching block: %s", err)
|
t.Fatalf("err fetching block: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
transactions :=
|
transactions := make(
|
||||||
make(map[chainhash.Hash][]*wire.TxOut, len(fetchedBlock.Transactions))
|
map[chainhash.Hash][]*wire.TxOut,
|
||||||
|
len(fetchedBlock.Transactions),
|
||||||
|
)
|
||||||
for _, tx := range fetchedBlock.Transactions {
|
for _, tx := range fetchedBlock.Transactions {
|
||||||
transactions[tx.TxHash()] = tx.TxOut
|
transactions[tx.TxHash()] = tx.Copy().TxOut
|
||||||
}
|
}
|
||||||
|
|
||||||
blockTxOuts[fetchedBlock.BlockHash()] = transactions
|
blockTxOuts[fetchedBlock.BlockHash()] = transactions
|
||||||
|
|
|
@ -264,7 +264,7 @@ func (b *BitcoindFilteredChainView) chainFilterer() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
filteredTxns = append(filteredTxns, tx)
|
filteredTxns = append(filteredTxns, tx.Copy())
|
||||||
txAlreadyFiltered = true
|
txAlreadyFiltered = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -283,7 +283,7 @@ func (b *BtcdFilteredChainView) chainFilterer() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
filteredTxns = append(filteredTxns, tx)
|
filteredTxns = append(filteredTxns, tx.Copy())
|
||||||
txAlreadyFiltered = true
|
txAlreadyFiltered = true
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -296,7 +296,7 @@ func (c *CfFilteredChainView) FilterBlock(blockHash *chainhash.Hash) (*FilteredB
|
||||||
if ok {
|
if ok {
|
||||||
filteredBlock.Transactions = append(
|
filteredBlock.Transactions = append(
|
||||||
filteredBlock.Transactions,
|
filteredBlock.Transactions,
|
||||||
tx.MsgTx(),
|
tx.MsgTx().Copy(),
|
||||||
)
|
)
|
||||||
|
|
||||||
c.filterMtx.Lock()
|
c.filterMtx.Lock()
|
||||||
|
|
|
@ -378,7 +378,7 @@ func (m *mockChainView) FilterBlock(blockHash *chainhash.Hash) (*chainview.Filte
|
||||||
prevOp := txIn.PreviousOutPoint
|
prevOp := txIn.PreviousOutPoint
|
||||||
if _, ok := m.filter[prevOp]; ok {
|
if _, ok := m.filter[prevOp]; ok {
|
||||||
filteredBlock.Transactions = append(
|
filteredBlock.Transactions = append(
|
||||||
filteredBlock.Transactions, tx,
|
filteredBlock.Transactions, tx.Copy(),
|
||||||
)
|
)
|
||||||
|
|
||||||
m.Lock()
|
m.Lock()
|
||||||
|
|
|
@ -1894,7 +1894,7 @@ func (r *ChannelRouter) fetchFundingTx(
|
||||||
chanID.TxIndex, numTxns-1, chanID)
|
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
|
// 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)
|
hint := blob.NewBreachHintFromHash(&hash)
|
||||||
|
|
||||||
txHints = append(txHints, hint)
|
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
|
// Query the database to see if any of the breach hints cause a match
|
||||||
|
|
Loading…
Add table
Reference in a new issue