Skip to main content

PublishAndLogTransfer

PublishAndLogTransfer accepts a fully committed and signed anchor transaction and publishes it to the Bitcoin network. It also logs the transfer of the given active and passive assets in the database and ships any outgoing proofs to the counterparties.

Source: assetwalletrpc/assetwallet.proto

gRPC

rpc PublishAndLogTransfer (PublishAndLogRequest) returns (SendAssetResponse);

REST

HTTP MethodPath
POST /v1/taproot-assets/wallet/virtual-psbt/log-transfer

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('assetwalletrpc/assetwallet.proto', loaderOptions);
const assetwalletrpc = grpc.loadPackageDefinition(packageDefinition).assetwalletrpc;
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 assetwalletrpc.AssetWallet(GRPC_HOST, creds);
let request = {
anchor_psbt: <bytes>,
virtual_psbts: <bytes>,
passive_asset_psbts: <bytes>,
change_output_index: <int32>,
lnd_locked_utxos: <OutPoint>,
};
client.publishAndLogTransfer(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "transfer": <AssetTransfer>,
// }

Messages

assetwalletrpc.PublishAndLogRequest

Source: assetwalletrpc/assetwallet.proto

FieldgRPC TypeREST TypeREST Placement
anchor_psbt
bytesstringbody
virtual_psbts
bytes[]arraybody
passive_asset_psbts
bytes[]arraybody
change_output_index
int32integerbody
lnd_locked_utxos
OutPoint[]arraybody

taprpc.SendAssetResponse

Source: taprootassets.proto

FieldgRPC TypeREST Type
transfer
AssetTransferobject

Nested Messages

taprpc.AssetTransfer

FieldgRPC TypeREST Type
transfer_timestamp
int64string
anchor_tx_hash
bytesstring
anchor_tx_height_hint
uint32integer
anchor_tx_chain_fees
int64string
inputs
TransferInput[]array
outputs
TransferOutput[]array

taprpc.OutPoint

FieldgRPC TypeREST Type
txid
bytesstring
output_index
uint32integer

taprpc.TransferInput

FieldgRPC TypeREST Type
anchor_point
stringstring
asset_id
bytesstring
script_key
bytesstring
amount
uint64string

taprpc.TransferOutput

FieldgRPC TypeREST Type
anchor
TransferOutputAnchorobject
script_key
bytesstring
script_key_is_local
boolboolean
amount
uint64string
new_proof_blob
bytesstring
split_commit_root_hash
bytesstring
output_type
OutputTypestring
asset_version
AssetVersionstring

taprpc.TransferOutputAnchor

FieldgRPC TypeREST Type
outpoint
stringstring
value
int64string
internal_key
bytesstring
taproot_asset_root
bytesstring
merkle_root
bytesstring
tapscript_sibling
bytesstring
num_passive_assets
uint32integer

Enums

taprpc.AssetVersion

NameNumber
ASSET_VERSION_V0
0
ASSET_VERSION_V1
1

taprpc.OutputType

NameNumber
OUTPUT_TYPE_SIMPLE
0
OUTPUT_TYPE_SPLIT_ROOT
1