Skip to main content

EncodeCustomRecords

EncodeCustomRecords allows RPC users to encode Taproot Asset channel related data into the TLV format that is used in the custom records of the lnd payment or other channel related RPCs. This RPC is completely stateless and does not perform any checks on the data provided, other than pure format validation.

Source: tapchannelrpc/tapchannel.proto

gRPC

rpc EncodeCustomRecords (EncodeCustomRecordsRequest) returns (EncodeCustomRecordsResponse);

REST

HTTP MethodPath
POST /v1/taproot-assets/channels/encode-custom-data

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 = {
router_send_payment: <RouterSendPaymentData>,
};
client.encodeCustomRecords(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "custom_records": <CustomRecordsEntry>,
// }

Messages

tapchannelrpc.EncodeCustomRecordsRequest

Source: tapchannelrpc/tapchannel.proto

FieldgRPC TypeREST TypeREST Placement
router_send_payment
RouterSendPaymentDataobjectbody

tapchannelrpc.EncodeCustomRecordsResponse

Source: tapchannelrpc/tapchannel.proto

FieldgRPC TypeREST Type
custom_records
CustomRecordsEntry[]object

Nested Messages

tapchannelrpc.EncodeCustomRecordsResponse.CustomRecordsEntry

FieldgRPC TypeREST Type
key
uint64unknown
value
bytesunknown

tapchannelrpc.RouterSendPaymentData

FieldgRPC TypeREST Type
asset_amounts
AssetAmountsEntry[]object
rfq_id
bytesstring

tapchannelrpc.RouterSendPaymentData.AssetAmountsEntry

FieldgRPC TypeREST Type
key
stringunknown
value
uint64unknown