
btc (Standard Bitcoin RPC)
SANDSHREW hosts a fully hosted Bitcoin node, for each supported network, and passes through JSON-RPC requests that are either namespaced with the btc_
prefix, or otherwise have no namespace, directly to the Bitcoin core JSON-RPC which will be familiar to anyone who has developed against a Bitcoin node. The Bitcoin node hosted by SANDSHREW runs with the -txindex
flag set, so full indexing service is provided and data surfaced as-is.
The Bitcoin RPC is documented on the Bitcoin developer documentation, specifically here:
Descriptions of these JSON-RPC methods are reproduced below.
Bitcoin RPC
getblock
Returns block information.
curl https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_getblock",
"params": [
"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09",
1
]
}'
getbestblockhash
Returns the hash of the best (tip) block in the most-work fully-validated chain.
curl https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_getbestblockhash",
"params": []
}'
getblockchaininfo
Returns an object containing various state info regarding blockchain processing.
curl https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_getblockchaininfo",
"params": []
}'
getblockcount
Returns the height of the most-work fully-validated chain.
curl https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_getblockcount",
"params": []
}'
getblockhash
Returns hash of block in best-block-chain at height provided.
curl https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_getblockhash",
"params": [
819942
]
}'
getblockheader
If verbose is false, returns a string that is serialized, hex-encoded data for blockheader ‘hash’.
If verbose is true, returns an Object with information about blockheader ‘hash’.
curl https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_getblockheader",
"params": [
"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09",
true
]
}'
getblockstats
Returns block information.
curl https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_getblockstats",
"params": [
"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09",
[
"height",
"time"
]
]
}'
getchaintips
Return information about all known tips in the block tree, including the main chain as well as orphaned branches.
curl https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_getchaintips",
"params": []
}'
getchaintxstats
Compute statistics about the total number and rate of transactions in the chain
curl https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_getchaintxstats",
"params": [
2016
]
}'
getdifficulty
Returns the proof-of-work difficulty as a multiple of the minimum difficulty.
curl https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_getdifficulty",
"params": []
}'
getmempoolancestors
If txid is in the mempool, returns all in-mempool ancestors.
curl https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_getmempoolancestors",
"params": [
"fadd2d64a82f96bb2cd7743106e7a69933c97175c51a7f0cab10103c53e0a7a6",
true
]
}'
getmempooldescendants
If txid is in the mempool, returns all in-mempool descendants.
curl https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_getmempooldescendants",
"params": [
"f1e2075eb37a38e368569eed8a2354f5289cfa9e5042b65606460f803644d8b6",
true
]
}'
getmempoolentry
Returns mempool data for given transaction
curl https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_getmempoolentry",
"params": [
"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09"
]
}'
getmempoolinfo
Returns details on the active state of the TX memory pool.
curl https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_getmempoolinfo",
"params": []
}'
getrawmempool
Returns all transaction ids in memory pool as a json array of string transaction ids.
Hint: use getmempoolentry
to fetch a specific transaction from the mempool.
curl https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_getrawmempool",
"params": [
false
]
}'
gettxout
Returns details about an unspent transaction output.
curl https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_gettxout",
"params": [
"1b5ec8ffdf1e653532af0fbd6d47453684496e87b89ff87e9f8fdd7c439640bf",
1
]
}'
gettxoutproof
Returns a hex-encoded proof that “txid” was included in a block.
NOTE: By default this function only works sometimes. This is when there is an unspent output in the utxo for this transaction. To make it always work, you need to maintain a transaction index, using the -txindex command line option or specify the block in which the transaction is included manually (by blockhash).
curl https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_gettxoutproof",
"params": [
["1b5ec8ffdf1e653532af0fbd6d47453684496e87b89ff87e9f8fdd7c439640bf"]
]
}'
gettxoutsetinfo
Returns statistics about the unspent transaction output set.
Note this call may take some time.
curl https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_gettxoutsetinfo",
"params": []
}'
verifytxoutproof
Verifies that a proof points to a transaction in a block, returning the transaction it commits to and throwing an RPC error if the block is not in our best chain
curl https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_verifytxoutproof",
"params": [
"0040cc2498ac05b7d7af45e1ca32bc01ba0e2ac9a7445131b0fc03000000000000000000d7641e92f0b3e503ae6fbbefe8e965d93cd416df8f1db933be4b71cfb4c046fa71cd6f65502404170baa99b67a0a00000d057ff517528695fed2025deaf2c9f8816a5c009e46a9c9a1ec94a79eb4fcbe04e19b92d64607a82b10a017d36b9b3dd6a86dc942def84e159e7c832ec84ac414ef07a158a76e7b8c24b75029d548d8f2f109267611c139b9140801caf9cbd6b848c1b65b294687c90c094a21c5aa64e1a512319551d61c064bf73e0250c44e55e7778b7fb27f6a4689d9203bc3b22bd0df3b599cd299277771ff8b6f811b5bbb243ab61c1ba7bedc4cfb3104066300deb81b68d960e63e02520368da7b1c3d1c43ce73991525557ee80f0bf1b5fd9924dd8fc1dd738257dc6f97f886871f5a3ca8138bd270042ac50fa0c98f1c9900d26bf90a5172442fcd9138784107050ab10f66ef59bc9ecd907d6ade9bf5f863ba8f730c6da8cff199d5052466711fee4e24e0a1dfa9526b5c71eb42cb622d71edccba148e6eae784eae2dd7782547037d20edeaaa87de02e4e290e9b5becd2a58ebd4d75d83f554cf268c8527da9c312a479260ae7b26092425082464dbc56045f4478c074a84c1466d8eed65be420317e737753cb4433f2efaf2a75c450fdd49502d2a2fea07f4477ec7b295c38638c304db5a1500"
]
}'
Rawtransactions RPCs
analyzepsbt
btc_analyzepsbt
analyzes and provides information about the current status of a PSBT and its inputs.
curl https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_analyzepsbt",
"params": [
"cHNidP8BAP0GAQIAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAA/////ww/Ybqlrf3R1mw1IuhEE/cL65NEjkYLabSBnsR2PuGpAAAAAAD/////AwAAAAAAAAAAIlEgoFjEyXO/4q/9a4OxcayNLtomxD4gYFOv5G3U3ehS0gEAAAAAAAAAACJRIKBYxMlzv+Kv/WuDsXGsjS7aJsQ+IGBTr+Rt1N3oUtIBOEoAAAAAAAAiUSA8VRzAxPUE8z+1r+BbHKjNeygAdv4hvCa0mvUKxkPaogAAAAAAAQErAAAAAAAAAAAiUSA8VRzAxPUE8z+1r+BbHKjNeygAdv4hvCa0mvUKxkPaogETQNpOi9nxzWlptSf4lamevUQFikJDYJuaS43lnWrUsPNB+5MNSyIWh+vkCYVz3KYOY1rEHDdGU+0Yi7/Ow7NBNiIBFyC9T1+kiOs3SQRQNZIFqube66U86xDCOMUP4aoy7jzmhgABASsAAAAAAAAAACJRIDxVHMDE9QTzP7Wv4FscqM17KAB2/iG8JrSa9QrGQ9qiARNAzBZ3R61BaOAoXq6jJg3nsDnwLjnqN6RKQjXCTDU/vUJ9hASFp9/iL+STGFNpM2PvMBmRWEYfPHlR+jb8tdoCwQEXIL1PX6SI6zdJBFA1kgWq5t7rpTzrEMI4xQ/hqjLuPOaGAAEBKyICAAAAAAAAIlEgPFUcwMT1BPM/ta/gWxyozXsoAHb+IbwmtJr1CsZD2qIBAwSDAAAAARNBi/O44iCmOLCTqXMcPJ6oamcxzVB8SDz25n8E5Pzc9LsjVEhfbL32r+/MBYtCouxLecbYXHeiQDQVtr4VwI8T0oMBFyC9T1+kiOs3SQRQNZIFqube66U86xDCOMUP4aoy7jzmhgAAAAA="
]
}'
combinepsbt
btc_combinepsbt
combines multiple partially signed PSBTs into a single PSBT. It takes partially signed transactions from various sources and consolidates them. This is important in multi-signature or complex transaction processes where each party contributes part of the transaction's data or signatures.
curl https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_combinepsbt",
"params": [
[
"cHNidP8BAP0GAQIAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAA/////ww/Ybqlrf3R1mw1IuhEE/cL65NEjkYLabSBnsR2PuGpAAAAAAD/////AwAAAAAAAAAAIlEgoFjEyXO/4q/9a4OxcayNLtomxD4gYFOv5G3U3ehS0gEAAAAAAAAAACJRIKBYxMlzv+Kv/WuDsXGsjS7aJsQ+IGBTr+Rt1N3oUtIBOEoAAAAAAAAiUSA8VRzAxPUE8z+1r+BbHKjNeygAdv4hvCa0mvUKxkPaogAAAAAAAQErAAAAAAAAAAAiUSA8VRzAxPUE8z+1r+BbHKjNeygAdv4hvCa0mvUKxkPaogETQNpOi9nxzWlptSf4lamevUQFikJDYJuaS43lnWrUsPNB+5MNSyIWh+vkCYVz3KYOY1rEHDdGU+0Yi7/Ow7NBNiIBFyC9T1+kiOs3SQRQNZIFqube66U86xDCOMUP4aoy7jzmhgABASsAAAAAAAAAACJRIDxVHMDE9QTzP7Wv4FscqM17KAB2/iG8JrSa9QrGQ9qiARNAzBZ3R61BaOAoXq6jJg3nsDnwLjnqN6RKQjXCTDU/vUJ9hASFp9/iL+STGFNpM2PvMBmRWEYfPHlR+jb8tdoCwQEXIL1PX6SI6zdJBFA1kgWq5t7rpTzrEMI4xQ/hqjLuPOaGAAEBKyICAAAAAAAAIlEgPFUcwMT1BPM/ta/gWxyozXsoAHb+IbwmtJr1CsZD2qIBAwSDAAAAARNBi/O44iCmOLCTqXMcPJ6oamcxzVB8SDz25n8E5Pzc9LsjVEhfbL32r+/MBYtCouxLecbYXHeiQDQVtr4VwI8T0oMBFyC9T1+kiOs3SQRQNZIFqube66U86xDCOMUP4aoy7jzmhgAAAAA=",
"cHNidP8BAP0GAQIAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAA/////ww/Ybqlrf3R1mw1IuhEE/cL65NEjkYLabSBnsR2PuGpAAAAAAD/////AwAAAAAAAAAAIlEgoFjEyXO/4q/9a4OxcayNLtomxD4gYFOv5G3U3ehS0gEAAAAAAAAAACJRIKBYxMlzv+Kv/WuDsXGsjS7aJsQ+IGBTr+Rt1N3oUtIBOEoAAAAAAAAiUSA8VRzAxPUE8z+1r+BbHKjNeygAdv4hvCa0mvUKxkPaogAAAAAAAQErAAAAAAAAAAAiUSA8VRzAxPUE8z+1r+BbHKjNeygAdv4hvCa0mvUKxkPaogETQNpOi9nxzWlptSf4lamevUQFikJDYJuaS43lnWrUsPNB+5MNSyIWh+vkCYVz3KYOY1rEHDdGU+0Yi7/Ow7NBNiIBFyC9T1+kiOs3SQRQNZIFqube66U86xDCOMUP4aoy7jzmhgABASsAAAAAAAAAACJRIDxVHMDE9QTzP7Wv4FscqM17KAB2/iG8JrSa9QrGQ9qiARNAzBZ3R61BaOAoXq6jJg3nsDnwLjnqN6RKQjXCTDU/vUJ9hASFp9/iL+STGFNpM2PvMBmRWEYfPHlR+jb8tdoCwQEXIL1PX6SI6zdJBFA1kgWq5t7rpTzrEMI4xQ/hqjLuPOaGAAEBKyICAAAAAAAAIlEgPFUcwMT1BPM/ta/gWxyozXsoAHb+IbwmtJr1CsZD2qIBAwSDAAAAARNBi/O44iCmOLCTqXMcPJ6oamcxzVB8SDz25n8E5Pzc9LsjVEhfbL32r+/MBYtCouxLecbYXHeiQDQVtr4VwI8T0oMBFyC9T1+kiOs3SQRQNZIFqube66U86xDCOMUP4aoy7jzmhgAAAAA="
]
]
}'
combinerawtransaction
btc_combinerawtransaction
combines multiple partially signed raw transactions, in hexidecimal format, into one transaction. The combined transaction may be another partially signed transaction or a fully signed transaction. Each input transaction must have the same output structure to be successfully combined.
Useful for multi-signature transactions where each party signs the transaction separately. btc_combinerawtransaction
collects these partial signatures and combines them into one transaction.
curl https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_combinerawtransaction",
"params": [
[
"<txs>",
]
]
}'
converttopsbt
btc_converttopsbt
converts a standard Bitcoin raw transaction into a PSBT. This functionality is particularly useful when starting with a non-PSBT transaction format and needing to transition to a PSBT for multi-signature or advanced signing workflows. The conversion process ensures that the resulting PSBT remains unsigned, making it suitable for passing around to various parties for signatures.
curl https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_converttopsbt",
"params": [
"<raw_txn>",
true
]
}'
createpsbt
btc_createpsbt
creates a PSBT. It can be used for creating transactions that require multiple signatures or specific signing arrangements.
curl https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_createpsbt",
"params": [
"640e8ee134ecf886a874bbfd555b9e5beaf70cdc93ffe52cc10f009c8ee1cc59",
true
]
}'
createrawtransaction
btc_createrawtransaction
creates a new, raw, and unsigned Bitcoin transaction.
curl https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_createrawtransaction",
"params": [
[
"<inputs>"
],
"<outputs>"
]
}'
decodepsbt
btc_decodepsbt
decodes a base64-encoded PSBT into a structured, readable format. The decoded output provides comprehensive information about the PSBT, including its inputs, outputs, any signatures it contains, and additional metadata.
curl https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_decodepsbt",
"params": [
"<psbt>"
]
}'
decoderawtransaction
btc_decoderawtransaction
decodes a serialized, hex-encoded transaction into a human-readable format.
curl https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_decoderawtransaction",
"params": [
"<hexstring>",
false
]
}'
decodescript
btc_decodescript
is used to decode a hex-encoded script and provide human-readable details about it. The decoded information includes details such as the type of script (e.g., P2PKH
, P2SH
), required signatures, and any embedded addresses.
curl https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_decodescript",
"params": [
"52205af0d72e5a051ba2b5615136ee598dcae09aaf7f2dfbd51170ac18d7aae917968e8585e86048f2824278afa7abaa0527bc46314533d57a09c62216da38a5"
]
}'
finalizepsbt
btc_finalizepsbt
is used to finalize a Partially Signed Bitcoin Transaction (PSBT). This process involves completing the signing of the transaction and converting it into a fully signed transaction that is ready to be broadcast to the Bitcoin network.
Here's a breakdown of its functionality:
Completing Signatures: The primary function of
btc_finalizepsbt
is to complete the signing of all inputs in the PSBT. It checks if all necessary signatures are present and valid for each input.Constructing the Final Transaction: Once all inputs are fully signed,
btc_finalizepsbt
constructs a final, standard Bitcoin transaction from the PSBT. This transaction is in a standard serialized transaction format, which is recognized and can be processed by the Bitcoin network.Ensuring Transaction Validity: The API call also checks that the transaction is valid. This includes ensuring that all inputs are correctly signed and that the transaction conforms to Bitcoin's transaction rules.
Extracting the Transaction: If the PSBT is fully signed,
btc_finalizepsbt
extracts and returns the fully signed transaction in a hexadecimal string format. This string can then be directly submitted to the Bitcoin network for confirmation and inclusion in a block.Use in Multi-Party Transactions:
btc_finalizepsbt
is particularly useful in multi-party transaction scenarios where a PSBT has been passed around multiple parties for signing. It provides a simple and secure way to finalize the transaction once all parties have provided their signatures.
curl https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_finalizepsbt",
"params": [
"<psbt>",
true
]
}'
getrawtransaction
btc_getrawtransaction
retrieves detailed information about a specific transaction in the Bitcoin network. It's particularly useful for examining the details of transactions that are either in the mempool or already included in a block.
By default this function only works for mempool transactions. When called with a blockhash
argument, btc_getrawtransaction
will return the transaction if the specified block is available and the transaction is found in that block.
curl https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_getrawtransaction",
"params": [
"9d92bea825ec5736f7cb0bb8b952b6bb0b7dc6f13f300245b2aece25acb31ef8",
false
]
}'
joinpsbts
btc_joinpsbts
is used for joining multiple Partially Signed Bitcoin Transactions (PSBTs) into a single PSBT. PSBT is a standard format for Bitcoin transactions that are not fully signed, allowing for transactions to be passed around multiple parties for signing without revealing the private keys.
Functionality of btc_joinpsbts
includes:
Combining Transactions: It takes multiple PSBTs as input and combines them into one. This is particularly useful in scenarios where different parties have created separate PSBTs for different inputs or outputs, and these need to be consolidated into a single transaction.
Facilitating Multi-Party Transactions: In situations where a transaction requires inputs or consents from multiple parties, each party can create their own PSBT.
btc_joinpsbts
then merges these into a single PSBT that encompasses all the inputs, outputs, and signatures provided by the individual parties.Streamlining the Signing Process: Once the PSBTs are joined, the resulting single PSBT can be passed to each relevant party for signing. This streamlines the process, as each party can sign the same transaction instead of having to deal with multiple transactions.
Use in Complex Transaction Scenarios: This call is particularly useful in complex transaction scenarios like multi-signature transactions, CoinJoin transactions, or batch processing of transactions.
curl https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_joinpsbts",
"params": [
[
"<psbt>",
"<psbt>"
]
]
}'
sendrawtransaction
Submit a raw transaction (serialized, hex-encoded) to local node and network.
Note that the transaction will be sent unconditionally to all peers, so using this for manual rebroadcast may degrade privacy by leaking the transaction’s origin, as nodes will normally not rebroadcast non-wallet transactions already in their mempool.
Also see createrawtransaction and signrawtransactionwithkey calls.
curl -XPOST https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_sendrawtransaction",
"params": [
"<raw_tx>",
]
}'
testmempoolaccept
btc_testmempoolaccept
is used to test how a transaction would be received by the mempool without actually broadcasting it to the network. Here's an overview of its functionality:
Transaction Validation: It validates a raw transaction to check whether it would be accepted into the mempool. This validation includes various checks like transaction syntax, structure, and whether it meets the network's consensus rules.
Fee and Size Checks: The call assesses whether the transaction fees are adequate and if the transaction size is within acceptable limits.
Double-Spend Checks: It verifies that the transaction doesn't attempt to double-spend any UTXOs (Unspent Transaction Outputs).
Chain State Consideration: The API call considers the current state of the blockchain and the mempool to evaluate if the transaction would be accepted at that particular moment.
No Actual Broadcast: Importantly,
btc_testmempoolaccept
does not broadcast the transaction to the network. It's a purely local test to see if the transaction would be accepted by the mempool under current conditions.Response Data: It returns information on whether the transaction would be accepted and, if not, provides details about why it would be rejected.
Note that the transaction will be sent unconditionally to all peers, so using this for manual rebroadcast may degrade privacy by leaking the transaction’s origin, as nodes will normalin getgly not rebroadcast non-wallet transactions already in their mempool.
curl -XPOST https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_testmempoolaccept",
"params": [
[
"<raw_txs>",
"0.10"
]
]
}'
utxoupdatepsbt
btc_utxoupdatepsbt
updates a PSBT with information about the UTXOs it spends. This is particularly useful in scenarios where a PSBT lacks certain details about the UTXOs, which are necessary for signing and finalizing the transaction.
curl -XPOST https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_utxoupdatepsbt",
"params": [
"<psbt>"
]
}'
Util RPCs
createmultisig
btc_createmultisig
creates a multi-signature address. Multi-signature addresses require more than one private key to authorize a transaction, enhancing the security of Bitcoin transactions
curl -XPOST https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_createmultisig",
"params": [
"2",
[
"<pubkey>",
"<pubkey>"
]
]
}'
deriveaddresses
btc_deriveaddresses
derives one or more addresses from an output descriptor. Output descriptors provide a human-readable way to describe Bitcoin addresses, including information about how to spend coins sent to these addresses.
curl -XPOST https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_deriveaddresses",
"params": [
"<descriptor>"
]
}'
estimatesmartfee
btc_estimatesmartfee
estimates the transaction fee per kilobyte that should be included with a transaction in order to have it confirmed within a certain number of blocks. This estimation is based on the current state of the mempool and recent blocks.
curl -XPOST https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_estimatesmartfee",
"params": [
"6",
"ECONOMICAL"
]
}'
getdescriptorinfo
btc_getdescriptorinfo
provides information about a descriptor. A descriptor is a more expressive way to describe Bitcoin script types for wallets, including information on how to spend outputs sent to these addresses. The call calculates and returns a checksum for the descriptor, which is used to verify its integrity.
curl -XPOST https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_getdescriptorinfo",
"params": [
"<descriptor>"
]
}'
getindexinfo
btc_getindexinfo
obtains information about the state of the blockchain indexes. These indexes are additional structures maintained by the node, which provide faster access to certain types of data, like transaction data or block information.
curl -XPOST https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_getindexinfo",
"params": [ ]
}'
validateaddress
btc_validateaddress
validates and provides detailed information about a Bitcoin address. If the address is valid, it provides detailed information about it, including the address type, whether it belongs to the wallet, and its associated public key (if available). For script addresses, it provides information about the script.
curl -XPOST https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_validateaddress",
"params": [
"<address>"
]
}'
verifymessage
btc_verifymessage
verifies a signed message. This function is used in scenarios where you need to prove ownership of a Bitcoin address or validate the authenticity of a message signed with a Bitcoin private key.
curl -XPOST https://mainnet.sandshrew.io/v1/<developer key> \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "btc_verifymessage",
"params": [
"<address>",
"<signature>",
"<message>"
]
}'
Last updated