lntest/mock: set input index on spend event

This commit is contained in:
Johan T. Halseth 2021-04-20 08:50:55 +02:00
parent a6724c1088
commit 3aa5e650fb
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26

@ -67,13 +67,20 @@ func (s *SpendNotifier) Spend(outpoint *wire.OutPoint, height int32,
s.mtx.Lock() s.mtx.Lock()
defer s.mtx.Unlock() defer s.mtx.Unlock()
var inputIndex uint32
for i, in := range txn.TxIn {
if in.PreviousOutPoint == *outpoint {
inputIndex = uint32(i)
}
}
txnHash := txn.TxHash() txnHash := txn.TxHash()
details := &chainntnfs.SpendDetail{ details := &chainntnfs.SpendDetail{
SpentOutPoint: outpoint, SpentOutPoint: outpoint,
SpendingHeight: height, SpendingHeight: height,
SpendingTx: txn, SpendingTx: txn,
SpenderTxHash: &txnHash, SpenderTxHash: &txnHash,
SpenderInputIndex: outpoint.Index, SpenderInputIndex: inputIndex,
} }
// Cache details in case of late registration. // Cache details in case of late registration.