Skip to main content

FundChannel

FundChannel initiates the channel funding negotiation with a peer for the creation of a channel that contains a specified amount of a given asset.

Source: tapchannelrpc/tapchannel.proto

gRPC

rpc FundChannel (FundChannelRequest) returns (FundChannelResponse);

REST

HTTP MethodPath
GET /v1/taproot-assets/channels/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('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_amount: <uint64>,
asset_id: <bytes>,
peer_pubkey: <bytes>,
fee_rate_sat_per_vbyte: <uint32>,
push_sat: <int64>,
};
client.fundChannel(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "txid": <string>,
// "output_index": <int32>,
// }

Messages

tapchannelrpc.FundChannelRequest

Source: tapchannelrpc/tapchannel.proto

FieldgRPC TypeREST TypeREST Placement
asset_amount
uint64stringquery
asset_id
bytesstringquery
peer_pubkey
bytesstringquery
fee_rate_sat_per_vbyte
uint32integerquery
push_sat
int64stringquery

tapchannelrpc.FundChannelResponse

Source: tapchannelrpc/tapchannel.proto

FieldgRPC TypeREST Type
txid
stringstring
output_index
int32integer