chainntnfs/btcdnotify: properly include SpendingHeight in SpendDetails
This commit modifies the btcdnotify implementation of the ChainNotifier interface to properly include the height in which the watched output was spent in the SpendDetail sent as a notification. The set of tests have also been updated to assert that the proper spending height is included in received notification.
This commit is contained in:
2 files changed
+26
-9
No files matched your search
@@ -369,15 +369,22 @@ out:
|
||||
// the notification subscriber.
|
||||
if clients, ok := b.spendNotifications[prevOut]; ok {
|
||||
spenderSha := newSpend.tx.Hash()
|
||||
for _, ntfn := range clients {
|
||||
spendDetails := &chainntnfs.SpendDetail{
|
||||
SpentOutPoint: ntfn.targetOutpoint,
|
||||
SpenderTxHash: spenderSha,
|
||||
// TODO(roasbeef): copy tx?
|
||||
SpendingTx: spendingTx.MsgTx(),
|
||||
SpenderInputIndex: uint32(i),
|
||||
}
|
||||
spendDetails := &chainntnfs.SpendDetail{
|
||||
SpentOutPoint: &prevOut,
|
||||
SpenderTxHash: spenderSha,
|
||||
SpendingTx: spendingTx.MsgTx(),
|
||||
SpenderInputIndex: uint32(i),
|
||||
}
|
||||
// TODO(roasbeef): after change to
|
||||
// loadfilter, only notify on block
|
||||
// inclusion?
|
||||
if newSpend.details != nil {
|
||||
spendDetails.SpendingHeight = newSpend.details.Height
|
||||
} else {
|
||||
spendDetails.SpendingHeight = currentHeight
|
||||
}
|
||||
|
||||
for _, ntfn := range clients {
|
||||
chainntnfs.Log.Infof("Dispatching "+
|
||||
"spend notification for "+
|
||||
"outpoint=%v", ntfn.targetOutpoint)
|
||||
|
||||
Reference in new issue
Block a user