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 transactionsignTransaction- 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;
}| Field | Type | Description |
|---|---|---|
method | BtcBatchRequestMethod | The BTC method to invoke — "sendTransaction" or "signTransaction" |
params | BtcSendTransaction | BtcSignTransaction | Parameters 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
>;| Field | Type | Description |
|---|---|---|
txid | string | Transaction hash (from sendTransaction on successful broadcast) |
txraw | string | Raw transaction data (from sendTransaction when broadcastEnabled is false) |
sigs | string[] | Signature hex array (from signTransaction) |
error | string | Error 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()
Unknown
Use the wallet control in the top navigation before running this example.
Includes sample data for preview. Clear it to use your own transaction data.
Active Wallet NetworkUnknown
Controllable transactions in this run are signed without broadcasting.
Off by default, forcing controllable transaction requests to use broadcastEnabled: false. When enabled, each JSON item keeps its own setting.
Code Preview
const requests = [
{
"method": "sendTransaction",
"params": {
"toAddress": "1BitcoinEaterAddressDontSendf59kuE",
"amount": "100000",
"broadcastEnabled": false
}
},
{
"method": "signTransaction",
"params": {
"txHex": "020000000133333333333333333333333333333333333333333333333333333333333333330000000000ffffffff01a0860100000000001976a914444444444444444444444444444444444444444488ac00000000",
"type": "legacy",
"prevOutScriptsHex": [
"76a914555555555555555555555555555555555555555588ac"
]
}
}
];
const result = await Turing.btc.sendBatchRequest(requests);
console.log(result);