Skip to content

btc.sendBatchRequest ​

Batch submit BTC-related requests via the btc object. Each request is executed independently; one failure does not affect others.

Supported Methods ​

  • sendTransaction - Send transaction
  • signTransaction - Sign transaction

Usage ​

ts
const requests = [
  {
    method: "sendTransaction",
    params: {
      toAddress: "bc1qxyz...",
      amount: "100000",
      broadcastEnabled: true,
    },
  },
  {
    method: "signTransaction",
    params: {
      txHex: "0200000001...",
      type: "legacy",
      prevOutScriptsHex: ["76a914...88ac"],
    },
  },
];

const results = await Turing.btc.sendBatchRequest(requests);

Parameters ​

ts
type BtcBatchRequestMethod = "sendTransaction" | "signTransaction";

interface BtcBatchRequest {
  method: BtcBatchRequestMethod;
  params: BtcSendTransaction | BtcSignTransaction;
}
FieldTypeDescription
methodBtcBatchRequestMethodThe BTC method to invoke — "sendTransaction" or "signTransaction"
paramsBtcSendTransaction | BtcSignTransactionParameters for the specified method

Returns ​

Returns an array of results, each corresponding to a request at the same index.

ts
type BtcBatchResponse = Array<
  BtcSendTransactionResponse | BtcSignTransactionResponse
>;
FieldTypeDescription
txidstringTransaction hash (from sendTransaction on successful broadcast)
txrawstringRaw transaction data (from sendTransaction when broadcastEnabled is false)
sigsstring[]Signature hex array (from signTransaction)
errorstringError message if the request fails

Error Handling ​

ts
const results = await Turing.btc.sendBatchRequest(requests);

results.forEach((result, index) => {
  if (result.error) {
    console.error(`Request ${index + 1} failed:`, result.error);
  } else {
    console.log(`Request ${index + 1} success:`, result);
  }
});

Live Example ​

The playground disables batch broadcasting by default and forces sendTransaction requests to use broadcastEnabled: false. Each item follows its JSON setting only after the master gate is enabled.

Live Example

Turing.btc.sendBatchRequest()

Detecting Wallet...

Includes sample data for preview. Clear it to use your own transaction data.

Active Wallet NetworkUnknown

The active wallet network is Unknown. This method requires BTC. Switch networks and try again.

Off by default, forcing controllable transaction requests to use broadcastEnabled: false. When enabled, each JSON item keeps its own setting.

Detecting Wallet...
Code Preview