Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions itest/channels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package itest
import (
"context"

"github.com/lightninglabs/taproot-assets/internal/test"
"github.com/lightninglabs/taproot-assets/rfqmath"
"github.com/lightninglabs/taproot-assets/rfqmsg"
tchrpc "github.com/lightninglabs/taproot-assets/taprpc/tapchannelrpc"
"github.com/lightningnetwork/lnd/lnrpc"
Expand Down Expand Up @@ -66,6 +68,26 @@ func testChannelRPCs(t *harnessTest) {
"payment",
)

// Make sure that the minimum satoshi amount for a keysend payment is
// enforced.
stream, err = t.tapd.SendPayment(ctx, &tchrpc.SendPaymentRequest{
AssetAmount: 123,
AssetId: dummyByteArr[:],
PaymentRequest: &routerrpc.SendPaymentRequest{
Dest: test.RandPubKey(t.t).SerializeCompressed(),
DestCustomRecords: map[uint64][]byte{
record.KeySendType: dummyByteArr[:],
},
Amt: int64(rfqmath.DefaultOnChainHtlcSat - 1),
},
})
require.NoError(t.t, err)

_, err = stream.Recv()
require.ErrorContains(
t.t, err, "keysend payment satoshi amount must be greater",
)

// Now let's also try the invoice path, which should fail because we
// don't have any asset channels with peers that we could ask for a
// quote.
Expand Down
10 changes: 10 additions & 0 deletions rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -7798,6 +7798,16 @@ func (r *rpcServer) SendPayment(req *tchrpc.SendPaymentRequest,
"pubkey: %w", err)
}

// We must enforce a minimum satoshi amount to make sure the
// carrier HTLC is above dust. This is handled by the traffic
// shaper for invoice-based payments, but for keysend payments
// we need to do it here.
if pReq.Amt < int64(rfqmath.DefaultOnChainHtlcSat) {
return fmt.Errorf("keysend payment satoshi amount "+
"must be greater than or equal to %d satoshis",
rfqmath.DefaultOnChainHtlcSat)
}

// We check that we have the asset amount available in the
// channel.
_, err = r.cfg.RfqManager.FetchChannel(
Expand Down