Skip to main content

FundVirtualPsbt

FundVirtualPsbt selects inputs from the available asset commitments to fund a virtual transaction matching the template.

Source: assetwalletrpc/assetwallet.proto

gRPC

rpc FundVirtualPsbt (FundVirtualPsbtRequest) returns (FundVirtualPsbtResponse);

REST

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

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 = {
psbt: <bytes>,
raw: <TxTemplate>,
coin_select_type: <CoinSelectType>,
};
client.fundVirtualPsbt(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "funded_psbt": <bytes>,
// "change_output_index": <int32>,
// "passive_asset_psbts": <bytes>,
// }

Messages

assetwalletrpc.FundVirtualPsbtRequest

Source: assetwalletrpc/assetwallet.proto

FieldgRPC TypeREST TypeREST Placement
psbt
bytesstringbody
raw
TxTemplateobjectbody
coin_select_type
CoinSelectTypestringbody

assetwalletrpc.FundVirtualPsbtResponse

Source: assetwalletrpc/assetwallet.proto

FieldgRPC TypeREST Type
funded_psbt
bytesstring
change_output_index
int32integer
passive_asset_psbts
bytes[]array

Nested Messages

assetwalletrpc.PrevId

FieldgRPC TypeREST Type
outpoint
OutPointobject
id
bytesstring
script_key
bytesstring

assetwalletrpc.TxTemplate

FieldgRPC TypeREST Type
inputs
PrevId[]array
recipients
RecipientsEntry[]object

assetwalletrpc.TxTemplate.RecipientsEntry

FieldgRPC TypeREST Type
key
stringunknown
value
uint64unknown

taprpc.OutPoint

FieldgRPC TypeREST Type
txid
bytesstring
output_index
uint32integer

Enums

assetwalletrpc.CoinSelectType

NameNumber
COIN_SELECT_DEFAULT
0
COIN_SELECT_BIP86_ONLY
1
COIN_SELECT_SCRIPT_TREES_ALLOWED
2