Skip to content

Commit 3fa9217

Browse files
committed
rpcserver: check channel balance on keysend
1 parent e0d18c6 commit 3fa9217

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

rpcserver.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7743,8 +7743,26 @@ func (r *rpcServer) SendPayment(req *tchrpc.SendPaymentRequest,
77437743
"for keysend payment")
77447744
}
77457745

7746-
var balances []*rfqmsg.AssetBalance
7746+
if len(req.PaymentRequest.Dest) == 0 {
7747+
return fmt.Errorf("destination node must be " +
7748+
"specified for keysend payment")
7749+
}
7750+
7751+
dest, err := route.NewVertexFromBytes(req.PaymentRequest.Dest)
7752+
if err != nil {
7753+
return fmt.Errorf("error parsing destination node "+
7754+
"pubkey: %w", err)
7755+
}
77477756

7757+
// We check that we have the asset amount available in the
7758+
// channel.
7759+
_, err = r.rfqChannel(ctx, specifier, &dest, SendIntention)
7760+
if err != nil {
7761+
return fmt.Errorf("error finding asset channel to "+
7762+
"use: %w", err)
7763+
}
7764+
7765+
var balances []*rfqmsg.AssetBalance
77487766
switch {
77497767
case specifier.HasId():
77507768
balances = []*rfqmsg.AssetBalance{

0 commit comments

Comments
 (0)