Skip to main content

SendPayment

SendPayment is a wrapper around lnd's routerrpc.SendPaymentV2 RPC method with asset specific parameters. It allows RPC users to send asset keysend payments (direct payments) or payments to an invoice with a specified asset amount.

Source: tapchannelrpc/tapchannel.proto

gRPC

info

This is a server-streaming RPC

rpc SendPayment (SendPaymentRequest) returns (stream SendPaymentResponse);

REST

HTTP MethodPath
POST /v1/taproot-assets/channels/send-payment

Code Samples

const fs = require('fs');
const grpc = require('@grpc/grpc-js');
const protoLoader = require('@grpc/proto-loader');

const GRPC_HOST = 'localhost:10029'
const MACAROON_PATH = 'TAPROOT-ASSETS_DIR/regtest/taproot-assets.macaroon'
const TLS_PATH = 'TAPROOT-ASSETS_DIR/tls.cert'

const loaderOptions = {
keepCase: true,
longs: String,
enums: String,
defaults: true,
oneofs: true,
};
const packageDefinition = protoLoader.loadSync('tapchannelrpc/tapchannel.proto', loaderOptions);
const tapchannelrpc = grpc.loadPackageDefinition(packageDefinition).tapchannelrpc;
process.env.GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA';
const tlsCert = fs.readFileSync(TLS_PATH);
const sslCreds = grpc.credentials.createSsl(tlsCert);
const macaroon = fs.readFileSync(MACAROON_PATH).toString('hex');
const macaroonCreds = grpc.credentials.createFromMetadataGenerator(function(args, callback) {
let metadata = new grpc.Metadata();
metadata.add('macaroon', macaroon);
callback(null, metadata);
});
let creds = grpc.credentials.combineChannelCredentials(sslCreds, macaroonCreds);
let client = new tapchannelrpc.TaprootAssetChannels(GRPC_HOST, creds);
let request = {
asset_id: <bytes>,
asset_amount: <uint64>,
peer_pubkey: <bytes>,
payment_request: <SendPaymentRequest>,
rfq_id: <bytes>,
allow_overpay: <bool>,
};
let call = client.sendPayment(request);
call.on('data', function(response) {
// A response was received from the server.
console.log(response);
});
call.on('status', function(status) {
// The current status of the stream.
});
call.on('end', function() {
// The server has closed the stream.
});
// Console output:
// {
// "accepted_sell_order": <PeerAcceptedSellQuote>,
// "payment_result": <Payment>,
// }

Messages

tapchannelrpc.SendPaymentRequest

Source: tapchannelrpc/tapchannel.proto

FieldgRPC TypeREST TypeREST Placement
asset_id
bytesstringbody
asset_amount
uint64stringbody
peer_pubkey
bytesstringbody
payment_request
SendPaymentRequestobjectbody
rfq_id
bytesstringbody
allow_overpay
boolbooleanbody

tapchannelrpc.SendPaymentResponse

Source: tapchannelrpc/tapchannel.proto

FieldgRPC TypeREST Type
accepted_sell_order
PeerAcceptedSellQuoteobject
payment_result
Paymentobject

Nested Messages

rfqrpc.FixedPoint

FieldgRPC TypeREST Type
coefficient
stringstring
scale
uint32integer

rfqrpc.PeerAcceptedSellQuote

FieldgRPC TypeREST Type
peer
stringstring
id
bytesstring
scid
uint64string
asset_amount
uint64string
bid_asset_rate
FixedPointobject
expiry
uint64string
min_transportable_msat
uint64string