Skip to main content

SubscribeInvoices

SubscribeInvoices is a wrapper around lnd's lnrpc.SubscribeInvoices method that only streams invoices that involve at least one Taproot Asset. The full lnd invoice is returned along with the decoded asset amounts that the invoice'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 lnrpc.SubscribeInvoices RPC method.

Source: tapchannelrpc/tapchannel.proto

gRPC

info

This is a server-streaming RPC

rpc SubscribeInvoices (SubscribeInvoicesRequest) returns (stream AssetInvoice);

REST

HTTP MethodPath
POST /v1/taproot-assets/channels/invoices/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: <InvoiceSubscription>,
};
let call = client.subscribeInvoices(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:
// {
// "invoice": <Invoice>,
// "asset_amounts": <AssetAmount>,
// }

Messages

tapchannelrpc.SubscribeInvoicesRequest

Source: tapchannelrpc/tapchannel.proto

FieldgRPC TypeREST TypeREST Placement
request
InvoiceSubscriptionobjectbody

tapchannelrpc.AssetInvoice

Source: tapchannelrpc/tapchannel.proto

FieldgRPC TypeREST Type
invoice
Invoiceobject
asset_amounts
AssetAmount[]array

Nested Messages

tapchannelrpc.AssetAmount

FieldgRPC TypeREST Type
asset_id
bytesstring
amount
uint64string
group_key
bytesstring