Skip to main content

AnchorVirtualPsbts

AnchorVirtualPsbts merges and then commits multiple virtual transactions in a single BTC level anchor transaction. This RPC should be used if the BTC level anchor transaction of the assets to be spent are encumbered by a normal key and don't require any special spending conditions. For any custom spending conditions on the BTC level, the two RPCs CommitVirtualPsbts and PublishAndLogTransfer should be used instead (which in combination do the same as this RPC but allow for more flexibility).

Source: assetwalletrpc/assetwallet.proto

gRPC

rpc AnchorVirtualPsbts (AnchorVirtualPsbtsRequest) returns (SendAssetResponse);

REST

HTTP MethodPath
POST /v1/taproot-assets/wallet/virtual-psbt/anchor

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 = {
virtual_psbts: <bytes>,
};
client.anchorVirtualPsbts(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "transfer": <AssetTransfer>,
// }

Messages

assetwalletrpc.AnchorVirtualPsbtsRequest

Source: assetwalletrpc/assetwallet.proto

FieldgRPC TypeREST TypeREST Placement
virtual_psbts
bytes[]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
anchor_tx_block_hash
ChainHashobject

taprpc.ChainHash

FieldgRPC TypeREST Type
hash
bytesstring
hash_str
stringstring

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
lock_time
uint64string
relative_lock_time
uint64string
proof_delivery_status
ProofDeliveryStatusstring

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

taprpc.ProofDeliveryStatus

NameNumber
PROOF_DELIVERY_STATUS_NOT_APPLICABLE
0
PROOF_DELIVERY_STATUS_COMPLETE
1
PROOF_DELIVERY_STATUS_PENDING
2