Skip to main content

AddInvoice

AddInvoice is a wrapper around lnd's lnrpc.AddInvoice method with asset specific parameters. It allows RPC users to create invoices that correspond to the specified asset amount.

Source: tapchannelrpc/tapchannel.proto

gRPC

rpc AddInvoice (AddInvoiceRequest) returns (AddInvoiceResponse);

REST

HTTP MethodPath
POST /v1/taproot-assets/channels/invoice

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>,
invoice_request: <Invoice>,
};
client.addInvoice(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "accepted_buy_quote": <PeerAcceptedBuyQuote>,
// "invoice_result": <AddInvoiceResponse>,
// }

Messages

tapchannelrpc.AddInvoiceRequest

Source: tapchannelrpc/tapchannel.proto

FieldgRPC TypeREST TypeREST Placement
asset_id
bytesstringbody
asset_amount
uint64stringbody
peer_pubkey
bytesstringbody
invoice_request
Invoiceobjectbody

tapchannelrpc.AddInvoiceResponse

Source: tapchannelrpc/tapchannel.proto

FieldgRPC TypeREST Type
accepted_buy_quote
PeerAcceptedBuyQuoteobject
invoice_result
AddInvoiceResponseobject

Nested Messages

rfqrpc.PeerAcceptedBuyQuote

FieldgRPC TypeREST Type
peer
stringstring
id
bytesstring
scid
uint64string
asset_amount
uint64string
ask_price
uint64string
expiry
uint64string