Skip to content

transferBTC

transferBTC(config, params): Promise<TransferBTCResponse>

Transfers BTC with the given parameters. Optionally, it can broadcast the transaction.

Import

ts
import { transferBTC } from "@midl-xyz/midl-js-core";

Example

ts
const tx = await transferBTC(config, {
  transfers: [
    { receiver: "tb1q...", amount: 10000 },
    { receiver: "tb1q...", amount: 20000 },
  ],
  feeRate: 1,
  publish: true,
});

console.log(tx);

Parameters

NameTypeDescription
configConfigThe configuration object
paramsTransferBTCParamsThe parameters for the transfer

TransferBTCParams

NameTypeDescription
transfersobject[]An array of transfers
transfers.receiverstringThe receiver address
transfers.amountnumberThe amount in satoshis to transfer
feeRate?numberThe fee rate in satoshis per byte
publish?booleanIf true, the transaction will be broadcasted
from?stringThe address to transfer the BTC from

Returns

Promise<TransferBTCResponse>

The PSBT and transaction data

TransferBTCResponse

NameTypeDescription
psbtstringSigned Base64 encoded PSBT
txobjectThe transaction
tx.idstringThe transaction ID
tx.hexstringThe transaction hex