Skip to main content

DecodeAssetPayReq

DecodeAssetPayReq is similar to lnd's lnrpc.DecodePayReq, but it accepts an asset ID and returns the invoice amount expressed in asset units along side the normal information.

Source: tapchannelrpc/tapchannel.proto

gRPC

rpc DecodeAssetPayReq (AssetPayReq) returns (AssetPayReqResponse);

REST

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

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>,
pay_req_string: <string>,
};
client.decodeAssetPayReq(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "asset_amount": <uint64>,
// "decimal_display": <DecimalDisplay>,
// "asset_group": <AssetGroup>,
// "genesis_info": <GenesisInfo>,
// "pay_req": <PayReq>,
// }

Messages

tapchannelrpc.AssetPayReq

Source: tapchannelrpc/tapchannel.proto

FieldgRPC TypeREST TypeREST Placement
asset_id
bytesstringbody
pay_req_string
stringstringbody

tapchannelrpc.AssetPayReqResponse

Source: tapchannelrpc/tapchannel.proto

FieldgRPC TypeREST Type
asset_amount
uint64string
decimal_display
DecimalDisplayobject
asset_group
AssetGroupobject
genesis_info
GenesisInfoobject
pay_req
PayReqobject

Nested Messages

taprpc.AssetGroup

FieldgRPC TypeREST Type
raw_group_key
bytesstring
tweaked_group_key
bytesstring
asset_witness
bytesstring
tapscript_root
bytesstring

taprpc.DecimalDisplay

FieldgRPC TypeREST Type
decimal_display
uint32integer

taprpc.GenesisInfo

FieldgRPC TypeREST Type
genesis_point
stringstring
name
stringstring
meta_hash
bytesstring
asset_id
bytesstring
asset_type
AssetTypestring
output_index
uint32integer

Enums

taprpc.AssetType

NameNumber
NORMAL
0
COLLECTIBLE
1