Skip to main content

SubscribePayments

SubscribePayments is a wrapper around lnd's routerrpc.TrackPayments method that only streams payment updates that involve at least one Taproot Asset. The full lnd payment is returned along with the decoded asset amounts that the payment's HTLCs carry, so that callers don't need to parse the custom channel data themselves. All request fields behave the same way as they do for lnd's routerrpc.TrackPayments RPC method.

Source: tapchannelrpc/tapchannel.proto

gRPC

info

This is a server-streaming RPC

rpc SubscribePayments (SubscribePaymentsRequest) returns (stream AssetPayment);

REST

HTTP MethodPath
POST /v1/taproot-assets/channels/payments/subscribe

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 = 'TAPD_DIR/data/regtest/admin.macaroon'
const TLS_PATH = 'TAPD_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 = {
request: <TrackPaymentsRequest>,
};
let call = client.subscribePayments(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:
// {
// "payment": <Payment>,
// "asset_amounts": <AssetAmount>,
// }

Messages

tapchannelrpc.SubscribePaymentsRequest

Source: tapchannelrpc/tapchannel.proto

FieldgRPC TypeREST TypeREST Placement
request
TrackPaymentsRequestobjectbody

tapchannelrpc.AssetPayment

Source: tapchannelrpc/tapchannel.proto

FieldgRPC TypeREST Type
payment
Paymentobject
asset_amounts
AssetAmount[]array

Nested Messages

tapchannelrpc.AssetAmount

FieldgRPC TypeREST Type
asset_id
bytesstring
amount
uint64string
group_key
bytesstring