lnd+lnrpc: update fwdinghistory message
In this commit we update the returned message for fwdinghistory to include the htlcindex for all forwarded htlcs.
This commit is contained in:
5 files changed
+860
-778
No files matched your search
@@ -213,6 +213,31 @@ func testMultiHopPayments(ht *lntest.HarnessTest) {
|
||||
require.Equal(ht, aliceAlias, event.PeerAliasOut)
|
||||
}
|
||||
|
||||
// Verify HTLC IDs are not nil and unique across all forwarding events.
|
||||
seenIDs := make(map[uint64]bool)
|
||||
for _, event := range fwdingHistory.ForwardingEvents {
|
||||
// We check that the incoming and outgoing htlc indices are not
|
||||
// set to nil. The indices are required for any forwarding event
|
||||
// recorded after v0.20.
|
||||
require.NotNil(ht, event.IncomingHtlcId)
|
||||
require.NotNil(ht, event.OutgoingHtlcId)
|
||||
|
||||
require.False(ht, seenIDs[*event.IncomingHtlcId])
|
||||
require.False(ht, seenIDs[*event.OutgoingHtlcId])
|
||||
seenIDs[*event.IncomingHtlcId] = true
|
||||
seenIDs[*event.OutgoingHtlcId] = true
|
||||
}
|
||||
|
||||
// The HTLC IDs should be exactly 0, 1, 2, 3, 4.
|
||||
expectedIDs := map[uint64]bool{
|
||||
0: true,
|
||||
1: true,
|
||||
2: true,
|
||||
3: true,
|
||||
4: true,
|
||||
}
|
||||
require.Equal(ht, expectedIDs, seenIDs)
|
||||
|
||||
// We expect Carol to have successful forwards and settles for
|
||||
// her sends.
|
||||
ht.AssertHtlcEvents(
|
||||
|
||||
+807
-778
File diff suppressed because it is too large.
Load diff
@@ -4716,6 +4716,14 @@ message ForwardingEvent {
|
||||
// The peer alias of the outgoing channel.
|
||||
string peer_alias_out = 13;
|
||||
|
||||
// The ID of the incoming HTLC in the payment circuit. This field is
|
||||
// optional and is unset for forwarding events happened before v0.20.
|
||||
optional uint64 incoming_htlc_id = 14;
|
||||
|
||||
// The ID of the outgoing HTLC in the payment circuit. This field is
|
||||
// optional and may be unset for legacy forwarding events.
|
||||
optional uint64 outgoing_htlc_id = 15;
|
||||
|
||||
// TODO(roasbeef): add settlement latency?
|
||||
// * use FPE on the chan id?
|
||||
// * also list failures?
|
||||
|
||||
@@ -5075,6 +5075,16 @@
|
||||
"peer_alias_out": {
|
||||
"type": "string",
|
||||
"description": "The peer alias of the outgoing channel."
|
||||
},
|
||||
"incoming_htlc_id": {
|
||||
"type": "string",
|
||||
"format": "uint64",
|
||||
"description": "The ID of the incoming HTLC in the payment circuit. This field is\noptional and is unset for forwarding events happened before v0.20."
|
||||
},
|
||||
"outgoing_htlc_id": {
|
||||
"type": "string",
|
||||
"format": "uint64",
|
||||
"description": "The ID of the outgoing HTLC in the payment circuit. This field is\noptional and may be unset for legacy forwarding events."
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -8100,6 +8100,16 @@ func (r *rpcServer) ForwardingHistory(ctx context.Context,
|
||||
AmtOutMsat: uint64(amtOutMsat),
|
||||
}
|
||||
|
||||
// If the incoming htlc id is present, add it to the response.
|
||||
event.IncomingHtlcID.WhenSome(func(id uint64) {
|
||||
resp.ForwardingEvents[i].IncomingHtlcId = &id
|
||||
})
|
||||
|
||||
// If the outgoing htlc id is present, add it to the response.
|
||||
event.OutgoingHtlcID.WhenSome(func(id uint64) {
|
||||
resp.ForwardingEvents[i].OutgoingHtlcId = &id
|
||||
})
|
||||
|
||||
if req.PeerAliasLookup {
|
||||
aliasIn, err := getRemoteAlias(event.IncomingChanID)
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user