From 3aa5e650fb3b2b71c20d27c88bcfbb1393b9d830 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Tue, 20 Apr 2021 08:50:55 +0200 Subject: [PATCH] lntest/mock: set input index on spend event --- lntest/mock/spendnotifier.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lntest/mock/spendnotifier.go b/lntest/mock/spendnotifier.go index 7d51b458..ced93f25 100644 --- a/lntest/mock/spendnotifier.go +++ b/lntest/mock/spendnotifier.go @@ -67,13 +67,20 @@ func (s *SpendNotifier) Spend(outpoint *wire.OutPoint, height int32, s.mtx.Lock() defer s.mtx.Unlock() + var inputIndex uint32 + for i, in := range txn.TxIn { + if in.PreviousOutPoint == *outpoint { + inputIndex = uint32(i) + } + } + txnHash := txn.TxHash() details := &chainntnfs.SpendDetail{ SpentOutPoint: outpoint, SpendingHeight: height, SpendingTx: txn, SpenderTxHash: &txnHash, - SpenderInputIndex: outpoint.Index, + SpenderInputIndex: inputIndex, } // Cache details in case of late registration.