Skip to content

Commit

Permalink
cln: uses the exact channel to probe payment
Browse files Browse the repository at this point in the history
To ensures that the invoice payment is probed
via the direct channel to the peer.
  • Loading branch information
YusukeShimizu committed Dec 19, 2023
1 parent dbec5bb commit 49b72cf
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions clightning/clightning.go
Original file line number Diff line number Diff line change
Expand Up @@ -640,17 +640,23 @@ func (cl *ClightningClient) ProbePayment(scid string, amountMsat uint64) (bool,
}
}

route, err := cl.glightning.GetRoute(channel.PeerId, amountMsat, 1, 0, cl.nodeId, 0, nil, 1)
if err != nil {
return false, "", fmt.Errorf("GetRoute() %w", err)
}
preimage, err := lightning.GetPreimage()
if err != nil {
return false, "", fmt.Errorf("GetPreimage() %w", err)
}
paymentHash := preimage.Hash().String()
_, err = cl.glightning.SendPay(
route,
[]glightning.RouteHop{
{
Id: channel.PeerId,
ShortChannelId: scid,
AmountMsat: glightning.AmountFromMSat(amountMsat),
// The total expected CLTV.
// The default GetRoute value of 9 is set here.
Delay: 9,
Direction: 0,
},
},
paymentHash,
"",
amountMsat,
Expand Down

0 comments on commit 49b72cf

Please sign in to comment.