Node API
Supported Chains
API Reference
Bitcoin

Bitcoin

Bitcoin API is available on Web3 API platform (opens in a new tab).

Bitcoin API provides the means for communication with the Bitcoin’s public ledger.

In order for your Web3 application to interact with Bitcoin — either by reading blockchain data or sending transactions to the network — it must connect to a Bitcoin node. Developers interact with the blockchain using the methods provided by the API.

The API interaction follows the JSON-RPC (opens in a new tab) which is a stateless, light-weight remote procedure call (RPC) protocol. It defines several data structures and the rules around their processing. It is transport agnostic in that the concepts can be used within the same process, over sockets, over HTTP, or in other message-passing environments. It uses JSON (RFC 4627) as data format.


Methods supported


Blockchain RPCs:

  • getbestblockhash — returns the hash of the best (tip) block in the most-work fully-validated chain.
  • getblock — retrieves info about a specific block given its block hash.
  • getblockchaininfo — returns an object containing various state info regarding blockchain processing.
  • getblockcount — returns the height of the most-work fully-validated chain.
  • getblockfilter — retrieves a BIP 157 content filter for a particular block.
  • getblockhash — returns hash of block in best-block-chain at height provided.
  • getblockheader — retrieves information about a specific block header.
  • getblockstats — computes per block statistics for a given window.
  • getchaintips — returns information about all known tips in the block tree.
  • getchaintxstats — computes statistics about the total number and rate of transactions in the chain.
  • getdifficulty — returns the proof-of-work difficulty as a multiple of the minimum difficulty.
  • getmempoolancestors — if txid is in the mempool, returns all in-mempool ancestors.
  • getmempooldescendants — if txid is in the mempool, returns all in-mempool descendants.
  • getmempoolentry — returns mempool data for given transaction.
  • getmempoolinfo — returns details on the active state of the TX memory pool.
  • getrawmempool — returns all transaction ids in memory pool as a json array of string transaction ids.
  • gettxout — returns details about an unspent transaction output.
  • gettxoutproof — returns a hex-encoded proof that “txid” was included in a block.
  • verifytxoutproof — verifies that a proof points to a transaction in a block.

Raw transactions RPCs:

  • analyzepsbt — analyzes and provides information about the current status of a PSBT and its inputs.
  • combinepsbt — combines multiple partially signed Bitcoin transactions into one transaction.
  • combinerawtransaction — combines multiple partially signed transactions into one transaction.
  • converttopsbt — converts a network serialized transaction to a PSBT.
  • createpsbt – creates a transaction in the Partially Signed Transaction format.
  • createrawtransaction — creates a transaction spending the given inputs and creating new outputs.
  • decodepsbt – returns a JSON object representing the serialized, base64-encoded partially signed Bitcoin transaction.
  • decoderawtransaction — returns a JSON object representing the serialized, hex-encoded transaction.
  • decodescript — decodes a hex-encoded script.
  • finalizepsbt — finalizes the inputs of a PSBT.
  • getrawtransaction — returns the raw transaction data.
  • joinpsbts — joins multiple distinct PSBTs with different inputs and outputs into one PSBT.
  • sendrawtransaction — submits a raw transaction (serialized, hex-encoded) to local node and network.
  • testmempoolaccept — returns result of mempool acceptance tests.
  • utxoupdatepsbt — updates all segwit inputs and outputs in a PSBT with data from output descriptors, the UTXO set, or the mempool.

Util RPCs:

Wallet RPCs:

The wallet RPCs are only available if Bitcoin Core was built with wallet support, which is the default.

  • getaddressinfo — returns information about the given Bitcoin address.

Blockchain RPCs

getbestblockhash

Returns the hash of the best (tip) block in the most-work fully-validated chain.

getbestblockhash

Parameters


  • id (string; required): a request ID (example: test).
  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).
  • method (string; required): a method used for the request.
  • params (array; required): none.

Returns

The block hash, hex-encoded.

Request example

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "getbestblockhash",
      "params": []
}'

Response example

{
    "result": "00000000000000000001e4696901be3535c9f1cb3f3111caa57e809666021f46",
    "error": null,
    "id": "test"
}

getblock

Retrieves info about a specific block given its block hash.

If verbosity is 0, returns a string that is serialized, hex-encoded data for block ‘hash’.
If verbosity is 1, returns an Object with information about block ‘hash’.
If verbosity is 2, returns an Object with information about block ‘hash’ and information about each transaction.

getblock "blockhash" ( verbosity )

Parameters


  • id (string; required): a request ID (example: test).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • <blockhash> (string; required): the block hash.
    • <verbosity> (numeric; optional; default=1): 0 for hex-encoded data, 1 for a json object, and 2 for json object with transaction data.

Returns

Verbosity=0:

A string that is serialized, hex-encoded data for the block hash.

Verbosity=1:

{                                 (json object)
  "hash" : "hex",                 (string) the block hash (same as provided)
  "confirmations" : n,            (numeric) The number of confirmations, or -1 if the block is not on the main chain
  "size" : n,                     (numeric) The block size
  "strippedsize" : n,             (numeric) The block size excluding witness data
  "weight" : n,                   (numeric) The block weight as defined in BIP 141
  "height" : n,                   (numeric) The block height or index
  "version" : n,                  (numeric) The block version
  "versionHex" : "hex",           (string) The block version formatted in hexadecimal
  "merkleroot" : "hex",           (string) The merkle root
  "tx" : [                        (json array) The transaction ids
    "hex",                        (string) The transaction id
    ...
  ],
  "time" : xxx,                   (numeric) The block time expressed in UNIX epoch time
  "mediantime" : xxx,             (numeric) The median block time expressed in UNIX epoch time
  "nonce" : n,                    (numeric) The nonce
  "bits" : "hex",                 (string) The bits
  "difficulty" : n,               (numeric) The difficulty
  "chainwork" : "hex",            (string) Expected number of hashes required to produce the chain up to this block (in hex)
  "nTx" : n,                      (numeric) The number of transactions in the block
  "previousblockhash" : "hex",    (string) The hash of the previous block
  "nextblockhash" : "hex"         (string) The hash of the next block
}
 

Verbosity=2:

{             (json object)
  ...,        Same output as verbosity = 1
  "tx" : [    (json array)
    {         (json object)
      ...     The transactions in the format of the getrawtransaction RPC. Different from verbosity = 1 "tx" result
    },
    ...
  ]
}

Request example

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "getblock",
      "params": ["00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09"]
}'

Response example

{
    "result": {
        "hash": "00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09",
        "confirmations": 842553,
        "height": 1000,
        "version": 1,
        "versionHex": "00000001",
        "merkleroot": "fe28050b93faea61fa88c4c630f0e1f0a1c24d0082dd0e10d369e13212128f33",
        "time": 1232346882,
        "mediantime": 1232344831,
        "nonce": 2595206198,
        "bits": "1d00ffff",
        "difficulty": 1,
        "chainwork": "000000000000000000000000000000000000000000000000000003e903e903e9",
        "nTx": 1,
        "previousblockhash": "0000000008e647742775a230787d66fdf92c46a48c896bfbc85cdc8acc67e87d",
        "nextblockhash": "00000000a2887344f8db859e372e7e4bc26b23b9de340f725afbf2edb265b4c6",
        "strippedsize": 216,
        "size": 216,
        "weight": 864,
        "tx": [
            "fe28050b93faea61fa88c4c630f0e1f0a1c24d0082dd0e10d369e13212128f33"
        ]
    },
    "error": null,
    "id": "test"
}

getblockchaininfo

Returns an object containing various state info regarding blockchain processing.

getblockchaininfo

Parameters


  • id (string; required): a request ID (example: test).
  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).
  • method (string; required): a method used for the request.
  • params (array; required): none.

Returns

{                                         (json object)
  "chain" : "str",                        (string) current network name (main, test, regtest)
  "blocks" : n,                           (numeric) the height of the most-work fully-validated chain. The genesis block has height 0
  "headers" : n,                          (numeric) the current number of headers we have validated
  "bestblockhash" : "str",                (string) the hash of the currently best block
  "difficulty" : n,                       (numeric) the current difficulty
  "mediantime" : n,                       (numeric) median time for the current best block
  "verificationprogress" : n,             (numeric) estimate of verification progress [0..1]
  "initialblockdownload" : true|false,    (boolean) (debug information) estimate of whether this node is in Initial Block Download mode
  "chainwork" : "hex",                    (string) total amount of work in active chain, in hexadecimal
  "size_on_disk" : n,                     (numeric) the estimated size of the block and undo files on disk
  "pruned" : true|false,                  (boolean) if the blocks are subject to pruning
  "pruneheight" : n,                      (numeric) lowest-height complete block stored (only present if pruning is enabled)
  "automatic_pruning" : true|false,       (boolean) whether automatic pruning is enabled (only present if pruning is enabled)
  "prune_target_size" : n,                (numeric) the target size used by pruning (only present if automatic pruning is enabled)
  "softforks" : {                         (json object) status of softforks
    "xxxx" : {                            (json object) name of the softfork
      "type" : "str",                     (string) one of "buried", "bip9"
      "bip9" : {                          (json object) status of bip9 softforks (only for "bip9" type)
        "status" : "str",                 (string) one of "defined", "started", "locked_in", "active", "failed"
        "bit" : n,                        (numeric) the bit (0-28) in the block version field used to signal this softfork (only for "started" status)
        "start_time" : xxx,               (numeric) the minimum median time past of a block at which the bit gains its meaning
        "timeout" : xxx,                  (numeric) the median time past of a block at which the deployment is considered failed if not yet locked in
        "since" : n,                      (numeric) height of the first block to which the status applies
        "statistics" : {                  (json object) numeric statistics about BIP9 signalling for a softfork (only for "started" status)
          "period" : n,                   (numeric) the length in blocks of the BIP9 signalling period
          "threshold" : n,                (numeric) the number of blocks with the version bit set required to activate the feature
          "elapsed" : n,                  (numeric) the number of blocks elapsed since the beginning of the current period
          "count" : n,                    (numeric) the number of blocks with the version bit set in the current period
          "possible" : true|false         (boolean) returns false if there are not enough blocks left in this period to pass activation threshold
        }
      },
      "height" : n,                       (numeric) height of the first block which the rules are or will be enforced (only for "buried" type, or "bip9" type with "active" status)
      "active" : true|false               (boolean) true if the rules are enforced for the mempool and the next block
    },
    ...
  },
  "warnings" : "str"                      (string) any network and blockchain warnings
}

Request example

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "getblockchaininfo",
      "params": []
}'

Response example

{
    "result": {
        "chain": "main",
        "blocks": 843552,
        "headers": 843552,
        "bestblockhash": "00000000000000000000961750bb966af043f98ac0cc9a00c433ccc455204bac",
        "difficulty": 83148355189239.77,
        "time": 1715765116,
        "mediantime": 1715761540,
        "verificationprogress": 0.999989001722265,
        "initialblockdownload": false,
        "chainwork": "000000000000000000000000000000000000000079805bf222b2b5d07d76e90c",
        "size_on_disk": 649426145409,
        "pruned": false,
        "warnings": ""
    },
    "error": null,
    "id": "test"
}

getblockcount

Returns the height of the most-work fully-validated chain.

The genesis block has height 0.

getblockcount

Parameters


  • id (string; required): a request ID (example: test).
  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).
  • method (string; required): a method used for the request.
  • params (array; required): none.

Returns

The current block count.

Request example

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "getblockcount",
      "params": []
}'

Response example

{
    "result": 843552,
    "error": null,
    "id": "test"
}

getblockfilter

Retrieves a BIP 157 content filter for a particular block.

getblockfilter "blockhash" ( "filtertype" )

Parameters


  • id (string; required): a request ID (example: test).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • <blockhash> (string; required): the hash of the block.
    • <filtertype> (string; optional; default=basic): the type name of the filter.

Returns

{                      (json object)
  "filter" : "hex",    (string) the hex-encoded filter data
  "header" : "hex"     (string) the hex-encoded filter header
}

Request example

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "getblockfilter",
      "params": ["00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09", "basic"]
}'

Response example

{
    "result": {
        "filter": "0163cb10",
        "header": "4a242283a406a7c089f671bb8df7671e5d5e9ba577cea1047d30a7f4919df193"
    },
    "error": null,
    "id": "test"
}

getblockhash

Returns hash of block in best-block-chain at height provided.

getblockhash height

Parameters


  • id (string; required): a request ID (example: test).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • <height> (numeric; required): the height index.

Returns

The hash of the block.

Request example

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "getblockhash",
      "params": [1000]
}'

Response example

{
    "result": "00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09",
    "error": null,
    "id": "test"
}

getblockheader

Retrieves information about a specific block header

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.

getblockheader "blockhash" ( verbose )

Parameters


  • id (string; required): a request ID (example: test).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • <blockhash> (string; required): the block hash.
    • <verbose> (boolean; optional; default=true): true for a json object, false for the hex-encoded data.

Returns

Verbose=true:

{                                 (json object)
  "hash" : "hex",                 (string) the block hash (same as provided)
  "confirmations" : n,            (numeric) The number of confirmations, or -1 if the block is not on the main chain
  "height" : n,                   (numeric) The block height or index
  "version" : n,                  (numeric) The block version
  "versionHex" : "hex",           (string) The block version formatted in hexadecimal
  "merkleroot" : "hex",           (string) The merkle root
  "time" : xxx,                   (numeric) The block time expressed in UNIX epoch time
  "mediantime" : xxx,             (numeric) The median block time expressed in UNIX epoch time
  "nonce" : n,                    (numeric) The nonce
  "bits" : "hex",                 (string) The bits
  "difficulty" : n,               (numeric) The difficulty
  "chainwork" : "hex",            (string) Expected number of hashes required to produce the current chain
  "nTx" : n,                      (numeric) The number of transactions in the block
  "previousblockhash" : "hex",    (string) The hash of the previous block
  "nextblockhash" : "hex"         (string) The hash of the next block
}

Verbose=false:

A string that is serialized, hex-encoded data for block hash.

Request example

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "getblockheader",
      "params": ["00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09"]
}'

Response example

{
    "result": {
        "hash": "00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09",
        "confirmations": 842554,
        "height": 1000,
        "version": 1,
        "versionHex": "00000001",
        "merkleroot": "fe28050b93faea61fa88c4c630f0e1f0a1c24d0082dd0e10d369e13212128f33",
        "time": 1232346882,
        "mediantime": 1232344831,
        "nonce": 2595206198,
        "bits": "1d00ffff",
        "difficulty": 1,
        "chainwork": "000000000000000000000000000000000000000000000000000003e903e903e9",
        "nTx": 1,
        "previousblockhash": "0000000008e647742775a230787d66fdf92c46a48c896bfbc85cdc8acc67e87d",
        "nextblockhash": "00000000a2887344f8db859e372e7e4bc26b23b9de340f725afbf2edb265b4c6"
    },
    "error": null,
    "id": "test"
}

getblockstats

Computes per block statistics for a given window.

All amounts are in satoshis. It won’t work for some heights with pruning.

getblockstats hash_or_height ( stats )

Parameters


  • id (string; required): a request ID (example: test).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • <hash_or_height> (string/numeric; required): the block hash or height of the target block.

    • <stats> (json array; optional; default=all values):

      [
        "height",     (string) Selected statistic
        "time",       (string) Selected statistic
        ...
      ]

Returns

{                              (json object)
  "avgfee" : n,                (numeric) Average fee in the block
  "avgfeerate" : n,            (numeric) Average feerate (in satoshis per virtual byte)
  "avgtxsize" : n,             (numeric) Average transaction size
  "blockhash" : "hex",         (string) The block hash (to check for potential reorgs)
  "feerate_percentiles" : [    (json array) Feerates at the 10th, 25th, 50th, 75th, and 90th percentile weight unit (in satoshis per virtual byte)
    n,                         (numeric) The 10th percentile feerate
    n,                         (numeric) The 25th percentile feerate
    n,                         (numeric) The 50th percentile feerate
    n,                         (numeric) The 75th percentile feerate
    n                          (numeric) The 90th percentile feerate
  ],
  "height" : n,                (numeric) The height of the block
  "ins" : n,                   (numeric) The number of inputs (excluding coinbase)
  "maxfee" : n,                (numeric) Maximum fee in the block
  "maxfeerate" : n,            (numeric) Maximum feerate (in satoshis per virtual byte)
  "maxtxsize" : n,             (numeric) Maximum transaction size
  "medianfee" : n,             (numeric) Truncated median fee in the block
  "mediantime" : n,            (numeric) The block median time past
  "mediantxsize" : n,          (numeric) Truncated median transaction size
  "minfee" : n,                (numeric) Minimum fee in the block
  "minfeerate" : n,            (numeric) Minimum feerate (in satoshis per virtual byte)
  "mintxsize" : n,             (numeric) Minimum transaction size
  "outs" : n,                  (numeric) The number of outputs
  "subsidy" : n,               (numeric) The block subsidy
  "swtotal_size" : n,          (numeric) Total size of all segwit transactions
  "swtotal_weight" : n,        (numeric) Total weight of all segwit transactions
  "swtxs" : n,                 (numeric) The number of segwit transactions
  "time" : n,                  (numeric) The block time
  "total_out" : n,             (numeric) Total amount in all outputs (excluding coinbase and thus reward [ie subsidy + totalfee])
  "total_size" : n,            (numeric) Total size of all non-coinbase transactions
  "total_weight" : n,          (numeric) Total weight of all non-coinbase transactions
  "totalfee" : n,              (numeric) The fee total
  "txs" : n,                   (numeric) The number of transactions (including coinbase)
  "utxo_increase" : n,         (numeric) The increase/decrease in the number of unspent outputs
  "utxo_size_inc" : n          (numeric) The increase/decrease in size for the utxo index (not discounting op_return and similar)
}

Request example

Block hash param:

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "getblockstats",
      "params": ["00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09", ["minfeerate","avgfeerate"]]
}'

Block height param:

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "getblockstats",
      "params": [1000, ["minfeerate","avgfeerate"]]
}'

Response example

{
    "result": {
        "avgfeerate": 0,
        "minfeerate": 0
    },
    "error": null,
    "id": "test"
}

getchaintips

Returns information about all known tips in the block tree.

Return information about all known tips in the block tree, including the main chain as well as orphaned branches.

getchaintips

Parameters


  • id (string; required): a request ID (example: test).
  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).
  • method (string; required): a method used for the request.
  • params (array; required): none.

Returns

[                        (json array)
  {                      (json object)
    "height" : n,        (numeric) height of the chain tip
    "hash" : "hex",      (string) block hash of the tip
    "branchlen" : n,     (numeric) zero for main chain, otherwise length of branch connecting the tip to the main chain
    "status" : "str"     (string) status of the chain, "active" for the main chain
                         Possible values for status:
                         1.  "invalid"               This branch contains at least one invalid block
                         2.  "headers-only"          Not all blocks for this branch are available, but the headers are valid
                         3.  "valid-headers"         All blocks are available for this branch, but they were never fully validated
                         4.  "valid-fork"            This branch is not part of the active chain, but is fully validated
                         5.  "active"                This is the tip of the active main chain, which is certainly valid
  },
  ...
]

Request example

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "getchaintips",
      "params": []
}'

Response example

{
    "result": [
        {
            "height": 843553,
            "hash": "00000000000000000001f0d113bbcef2c1f52882bf8044a7df5299d364216734",
            "branchlen": 0,
            "status": "active"
        },
        {
            "height": 829613,
            "hash": "0000000000000000000357088139cba6dc295875d7d3b2dd1fd764705727e451",
            "branchlen": 1,
            "status": "valid-fork"
        }
    ],
    "error": null,
    "id": "test"
}

getchaintxstats

Computes statistics about the total number and rate of transactions in the chain.

getchaintxstats ( nblocks "blockhash" )

Parameters


  • id (string; required): a request ID (example: test).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • <nblocks> (numeric; optional; default=one month): size of the window in number of blocks
    • <blockhash> (string; optional; default=chain tip): the hash of the block that ends the window.

Returns

{                                       (json object)
  "time" : xxx,                         (numeric) The timestamp for the final block in the window, expressed in UNIX epoch time
  "txcount" : n,                        (numeric) The total number of transactions in the chain up to that point
  "window_final_block_hash" : "hex",    (string) The hash of the final block in the window
  "window_final_block_height" : n,      (numeric) The height of the final block in the window.
  "window_block_count" : n,             (numeric) Size of the window in number of blocks
  "window_tx_count" : n,                (numeric) The number of transactions in the window. Only returned if "window_block_count" is > 0
  "window_interval" : n,                (numeric) The elapsed time in the window in seconds. Only returned if "window_block_count" is > 0
  "txrate" : n                          (numeric) The average rate of transactions per second in the window. Only returned if "window_interval" is > 0
}

Request example

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "getchaintxstats",
      "params": [2016]
}'

Response example

{
    "result": {
        "time": 1715767659,
        "txcount": 1005147385,
        "window_final_block_hash": "00000000000000000001f0d113bbcef2c1f52882bf8044a7df5299d364216734",
        "window_final_block_height": 843553,
        "window_block_count": 2016,
        "window_tx_count": 7940938,
        "window_interval": 1269305,
        "txrate": 6.256130717203509
    },
    "error": null,
    "id": "test"
}

getdifficulty

Returns the proof-of-work difficulty as a multiple of the minimum difficulty.

getdifficulty

Parameters


  • id (string; required): a request ID (example: test).
  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).
  • method (string; required): a method used for the request.
  • params (array; required): none.

Returns

The proof-of-work difficulty as a multiple of the minimum difficulty.

Request example

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "getdifficulty",
      "params": []
}'

Response example

{
    "result": 83148355189239.77,
    "error": null,
    "id": "test"
}

getmempoolancestors

If txid is in the mempool, returns all in-mempool ancestors.

getmempoolancestors "txid" ( verbose )

Parameters


  • id (string; required): a request ID (example: test).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • <txid> (string; required): the transaction id (must be in mempool).
    • <verbose> (boolean; optional; default=false): true for a json object, false for array of transaction ids.

Returns

Verbose=false:

[           (json array)
  "hex",    (string) The transaction id of an in-mempool ancestor transaction
  ...
]

Verbose=true:

{                                         (json object)
  "transactionid" : {                     (json object)
    "vsize" : n,                          (numeric) virtual transaction size as defined in BIP 141. This is different from actual serialized size for witness transactions as witness data is discounted.
    "weight" : n,                         (numeric) transaction weight as defined in BIP 141.
    "fee" : n,                            (numeric) transaction fee in BTC (DEPRECATED)
    "modifiedfee" : n,                    (numeric) transaction fee with fee deltas used for mining priority (DEPRECATED)
    "time" : xxx,                         (numeric) local time transaction entered pool in seconds since 1 Jan 1970 GMT
    "height" : n,                         (numeric) block height when transaction entered pool
    "descendantcount" : n,                (numeric) number of in-mempool descendant transactions (including this one)
    "descendantsize" : n,                 (numeric) virtual transaction size of in-mempool descendants (including this one)
    "descendantfees" : n,                 (numeric) modified fees (see above) of in-mempool descendants (including this one) (DEPRECATED)
    "ancestorcount" : n,                  (numeric) number of in-mempool ancestor transactions (including this one)
    "ancestorsize" : n,                   (numeric) virtual transaction size of in-mempool ancestors (including this one)
    "ancestorfees" : n,                   (numeric) modified fees (see above) of in-mempool ancestors (including this one) (DEPRECATED)
    "wtxid" : "hex",                      (string) hash of serialized transaction, including witness data
    "fees" : {                            (json object)
      "base" : n,                         (numeric) transaction fee in BTC
      "modified" : n,                     (numeric) transaction fee with fee deltas used for mining priority in BTC
      "ancestor" : n,                     (numeric) modified fees (see above) of in-mempool ancestors (including this one) in BTC
      "descendant" : n                    (numeric) modified fees (see above) of in-mempool descendants (including this one) in BTC
    },
    "depends" : [                         (json array) unconfirmed transactions used as inputs for this transaction
      "hex",                              (string) parent transaction id
      ...
    ],
    "spentby" : [                         (json array) unconfirmed transactions spending outputs from this transaction
      "hex",                              (string) child transaction id
      ...
    ],
    "bip125-replaceable" : true|false,    (boolean) Whether this transaction could be replaced due to BIP125 (replace-by-fee)
    "unbroadcast" : true|false            (boolean) Whether this transaction is currently unbroadcast (initial broadcast not yet acknowledged by any peers)
  },
  ...
}

Request example

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "getmempoolancestors",
      "params": ["mytxid"]
}'

getmempooldescendants

If txid is in the mempool, returns all in-mempool descendants.

getmempooldescendants "txid" ( verbose )

Parameters


  • id (string; required): a request ID (example: test).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • <txid> (string; required): the transaction id (must be in mempool).
    • <verbose> (boolean; optional; default=false): true for a json object, false for array of transaction ids.

Returns

Verbose=false:

[           (json array)
  "hex",    (string) The transaction id of an in-mempool descendant transaction
  ...
]

Verbose=true:

{                                         (json object)
  "transactionid" : {                     (json object)
    "vsize" : n,                          (numeric) virtual transaction size as defined in BIP 141. This is different from actual serialized size for witness transactions as witness data is discounted.
    "weight" : n,                         (numeric) transaction weight as defined in BIP 141.
    "fee" : n,                            (numeric) transaction fee in BTC (DEPRECATED)
    "modifiedfee" : n,                    (numeric) transaction fee with fee deltas used for mining priority (DEPRECATED)
    "time" : xxx,                         (numeric) local time transaction entered pool in seconds since 1 Jan 1970 GMT
    "height" : n,                         (numeric) block height when transaction entered pool
    "descendantcount" : n,                (numeric) number of in-mempool descendant transactions (including this one)
    "descendantsize" : n,                 (numeric) virtual transaction size of in-mempool descendants (including this one)
    "descendantfees" : n,                 (numeric) modified fees (see above) of in-mempool descendants (including this one) (DEPRECATED)
    "ancestorcount" : n,                  (numeric) number of in-mempool ancestor transactions (including this one)
    "ancestorsize" : n,                   (numeric) virtual transaction size of in-mempool ancestors (including this one)
    "ancestorfees" : n,                   (numeric) modified fees (see above) of in-mempool ancestors (including this one) (DEPRECATED)
    "wtxid" : "hex",                      (string) hash of serialized transaction, including witness data
    "fees" : {                            (json object)
      "base" : n,                         (numeric) transaction fee in BTC
      "modified" : n,                     (numeric) transaction fee with fee deltas used for mining priority in BTC
      "ancestor" : n,                     (numeric) modified fees (see above) of in-mempool ancestors (including this one) in BTC
      "descendant" : n                    (numeric) modified fees (see above) of in-mempool descendants (including this one) in BTC
    },
    "depends" : [                         (json array) unconfirmed transactions used as inputs for this transaction
      "hex",                              (string) parent transaction id
      ...
    ],
    "spentby" : [                         (json array) unconfirmed transactions spending outputs from this transaction
      "hex",                              (string) child transaction id
      ...
    ],
    "bip125-replaceable" : true|false,    (boolean) Whether this transaction could be replaced due to BIP125 (replace-by-fee)
    "unbroadcast" : true|false            (boolean) Whether this transaction is currently unbroadcast (initial broadcast not yet acknowledged by any peers)
  },
  ...
}

Request example

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "getmempooldescendants",
      "params": ["mytxid"]
}'

getmempoolentry

Returns mempool data for given transaction.

getmempoolentry "txid"

Parameters


  • id (string; required): a request ID (example: test).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • <txid> (string; required): the transaction id (must be in mempool).

Returns

{                                       (json object)
  "vsize" : n,                          (numeric) virtual transaction size as defined in BIP 141. This is different from actual serialized size for witness transactions as witness data is discounted.
  "weight" : n,                         (numeric) transaction weight as defined in BIP 141.
  "fee" : n,                            (numeric) transaction fee in BTC (DEPRECATED)
  "modifiedfee" : n,                    (numeric) transaction fee with fee deltas used for mining priority (DEPRECATED)
  "time" : xxx,                         (numeric) local time transaction entered pool in seconds since 1 Jan 1970 GMT
  "height" : n,                         (numeric) block height when transaction entered pool
  "descendantcount" : n,                (numeric) number of in-mempool descendant transactions (including this one)
  "descendantsize" : n,                 (numeric) virtual transaction size of in-mempool descendants (including this one)
  "descendantfees" : n,                 (numeric) modified fees (see above) of in-mempool descendants (including this one) (DEPRECATED)
  "ancestorcount" : n,                  (numeric) number of in-mempool ancestor transactions (including this one)
  "ancestorsize" : n,                   (numeric) virtual transaction size of in-mempool ancestors (including this one)
  "ancestorfees" : n,                   (numeric) modified fees (see above) of in-mempool ancestors (including this one) (DEPRECATED)
  "wtxid" : "hex",                      (string) hash of serialized transaction, including witness data
  "fees" : {                            (json object)
    "base" : n,                         (numeric) transaction fee in BTC
    "modified" : n,                     (numeric) transaction fee with fee deltas used for mining priority in BTC
    "ancestor" : n,                     (numeric) modified fees (see above) of in-mempool ancestors (including this one) in BTC
    "descendant" : n                    (numeric) modified fees (see above) of in-mempool descendants (including this one) in BTC
  },
  "depends" : [                         (json array) unconfirmed transactions used as inputs for this transaction
    "hex",                              (string) parent transaction id
    ...
  ],
  "spentby" : [                         (json array) unconfirmed transactions spending outputs from this transaction
    "hex",                              (string) child transaction id
    ...
  ],
  "bip125-replaceable" : true|false,    (boolean) Whether this transaction could be replaced due to BIP125 (replace-by-fee)
  "unbroadcast" : true|false            (boolean) Whether this transaction is currently unbroadcast (initial broadcast not yet acknowledged by any peers)
}

Request example

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "getmempoolentry",
      "params": ["mytxid"]
}'

getmempoolinfo

Returns the details on the active state of the TX memory pool.

getmempoolinfo

Parameters


  • id (string; required): a request ID (example: test).
  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).
  • method (string; required): a method used for the request.
  • params (array; required): none.

Returns

{                            (json object)
  "loaded" : true|false,     (boolean) True if the mempool is fully loaded
  "size" : n,                (numeric) Current tx count
  "bytes" : n,               (numeric) Sum of all virtual transaction sizes as defined in BIP 141. Differs from actual serialized size because witness data is discounted
  "usage" : n,               (numeric) Total memory usage for the mempool
  "maxmempool" : n,          (numeric) Maximum memory usage for the mempool
  "mempoolminfee" : n,       (numeric) Minimum fee rate in BTC/kB for tx to be accepted. Is the maximum of minrelaytxfee and minimum mempool fee
  "minrelaytxfee" : n,       (numeric) Current minimum relay fee for transactions
  "unbroadcastcount" : n     (numeric) Current number of transactions that haven't passed initial broadcast yet
}

Request example

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "getmempoolinfo",
      "params": []
}'

Response example

{
    "result": {
        "loaded": true,
        "size": 57725,
        "bytes": 90167011,
        "usage": 294308080,
        "total_fee": 7.18859673,
        "maxmempool": 300000000,
        "mempoolminfee": 0.00004923,
        "minrelaytxfee": 0.00001,
        "incrementalrelayfee": 0.00001,
        "unbroadcastcount": 0,
        "fullrbf": false
    },
    "error": null,
    "id": "test"
}

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.

getrawmempool ( verbose mempool_sequence )

Parameters


  • id (string; required): a request ID (example: test).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • <verbose> (boolean; optional; default=false): true for a json object, false for array of transaction ids.
    • <mempool_sequence> (boolean; optional; default=false): if verbose=false, returns a json object with transaction list and mempool sequence number attached.

Returns

Verbose=false:

[           (json array)
  "hex",    (string) The transaction id
  ...
]

Verbose=true:

{                                         (json object)
  "transactionid" : {                     (json object)
    "vsize" : n,                          (numeric) virtual transaction size as defined in BIP 141. This is different from actual serialized size for witness transactions as witness data is discounted.
    "weight" : n,                         (numeric) transaction weight as defined in BIP 141.
    "fee" : n,                            (numeric) transaction fee in BTC (DEPRECATED)
    "modifiedfee" : n,                    (numeric) transaction fee with fee deltas used for mining priority (DEPRECATED)
    "time" : xxx,                         (numeric) local time transaction entered pool in seconds since 1 Jan 1970 GMT
    "height" : n,                         (numeric) block height when transaction entered pool
    "descendantcount" : n,                (numeric) number of in-mempool descendant transactions (including this one)
    "descendantsize" : n,                 (numeric) virtual transaction size of in-mempool descendants (including this one)
    "descendantfees" : n,                 (numeric) modified fees (see above) of in-mempool descendants (including this one) (DEPRECATED)
    "ancestorcount" : n,                  (numeric) number of in-mempool ancestor transactions (including this one)
    "ancestorsize" : n,                   (numeric) virtual transaction size of in-mempool ancestors (including this one)
    "ancestorfees" : n,                   (numeric) modified fees (see above) of in-mempool ancestors (including this one) (DEPRECATED)
    "wtxid" : "hex",                      (string) hash of serialized transaction, including witness data
    "fees" : {                            (json object)
      "base" : n,                         (numeric) transaction fee in BTC
      "modified" : n,                     (numeric) transaction fee with fee deltas used for mining priority in BTC
      "ancestor" : n,                     (numeric) modified fees (see above) of in-mempool ancestors (including this one) in BTC
      "descendant" : n                    (numeric) modified fees (see above) of in-mempool descendants (including this one) in BTC
    },
    "depends" : [                         (json array) unconfirmed transactions used as inputs for this transaction
      "hex",                              (string) parent transaction id
      ...
    ],
    "spentby" : [                         (json array) unconfirmed transactions spending outputs from this transaction
      "hex",                              (string) child transaction id
      ...
    ],
    "bip125-replaceable" : true|false,    (boolean) Whether this transaction could be replaced due to BIP125 (replace-by-fee)
    "unbroadcast" : true|false            (boolean) Whether this transaction is currently unbroadcast (initial broadcast not yet acknowledged by any peers)
  },
  ...
}

verbose=false and mempool_sequence=true:

{                            (json object)
  "txids" : [                (json array)
    "hex",                   (string) The transaction id
    ...
  ],
  "mempool_sequence" : n     (numeric) The mempool sequence value.
}

Request example

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "getrawmempool",
      "params": []
}'

Response example

{
    "result": [
        "09448e71251330ff2fab39365284df31278eee4a5102556f674f32155d5eda5b",
        "703feebeac6110ec3ab941e6c2e6ef655dc303f77209a142864828e4bba7bfc9",
        "587af96d47e5ff6b9690ccba02fafb07473ed70a4528ec34ab5d7bcb1cef7c2e",
        "6557e364a70420a1c0d06bad1eaff11cf23ccce3714aa2f384dcc854211f69cc",
        "7e42415091463558478e17e62517faace89e14a88c430e0efb9b511739c6b31d",
        "9eda12a34bbf507265c21e8d6c59dbfc1a779f238db7c06e8e8160147f74cbef",
        "e44938eacb53f4e8a5e61a67cd3f840c02d26ff999349c523cf36761f711fcb4",
        "e3494ca0f7fea1e598a1ec090f2f50df989e6c7b36ed1815a67f4a5c1b9e441b",
        "7bf20128eb9904fdf4d5dd1a7fafe9d494c52304574a3fcd88c188a83a32086f",
        "ebaedb496434bbd6b218e2d5ea1cb6d948a30cabb8f41576c4f15c5e4ad34f9d",
        "75f614042e2bd67ac5ee19f425830333ae0381a706afa2b4d21c6f49745b6bff",
        "85a183e9e19630e77b65abbf4e50305b32d683626099f65c385f034a2e72cb75"
    ],
    "error": null,
    "id": "test"
}

gettxout

Returns details about an unspent transaction output.

gettxout "txid" n ( include_mempool )

Parameters


  • id (string; required): a request ID (example: test).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • <txid> (string; required): the transaction ID.
    • <n> (numeric; required): vout number.
    • <include_mempool> (boolean; optional; default=true): whether to include the mempool. Note that an unspent output that is spent in the mempool won’t appear.

Returns

{                             (json object)
  "bestblock" : "hex",        (string) The hash of the block at the tip of the chain
  "confirmations" : n,        (numeric) The number of confirmations
  "value" : n,                (numeric) The transaction value in BTC
  "scriptPubKey" : {          (json object)
    "asm" : "hex",            (string)
    "hex" : "hex",            (string)
    "reqSigs" : n,            (numeric) Number of required signatures
    "type" : "hex",           (string) The type, eg pubkeyhash
    "addresses" : [           (json array) array of bitcoin addresses
      "str",                  (string) bitcoin address
      ...
    ]
  },
  "coinbase" : true|false     (boolean) Coinbase or not
}

Request example

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "gettxout",
      "params": ["txid", 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).

gettxoutproof ["txid",...] ( "blockhash" )

Parameters


  • id (string; required): a request ID (example: test).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • <txid> (array of strings: required): the txids to filter.

      [
        "txid",    (string) A transaction hash
        ...
      ]
    • <blockhash> (string; optional): if specified, looks for txid in the block with this hash.

Returns

A string that is a serialized, hex-encoded data for the proof.

Request example

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "gettxoutproof",
      "params": [["c7f32887779200fec23a0f4ebe73bed003f9ab8a46c2b549320c3c5cb78c7dc9"], "000000000000000000034e30310c8bf30133e41ae3ae189f987e509901409bf7"]

Response example

{
    "result": "008035222f854ca799cc749ca6d54a9ab85793b130a95348fe6e00000000000000000000badfdb8bab19d4ab1f08da2c98122c7d25586ba56b9c13cce8325eb42948fb8028a644669a62031723892528750d00000dc97d8cb75c3c0c3249b5c2468aabf903d0be73be4e0f3ac2fe0092778728f3c7096a1ace4290e6cfb9ab99245aee7fab74f6e6393ef47932d1b6cb494d60451780ecc5be308320b45fd9f07b6cffe1a6b7143ae9e2d134a4292dd937ff83d92b5a683483be79cabafd107330094c049ef166fad38a395b6bc4f58de82f0d5cbd479483b11d489ccb87e20cf97451419453495d1492e32bb9c0539c9a92885d7c2310ef802b85611f6340a7f99c36f04e769ab50bb00048791b16091870f817c503d46587bd48aa6bd895ea6ce9eb3fa06a86b432a40afbf27d879c09093ca03586284ac2b64b252b32be440a683beaf2f672efaf1cb36a429fa2a2cbe0800373a72857c1af218d71e4295ebeabdb80ca35b41f5d3a91c78a186fc76b01690d6f7a89a6912d4528a0072a5945f6a3f94b8fbc293964bdab3b9fb70ea0e7be6caa25f15f366a9473bbf55f69335b7dc642472efeb4feeaa0fafedf70c5a4f7dc370bddd972db84dd9fb5e82fced3cdef20bc98ae178fc8aedb8a2448652c6ce32cbe82d4859c7004d38db06d61b7b5014a89ad9160ec39adfb21b7a92d7f84525404ff1f0000",
    "error": null,
    "id": "test"
}

verifytxoutproof

Verifies that a proof points to a transaction in a block.

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.

verifytxoutproof "proof"

Parameters


  • id (string; required): a request ID (example: test).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • <proof> (string; required): the hex-encoded proof generated by gettxoutproof.

Returns

[           (json array)
  "hex",    (string) The txid(s) which the proof commits to, or empty array if the proof can not be validated.
  ...
]

Request example

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "verifytxoutproof",
      "params": ["008035222f854ca799cc749ca6d54a9ab85793b130a95348fe6e00000000000000000000badfdb8bab19d4ab1f08da2c98122c7d25586ba56b9c13cce8325eb42948fb8028a644669a62031723892528750d00000dc97d8cb75c3c0c3249b5c2468aabf903d0be73be4e0f3ac2fe0092778728f3c7096a1ace4290e6cfb9ab99245aee7fab74f6e6393ef47932d1b6cb494d60451780ecc5be308320b45fd9f07b6cffe1a6b7143ae9e2d134a4292dd937ff83d92b5a683483be79cabafd107330094c049ef166fad38a395b6bc4f58de82f0d5cbd479483b11d489ccb87e20cf97451419453495d1492e32bb9c0539c9a92885d7c2310ef802b85611f6340a7f99c36f04e769ab50bb00048791b16091870f817c503d46587bd48aa6bd895ea6ce9eb3fa06a86b432a40afbf27d879c09093ca03586284ac2b64b252b32be440a683beaf2f672efaf1cb36a429fa2a2cbe0800373a72857c1af218d71e4295ebeabdb80ca35b41f5d3a91c78a186fc76b01690d6f7a89a6912d4528a0072a5945f6a3f94b8fbc293964bdab3b9fb70ea0e7be6caa25f15f366a9473bbf55f69335b7dc642472efeb4feeaa0fafedf70c5a4f7dc370bddd972db84dd9fb5e82fced3cdef20bc98ae178fc8aedb8a2448652c6ce32cbe82d4859c7004d38db06d61b7b5014a89ad9160ec39adfb21b7a92d7f84525404ff1f0000"]
}'

Response example

{
    "result": [
        "c7f32887779200fec23a0f4ebe73bed003f9ab8a46c2b549320c3c5cb78c7dc9"
    ],
    "error": null,
    "id": "test"
}

Raw transactions RPCs

analyzepsbt

Analyzes and provides information about the current status of a PSBT and its inputs.

analyzepsbt "psbt"

Parameters


  • id (string; required): a request ID (example: test).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • <psbt> (string; required): a base64 string of a PSBT.

Returns

{                                   (json object)
  "inputs" : [                      (json array)
    {                               (json object)
      "has_utxo" : true|false,      (boolean) Whether a UTXO is provided
      "is_final" : true|false,      (boolean) Whether the input is finalized
      "missing" : {                 (json object, optional) Things that are missing that are required to complete this input
        "pubkeys" : [               (json array, optional)
          "hex",                    (string) Public key ID, hash160 of the public key, of a public key whose BIP 32 derivation path is missing
          ...
        ],
        "signatures" : [            (json array, optional)
          "hex",                    (string) Public key ID, hash160 of the public key, of a public key whose signature is missing
          ...
        ],
        "redeemscript" : "hex",     (string, optional) Hash160 of the redeemScript that is missing
        "witnessscript" : "hex"     (string, optional) SHA256 of the witnessScript that is missing
      },
      "next" : "str"                (string, optional) Role of the next person that this input needs to go to
    },
    ...
  ],
  "estimated_vsize" : n,            (numeric, optional) Estimated vsize of the final signed transaction
  "estimated_feerate" : n,          (numeric, optional) Estimated feerate of the final signed transaction in BTC/kB. Shown only if all UTXO slots in the PSBT have been filled
  "fee" : n,                        (numeric, optional) The transaction fee paid. Shown only if all UTXO slots in the PSBT have been filled
  "next" : "str",                   (string) Role of the next person that this psbt needs to go to
  "error" : "str"                   (string, optional) Error message (if there is one)
}

Request example

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "analyzepsbt",
      "params": ["cHNidP8BAFUCAAAAATK/5HXt1hQqK9Sy/NYfp/TPW/RZlM5LbV0v76TH56nhAAAAAAD9////AUBCDwAAAAAAGXapFGLpB7FcvyfVQlOZ6/bw+1DruI8YiKwAAAAAAAAA"]
}'

Response example

{
    "result": {
        "inputs": [
            {
                "has_utxo": false,
                "is_final": false,
                "next": "updater"
            }
        ],
        "next": "updater"
    },
    "error": null,
    "id": "test"
}

combinepsbt

Combines multiple partially signed Bitcoin transactions into one transaction.

Implements the Combiner role.

combinepsbt ["psbt",...]

Parameters


  • id (string; required): a request ID (example: test).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • <txs> (array of strings; required): the base64 strings of partially signed transactions.

      [
        "psbt",    (string) A base64 string of a PSBT
        ...
      ]

Returns

The base64-encoded partially signed transaction.

Request example

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "combinepsbt",
      "params": ["mybase64_1", "mybase64_2", "mybase64_3"]
}'

combinerawtransaction

Combines multiple partially signed transactions into one transaction.

The combined transaction may be another partially signed transaction or a fully signed transaction.

combinerawtransaction ["hexstring",...]

Parameters


  • id (string; required): a request ID (example: test).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • <txs> (array of strings; required): the hex strings of partially signed transactions.

      [
        "hexstring",    (string) A hex-encoded raw transaction
        ...
      ]

Returns

The hex-encoded raw transaction with signatures.

Request example

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "combinerawtransaction",
      "params": ["mybase64_1", "mybase64_2", "mybase64_3"]
}'

converttopsbt

Converts a network serialized transaction to a PSBT.

This should be used only with createrawtransaction and fundrawtransaction. createpsbt and walletcreatefundedpsbt should be used for new applications.

converttopsbt "hexstring" ( permitsigdata iswitness )

Parameters


  • id (string; required): a request ID (example: test).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • <hexstring> (string; required): the hex string of a raw transaction.
    • <permitsigdata> (boolean; optional; default=false): if true, any signatures in the input will be discarded and conversion will continue. If false, RPC will fail if any signatures are present.
    • <iswitness> (boolean; optional; default=depends on heuristic tests): whether the transaction hex is a serialized witness transaction. If iswitness is not present, heuristic tests will be used in decoding. If true, only witness deserialization will be tried. If false, only non-witness deserialization will be tried. This boolean should reflect whether the transaction has inputs (e.g. fully valid, or on-chain transactions), if known by the caller.

Returns

The resulting raw transaction (base64-encoded string).

Request example

Create a transaction:

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "createrawtransaction",
      "params": [[{"txid":"myid","vout":0}],[{"address":0.01}]]
}'

Convert the transaction to PSBT:

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "converttopsbt",
      "params": ["020000000132bfe475edd6142a2bd4b2fcd61fa7f4cf5bf45994ce4b6d5d2fefa4c7e7a9e10000000000fdffffff0140420f00000000001976a91462e907b15cbf27d5425399ebf6f0fb50ebb88f1888ac00000000"]
}'

Response example

{
    "result": "cHNidP8BAFUCAAAAATK/5HXt1hQqK9Sy/NYfp/TPW/RZlM5LbV0v76TH56nhAAAAAAD9////AUBCDwAAAAAAGXapFGLpB7FcvyfVQlOZ6/bw+1DruI8YiKwAAAAAAAAA",
    "error": null,
    "id": "test"
}

createpsbt

Creates a transaction in the Partially Signed Transaction format.

Implements the Creator role.

createpsbt [{"txid":"hex","vout":n,"sequence":n},...] [{"address":amount},{"data":"hex"},...] ( locktime replaceable )

Parameters


  • id (string; required): a request ID (example: test).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • <inputs> (json array; required): the json objects.

      [
        {                       (json object)
          "txid": "hex",        (string, required) The transaction id
          "vout": n,            (numeric, required) The output number
          "sequence": n,        (numeric, optional, default=depends on the value of the 'replaceable' and 'locktime' arguments) The sequence number
        },
        ...
      ]
    • <outputs> (json array; required): the outputs (key-value pairs), where none of the keys are duplicated. That is, each address can only appear once and there can only be one ‘data’ object. For compatibility reasons, a dictionary, which holds the key-value pairs directly, is also accepted as second parameter.

      [
        {                       (json object)
          "address": amount,    (numeric or string, required) A key-value pair. The key (string) is the bitcoin address, the value (float or string) is the amount in BTC
        },
        {                       (json object)
          "data": "hex",        (string, required) A key-value pair. The key must be "data", the value is hex-encoded data
        },
        ...
      ]
    • <locktime> (numeric; optional; default=0): raw locktime. Non-0 value also locktime-activates inputs.

    • <replaceable> (boolean; optional; default=false): marks this transaction as BIP125 replaceable. Allows this transaction to be replaced by a transaction with higher fees. If provided, it is an error if explicit sequence numbers are incompatible.

Returns

The resulting raw transaction (base64-encoded string).

Request example

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "createpsbt",
      "params": [[{"txid":"e1a9e7c7a4ef2f5d6d4bce9459f45bcff4a71fd6fcb2d42b2a14d6ed75e4bf32","vout":0}],[{"data":"00010203"}]]
}'

Response example

{
    "result": "cHNidP8BAEICAAAAATK/5HXt1hQqK9Sy/NYfp/TPW/RZlM5LbV0v76TH56nhAAAAAAD9////AQAAAAAAAAAABmoEAAECAwAAAAAAAAA=",
    "error": null,
    "id": "test"
}

createrawtransaction

Creates a transaction spending the given inputs and creating new outputs.

Outputs can be addresses or data.
Returns hex-encoded raw transaction.
Note that the transaction’s inputs are not signed, and it is not stored in the wallet or transmitted to the network.

createrawtransaction [{"txid":"hex","vout":n,"sequence":n},...] [{"address":amount},{"data":"hex"},...] ( locktime replaceable )

Parameters


  • id (string; required): a request ID (example: test).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • <inputs> (json array; required): the inputs.

      [
        {                       (json object)
          "txid": "hex",        (string, required) The transaction id
          "vout": n,            (numeric, required) The output number
          "sequence": n,        (numeric, optional, default=depends on the value of the 'replaceable' and 'locktime' arguments) The sequence number
        },
        ...
      ]
    • <outputs> (json array; required): the outputs (key-value pairs), where none of the keys are duplicated. That is, each address can only appear once and there can only be one ‘data’ object. For compatibility reasons, a dictionary, which holds the key-value pairs directly, is also accepted as second parameter.

      [
        {                       (json object)
          "address": amount,    (numeric or string, required) A key-value pair. The key (string) is the bitcoin address, the value (float or string) is the amount in BTC
        },
        {                       (json object)
          "data": "hex",        (string, required) A key-value pair. The key must be "data", the value is hex-encoded data
        },
        ...
      ]
    • <locktime> (numeric; optional; default=0): raw locktime. Non-0 value also locktime-activates inputs.

    • <replaceable> (boolean; optional; default=false): marks this transaction as BIP125-replaceable. Allows this transaction to be replaced by a transaction with higher fees. If provided, it is an error if explicit sequence numbers are incompatible.

Returns

A hex string of the transaction.

Request example

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "hww",
      "method": "createrawtransaction",
      "params": [[{"txid":"e1a9e7c7a4ef2f5d6d4bce9459f45bcff4a71fd6fcb2d42b2a14d6ed75e4bf32","vout":0}], [{"1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa":0.01}]]
}'

Response example

{
    "result": "020000000132bfe475edd6142a2bd4b2fcd61fa7f4cf5bf45994ce4b6d5d2fefa4c7e7a9e10000000000fdffffff0140420f00000000001976a91462e907b15cbf27d5425399ebf6f0fb50ebb88f1888ac00000000",
    "error": null,
    "id": "hww"
}

decodepsbt

Returns a JSON object representing the serialized, base64-encoded partially signed Bitcoin transaction.

decodepsbt "psbt"

Parameters


  • id (string; required): a request ID (example: test).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • <psbt> (string; required): the PSBT base64 string.

Returns

{                                          (json object)
  "tx" : {                                 (json object) The decoded network-serialized unsigned transaction.
    ...                                    The layout is the same as the output of decoderawtransaction.
  },
  "unknown" : {                            (json object) The unknown global fields
    "key" : "hex",                         (string) (key-value pair) An unknown key-value pair
    ...
  },
  "inputs" : [                             (json array)
    {                                      (json object)
      "non_witness_utxo" : {               (json object, optional) Decoded network transaction for non-witness UTXOs
        ...
      },
      "witness_utxo" : {                   (json object, optional) Transaction output for witness UTXOs
        "amount" : n,                      (numeric) The value in BTC
        "scriptPubKey" : {                 (json object)
          "asm" : "str",                   (string) The asm
          "hex" : "hex",                   (string) The hex
          "type" : "str",                  (string) The type, eg 'pubkeyhash'
          "address" : "str"                (string)  Bitcoin address if there is one
        }
      },
      "partial_signatures" : {             (json object, optional)
        "pubkey" : "str",                  (string) The public key and signature that corresponds to it.
        ...
      },
      "sighash" : "str",                   (string, optional) The sighash type to be used
      "redeem_script" : {                  (json object, optional)
        "asm" : "str",                     (string) The asm
        "hex" : "hex",                     (string) The hex
        "type" : "str"                     (string) The type, eg 'pubkeyhash'
      },
      "witness_script" : {                 (json object, optional)
        "asm" : "str",                     (string) The asm
        "hex" : "hex",                     (string) The hex
        "type" : "str"                     (string) The type, eg 'pubkeyhash'
      },
      "bip32_derivs" : [                   (json array, optional)
        {                                  (json object, optional) The public key with the derivation path as the value.
          "master_fingerprint" : "str",    (string) The fingerprint of the master key
          "path" : "str"                   (string) The path
        },
        ...
      ],
      "final_scriptsig" : {                (json object, optional)
        "asm" : "str",                     (string) The asm
        "hex" : "str"                      (string) The hex
      },
      "final_scriptwitness" : [            (json array)
        "hex",                             (string) hex-encoded witness data (if any)
        ...
      ],
      "unknown" : {                        (json object) The unknown global fields
        "key" : "hex",                     (string) (key-value pair) An unknown key-value pair
        ...
      }
    },
    ...
  ],
  "outputs" : [                            (json array)
    {                                      (json object)
      "redeem_script" : {                  (json object, optional)
        "asm" : "str",                     (string) The asm
        "hex" : "hex",                     (string) The hex
        "type" : "str"                     (string) The type, eg 'pubkeyhash'
      },
      "witness_script" : {                 (json object, optional)
        "asm" : "str",                     (string) The asm
        "hex" : "hex",                     (string) The hex
        "type" : "str"                     (string) The type, eg 'pubkeyhash'
      },
      "bip32_derivs" : [                   (json array, optional)
        {                                  (json object)
          "pubkey" : "str",                (string) The public key this path corresponds to
          "master_fingerprint" : "str",    (string) The fingerprint of the master key
          "path" : "str"                   (string) The path
        },
        ...
      ],
      "unknown" : {                        (json object) The unknown global fields
        "key" : "hex",                     (string) (key-value pair) An unknown key-value pair
        ...
      }
    },
    ...
  ],
  "fee" : n                                (numeric, optional) The transaction fee paid if all UTXOs slots in the PSBT have been filled.
}

Request example

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "decodepsbt",
      "params": ["cHNidP8BAEICAAAAATK/5HXt1hQqK9Sy/NYfp/TPW/RZlM5LbV0v76TH56nhAAAAAAD9////AQAAAAAAAAAABmoEAAECAwAAAAAAAAA="]
}'

Response example

{
    "result": {
        "tx": {
            "txid": "ad0f4833625ac33a57251e4c7d43fa29ed6f0b4b0276beed9977b6f84bfe58b4",
            "hash": "ad0f4833625ac33a57251e4c7d43fa29ed6f0b4b0276beed9977b6f84bfe58b4",
            "version": 2,
            "size": 66,
            "vsize": 66,
            "weight": 264,
            "locktime": 0,
            "vin": [
                {
                    "txid": "e1a9e7c7a4ef2f5d6d4bce9459f45bcff4a71fd6fcb2d42b2a14d6ed75e4bf32",
                    "vout": 0,
                    "scriptSig": {
                        "asm": "",
                        "hex": ""
                    },
                    "sequence": 4294967293
                }
            ],
            "vout": [
                {
                    "value": 0,
                    "n": 0,
                    "scriptPubKey": {
                        "asm": "OP_RETURN 50462976",
                        "desc": "raw(6a0400010203)#6scht25q",
                        "hex": "6a0400010203",
                        "type": "nulldata"
                    }
                }
            ]
        },
        "global_xpubs": [],
        "psbt_version": 0,
        "proprietary": [],
        "unknown": {},
        "inputs": [
            {}
        ],
        "outputs": [
            {}
        ]
    },
    "error": null,
    "id": "test"
}

decoderawtransaction

Returns a JSON object representing the serialized, hex-encoded transaction.

decoderawtransaction "hexstring" ( iswitness )

Parameters


  • id (string; required): a request ID (example: test).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • <hexstring> (string; required): the transaction hex string.
    • <iswitness> (boolean; optional; default=depends on heuristic tests): whether the transaction hex is a serialized witness transaction. If iswitness is not present, heuristic tests will be used in decoding. If true, only witness deserialization will be tried. If false, only non-witness deserialization will be tried. This boolean should reflect whether the transaction has inputs (e.g. fully valid, or on-chain transactions), if known by the caller.

Returns

{                           (json object)
  "txid" : "hex",           (string) The transaction id
  "hash" : "hex",           (string) The transaction hash (differs from txid for witness transactions)
  "size" : n,               (numeric) The transaction size
  "vsize" : n,              (numeric) The virtual transaction size (differs from size for witness transactions)
  "weight" : n,             (numeric) The transaction's weight (between vsize*4 - 3 and vsize*4)
  "version" : n,            (numeric) The version
  "locktime" : xxx,         (numeric) The lock time
  "vin" : [                 (json array)
    {                       (json object)
      "txid" : "hex",       (string) The transaction id
      "vout" : n,           (numeric) The output number
      "scriptSig" : {       (json object) The script
        "asm" : "str",      (string) asm
        "hex" : "hex"       (string) hex
      },
      "txinwitness" : [     (json array)
        "hex",              (string) hex-encoded witness data (if any)
        ...
      ],
      "sequence" : n        (numeric) The script sequence number
    },
    ...
  ],
  "vout" : [                (json array)
    {                       (json object)
      "value" : n,          (numeric) The value in BTC
      "n" : n,              (numeric) index
      "scriptPubKey" : {    (json object)
        "asm" : "str",      (string) the asm
        "hex" : "hex",      (string) the hex
        "reqSigs" : n,      (numeric) The required sigs
        "type" : "str",     (string) The type, eg 'pubkeyhash'
        "addresses" : [     (json array)
          "str",            (string) bitcoin address
          ...
        ]
      }
    },
    ...
  ]
}

Request example

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "decoderawtransaction",
      "params": ["02000000017e7c9f1b7eb7d7a48028a705a23f30ae9712a1b9c229aa57f948155f1d99f6b60000000000fdffffff0140420f00000000001976a91462e907b15cbf27d5425399ebf6f0fb50ebb88f1888ac00000000"]
}'

Response example

{
    "result": {
        "txid": "af71499460ee644f623f51d023dc837f3e2ae5dd6995ab872931fdb0cff2c2ee",
        "hash": "af71499460ee644f623f51d023dc837f3e2ae5dd6995ab872931fdb0cff2c2ee",
        "version": 2,
        "size": 85,
        "vsize": 85,
        "weight": 340,
        "locktime": 0,
        "vin": [
            {
                "txid": "b6f6991d5f1548f957aa29c2b9a11297ae303fa205a72880a4d7b77e1b9f7c7e",
                "vout": 0,
                "scriptSig": {
                    "asm": "",
                    "hex": ""
                },
                "sequence": 4294967293
            }
        ],
        "vout": [
            {
                "value": 0.01,
                "n": 0,
                "scriptPubKey": {
                    "asm": "OP_DUP OP_HASH160 62e907b15cbf27d5425399ebf6f0fb50ebb88f18 OP_EQUALVERIFY OP_CHECKSIG",
                    "desc": "addr(1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa)#632p52jr",
                    "hex": "76a91462e907b15cbf27d5425399ebf6f0fb50ebb88f1888ac",
                    "address": "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa",
                    "type": "pubkeyhash"
                }
            }
        ]
    },
    "error": null,
    "id": "test"
}

decodescript

Decodes a hex-encoded script.

decodescript "hexstring"

Parameters


  • id (string; required): a request ID (example: test).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • <hexstring> (string; required): the hex-encoded script.

Returns

{                             (json object)
  "asm" : "str",              (string) Script public key
  "type" : "str",             (string) The output type (e.g. nonstandard, pubkey, pubkeyhash, scripthash, multisig, nulldata, witness_v0_scripthash, witness_v0_keyhash, witness_v1_taproot, witness_unknown)
  "reqSigs" : n,              (numeric) The required signatures
  "addresses" : [             (json array)
    "str",                    (string) bitcoin address
    ...
  ],
  "p2sh" : "str",             (string) address of P2SH script wrapping this redeem script (not returned if the script is already a P2SH)
  "segwit" : {                (json object) Result of a witness script public key wrapping this redeem script (not returned if the script is a P2SH or witness)
    "asm" : "str",            (string) String representation of the script public key
    "hex" : "hex",            (string) Hex string of the script public key
    "type" : "str",           (string) The type of the script public key (e.g. witness_v0_keyhash or witness_v0_scripthash)
    "reqSigs" : n,            (numeric) The required signatures (always 1)
    "addresses" : [           (json array) (always length 1)
      "str",                  (string) segwit address
      ...
    ],
    "p2sh-segwit" : "str"     (string) address of the P2SH script wrapping this witness redeem script
  }
}

Request example

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "decodescript",
      "params": ["76a91489abcdefabbaabbaabbaabbaabbaabbaabbaabba88ac"]
}'

Response example

{
    "result": {
        "asm": "OP_DUP OP_HASH160 89abcdefabbaabbaabbaabbaabbaabbaabbaabba OP_EQUALVERIFY OP_CHECKSIG",
        "desc": "addr(1DYwPTpZuLjY2qApmJdHaSAuWRvEF5skCN)#kh26y3vv",
        "address": "1DYwPTpZuLjY2qApmJdHaSAuWRvEF5skCN",
        "type": "pubkeyhash",
        "p2sh": "3F6i6kwkevjR7AsAd4te2YB2zZyASEm1HM",
        "segwit": {
            "asm": "0 89abcdefabbaabbaabbaabbaabbaabbaabbaabba",
            "desc": "addr(bc1q3x4ummath24m42a64wa2hw4th24m42a6rul9r7)#fpmsztnh",
            "hex": "001489abcdefabbaabbaabbaabbaabbaabbaabbaabba",
            "address": "bc1q3x4ummath24m42a64wa2hw4th24m42a6rul9r7",
            "type": "witness_v0_keyhash",
            "p2sh-segwit": "37PDvpSnXXNRppuGZxa4CvqdfeNh9j6DtE"
        }
    },
    "error": null,
    "id": "test"
}

finalizepsbt

Finalizes the inputs of a PSBT.

Finalize the inputs of a PSBT. If the transaction is fully signed, it will produce a network serialized transaction which can be broadcast with sendrawtransaction. Otherwise, a PSBT will be created which has the final_scriptSig and final_scriptWitness fields filled for inputs that are complete.

Implements the Finalizer and Extractor roles.

finalizepsbt "psbt" ( extract )

Parameters


  • id (string; required): a request ID (example: test).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • <psbt> (string; required): a base64 string of a PSBT.
    • <extract> (boolean; optional; default=true): true and the transaction is complete, extract and return the complete transaction in normal network serialization instead of the PSBT.

Returns

{                             (json object)
  "psbt" : "str",             (string) The base64-encoded partially signed transaction if not extracted
  "hex" : "hex",              (string) The hex-encoded network transaction if extracted
  "complete" : true|false     (boolean) If the transaction has a complete set of signatures
}

Request example

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "finalizepsbt",
      "params": ["cHNidP8BAFUCAAAAATK/5HXt1hQqK9Sy/NYfp/TPW/RZlM5LbV0v76TH56nhAAAAAAD9////AUBCDwAAAAAAGXapFGLpB7FcvyfVQlOZ6/bw+1DruI8YiKwAAAAAAAAA"]
}'

Response example

{
    "result": {
        "psbt": "cHNidP8BAFUCAAAAATK/5HXt1hQqK9Sy/NYfp/TPW/RZlM5LbV0v76TH56nhAAAAAAD9////AUBCDwAAAAAAGXapFGLpB7FcvyfVQlOZ6/bw+1DruI8YiKwAAAAAAAAA",
        "complete": false
    },
    "error": null,
    "id": "test"
}

getrawtransaction

Returns the raw transaction data.

getrawtransaction "txid" ( verbose "blockhash" )

By default, this function only works for mempool transactions. When called with a blockhash argument, getrawtransaction will return the transaction if the specified block is available and the transaction is found in that block. When called without a blockhash argument, getrawtransaction will return the transaction if it is in the mempool, or if -txindex is enabled and the transaction is in a block in the blockchain.

Hint: Use gettransaction for wallet transactions.

If verbose is true, returns an Object with information about txid.
If verbose is false or omitted, returns a string that is serialized, hex-encoded data for txid.

Parameters


  • id (string; required): a request ID (example: test).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • <txid> (string; required): the transaction ID.
    • <verbose> (boolean; optional; default=false): if false, return a string, otherwise return a json object.
    • <blockhash> (string; optional): the block in which to look for the transaction.

Returns

Verbose=false:

The serialized, hex-encoded data for txid.

Verbose=true:

{                                    (json object)
  "in_active_chain" : true|false,    (boolean) Whether specified block is in the active chain or not (only present with explicit "blockhash" argument)
  "hex" : "hex",                     (string) The serialized, hex-encoded data for 'txid'
  "txid" : "hex",                    (string) The transaction id (same as provided)
  "hash" : "hex",                    (string) The transaction hash (differs from txid for witness transactions)
  "size" : n,                        (numeric) The serialized transaction size
  "vsize" : n,                       (numeric) The virtual transaction size (differs from size for witness transactions)
  "weight" : n,                      (numeric) The transaction's weight (between vsize*4-3 and vsize*4)
  "version" : n,                     (numeric) The version
  "locktime" : xxx,                  (numeric) The lock time
  "vin" : [                          (json array)
    {                                (json object)
      "txid" : "hex",                (string) The transaction id
      "vout" : n,                    (numeric) The output number
      "scriptSig" : {                (json object) The script
        "asm" : "str",               (string) asm
        "hex" : "hex"                (string) hex
      },
      "sequence" : n,                (numeric) The script sequence number
      "txinwitness" : [              (json array)
        "hex",                       (string) hex-encoded witness data (if any)
        ...
      ]
    },
    ...
  ],
  "vout" : [                         (json array)
    {                                (json object)
      "value" : n,                   (numeric) The value in BTC
      "n" : n,                       (numeric) index
      "scriptPubKey" : {             (json object)
        "asm" : "str",               (string) the asm
        "hex" : "str",               (string) the hex
        "reqSigs" : n,               (numeric) The required sigs
        "type" : "str",              (string) The type, eg 'pubkeyhash'
        "addresses" : [              (json array)
          "str",                     (string) bitcoin address
          ...
        ]
      }
    },
    ...
  ],
  "blockhash" : "hex",               (string) the block hash
  "confirmations" : n,               (numeric) The confirmations
  "blocktime" : xxx,                 (numeric) The block time expressed in UNIX epoch time
  "time" : n                         (numeric) Same as "blocktime"
}

Request example

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "getrawtransaction",
      "params": ["c7f32887779200fec23a0f4ebe73bed003f9ab8a46c2b549320c3c5cb78c7dc9", false, "000000000000000000034e30310c8bf30133e41ae3ae189f987e509901409bf7"]
}'

Response example

{
    "result": "010000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff560327df0c194d696e656420627920416e74506f6f6c20d1001e027fbb47f4fabe6d6de0c279796c6962fedcf285c9d73b2db2bdbf613053c23bde86fbfd601dcb857f10000000000000000000a0a91100000000000000ffffffff05220200000000000017a91442402a28dd61f2718a4b27ae72a4791d5bbdade787e380d0130000000017a9145249bdf2c131d43995cff42e8feee293f79297a8870000000000000000266a24aa21a9edbec170280a56f035b0341dbbddd94bb6e7980831c83800833367122d7aa839dc00000000000000002f6a2d434f524501a37cf4faa0758b26dca666f3e36d42fa15cc01064e3ecda72cb7961caa4b541b1e322bcfe0b5a03000000000000000002b6a2952534b424c4f434b3a4a651ea38b372994e3ba5f22984412606c1f031ea133168998896e280060d9d20120000000000000000000000000000000000000000000000000000000000000000000000000",
    "error": null,
    "id": "test"
}

joinpsbts

Joins multiple distinct PSBTs with different inputs and outputs into one PSBT.

Joins multiple distinct PSBTs with different inputs and outputs into one PSBT with inputs and outputs from all of the PSBTs. No input in any of the PSBTs can be in more than one of the PSBTs.

joinpsbts ["psbt",...]

Parameters


  • id (string; required): a request ID (example: test).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • <txs> (array of strings; required): the base64 strings of partially signed transactions.

      [
        "psbt",    (string, required) A base64 string of a PSBT
        ...
      ]

Returns

The base64-encoded partially signed transaction.

Request example

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "joinpsbts",
      "params": ["my-spbt1", "my-spbt2", "my-spbt3"]
}'

sendrawtransaction

Submits 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.

sendrawtransaction "hexstring" ( maxfeerate )

Parameters


  • id (string; required): a request ID (example: test).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • <hexstring> (string; required): the hex string of the raw transaction.
    • <maxfeerate> (numeric/string; optional; default=0.10): rejects transactions whose fee rate is higher than the specified value, expressed in BTC/kB. Set to 0 to accept any fee rate.

Returns

The transaction hash in hex.

Request example

Create a transaction:

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "createrawtransaction",
      "params": [[{"txid":"b6f6991d5f1548f957aa29c2b9a11297ae303fa205a72880a4d7b77e1b9f7c7e","vout":0}], {"1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa":0.01}]
}'

Sign the transaction, and get back the hex:

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "signrawtransactionwithwallet",
      "params": ["0200000001b6f6991d5f1548f957aa29c2b9a11297ae303fa205a72880a4d7b77e1b9f7c7e0000000000ffffffff0100f2052a010000001976a91489abcdefabbaabbaabbaabbaabbaabbaabbaabba88ac00000000"]
}'

Send the transaction (signed hex):

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "sendrawtransaction",
      "params": ["0200000001b6f6991d5f1548f957aa29c2b9a11297ae303fa205a72880a4d7b77e1b9f7c7e010000006a47304402203b8e51e8ee7a9f23f7c7ea3a73a9b7d9fda7914f7f7d433c9a9e6efad0706e9f022073c405f2beed367d9

testmempoolaccept

Returns result of mempool acceptance tests.

Returns result of mempool acceptance tests indicating if raw transaction (serialized, hex-encoded) would be accepted by mempool.

This checks if the transaction violates the consensus or policy rules.

See sendrawtransaction call.

testmempoolaccept ["rawtx",...] ( maxfeerate )

Parameters


  • id (string; required): a request ID (example: test).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • <rawtxs> (array of strings; required): an array of hex strings of raw transactions.

      [
        "rawtx",    (string)
        ...
      ]
    • <maxfeerate> (numeric/string; optional; default=0.10): rejects transactions whose fee rate is higher than the specified value, expressed in BTC/kB.

Returns

[                               (json array) The result of the mempool acceptance test for each raw transaction in the input array.
                                Length is exactly one for now.
  {                             (json object)
    "txid" : "hex",             (string) The transaction hash in hex
    "allowed" : true|false,     (boolean) If the mempool allows this tx to be inserted
    "vsize" : n,                (numeric) Virtual transaction size as defined in BIP 141. This is different from actual serialized size for witness transactions as witness data is discounted (only present when 'allowed' is true)
    "fees" : {                  (json object) Transaction fees (only present if 'allowed' is true)
      "base" : n                (numeric) transaction fee in BTC
    },
    "reject-reason" : "str"     (string) Rejection string (only present when 'allowed' is false)
  },
  ...
]

Request example

Create a transaction:

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "createrawtransaction",
      "params": [[{"txid":"b6f6991d5f1548f957aa29c2b9a11297ae303fa205a72880a4d7b77e1b9f7c7e","vout":0}], {"1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa":0.01}]
}'

Sign the transaction, and get back the hex:

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "signrawtransactionwithwallet",
      "params": ["0200000001b6f6991d5f1548f957aa29c2b9a11297ae303fa205a72880a4d7b77e1b9f7c7e0000000000ffffffff0100f2052a010000001976a91489abcdefabbaabbaabbaabbaabbaabbaabbaabba88ac00000000"]
}'

Test acceptance of the transaction (signed hex):

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "testmempoolaccept",
      "params": [["0200000001b6f6991d5f1548f957aa29c2b9a11297ae303fa205a72880a4d7b77e1b9f7c7e010000006a47304402203b8e51e8ee7a9f23f7c7ea3a73a9b7d9fda7914f7f7d433c9a9e6efad0706e9f022073c405f2beed367d9f7ee5e8e6a4e5e5c595cf1fa2b3b5dc74db9b2a36d4e7ec012102f3b5c0e7322d3e72d40c7f6b3fd8b1ab3141574a63eefa9a098c4b0be1dbb5e4ffffffff0100f2052a010000001976a91489abcdefabbaabbaabbaabbaabbaabbaabbaabba88ac00000000"]]
}'

Reponse example

{
    "result": [
        {
            "txid": "077e6ae456a9d84b4bc85aa782121e8b725031178595326d4df078927a66e998",
            "wtxid": "077e6ae456a9d84b4bc85aa782121e8b725031178595326d4df078927a66e998",
            "allowed": false,
            "reject-reason": "missing-inputs"
        }
    ],
    "error": null,
    "id": "test"
}

utxoupdatepsbt

Updates all segwit inputs and outputs in a PSBT with data from output descriptors, the UTXO set, or the mempool.

utxoupdatepsbt "psbt" ( ["",{"desc":"str","range":n or [n,n]},...] )

Parameters


  • id (string; required): a request ID (example: test).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • <psbt> (string; required): a base64 string of a PSBT.

    • <descriptors> (array; optional): an array of either strings or objects.

      [
        "",                       (string) An output descriptor
        {                         (json object) An object with an output descriptor and extra information
          "desc": "str",          (string, required) An output descriptor
          "range": n or [n,n],    (numeric or array, optional, default=1000) Up to what index HD chains should be explored (either end or [begin,end])
        },
        ...
      ]

Returns

The base64-encoded partially signed transaction with inputs updated.

Request example

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "utxoupdatepsbt",
      "params": ["cHNidP8BAFUCAAAAATK/5HXt1hQqK9Sy/NYfp/TPW/RZlM5LbV0v76TH56nhAAAAAAD9////AUBCDwAAAAAAGXapFGLpB7FcvyfVQlOZ6/bw+1DruI8YiKwAAAAAAAAA"]
}'

Response example

{
    "result": "cHNidP8BAFUCAAAAATK/5HXt1hQqK9Sy/NYfp/TPW/RZlM5LbV0v76TH56nhAAAAAAD9////AUBCDwAAAAAAGXapFGLpB7FcvyfVQlOZ6/bw+1DruI8YiKwAAAAAAAAA",
    "error": null,
    "id": "test"
}

Util RPCs

estimatesmartfee

Estimates the approximate fee.

Estimates the approximate fee per kilobyte needed for a transaction to begin confirmation within conf_target blocks if possible and return the number of blocks for which the estimate is valid. Uses virtual transaction size as defined in BIP 141 (witness data is discounted).

estimatesmartfee conf_target ( "estimate_mode" )

Parameters


  • id (string; required): a request ID (example: test).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • <conf_target> (numeric; required): confirmation target in blocks (1 - 1008).
    • <estimate_mode> (string; optional; default=CONSERVATIVE): the fee estimate mode. Whether to return a more conservative estimate which also satisfies a longer history. A conservative estimate potentially returns a higher feerate and is more likely to be sufficient for the desired target, but is not as responsive to short term drops in the prevailing fee market. Must be one of: “UNSET” “ECONOMICAL” “CONSERVATIVE”.

Returns

{                   (json object)
  "feerate" : n,    (numeric, optional) estimate fee rate in BTC/kB (only present if no errors were encountered)
  "errors" : [      (json array, optional) Errors encountered during processing (if there are any)
    "str",          (string) error
    ...
  ],
  "blocks" : n      (numeric) block number where estimate was found
                    The request target will be clamped between 2 and the highest target
                    fee estimation is able to return based on how long it has been running.
                    An error is returned if not enough transactions and blocks
                    have been observed to make an estimate for any number of blocks.
}

Request example

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "estimatesmartfee",
      "params": [6]
}'

Response example

{
    "result": {
        "feerate": 0.00012296,
        "blocks": 6
    },
    "error": null,
    "id": "test"
}

getindexinfo

Returns the status of one or all available indices currently running in the node.

getindexinfo ( "index_name" )

Parameters


  • id (string; required): a request ID (example: test).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • <txindex> (string; optional): filters results for an index with a specific name.

Returns

{                               (json object)
  "name" : {                    (json object) The name of the index
    "synced" : true|false,      (boolean) Whether the index is synced or not
    "best_block_height" : n     (numeric) The block height to which the index is synced
  }
}

Request example

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "getindexinfo",
      "params": ["txindex"]
}'

validateaddress

Returns information about the given bitcoin address.

validateaddress "address"

Parameters


  • id (string; required): a request ID (example: test).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • <address> (string; required): the Bitcoin address to validate.

Returns

{                               (json object)
  "isvalid" : true|false,       (boolean) If the address is valid or not. If not, this is the only property returned.
  "address" : "str",            (string) The bitcoin address validated
  "scriptPubKey" : "hex",       (string) The hex-encoded scriptPubKey generated by the address
  "isscript" : true|false,      (boolean) If the key is a script
  "iswitness" : true|false,     (boolean) If the address is a witness address
  "witness_version" : n,        (numeric, optional) The version number of the witness program
  "witness_program" : "hex"     (string, optional) The hex value of the witness program
}

Request example

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "validateaddress",
      "params": ["bc1qw4e2dl3pfw6nzxrzpghrtnpx7y8kyj7vg09qlh"]
}'

Response example

{
    "result": {
        "isvalid": false,
        "error_locations": [
            35,
            36
        ],
        "error": "Invalid Bech32 checksum"
    },
    "error": null,
    "id": "test"
}

verifymessage

Verifies a signed message.

verifymessage "address" "signature" "message"

Parameters


  • id (string; required): a request ID (example: test).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • <address> (string; required): the Bitcoin address to use for the signature.
    • <signature> (string; required): the signature provided by the signer in base 64 encoding (see signmessage).
    • <message> (string; required): the message that was signed.

Returns

If the signature is verified or not.

Request example

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "verifymessage",
      "params": ["1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX", "signature", "my message"]
}'

Wallet RPCs

The wallet RPCs are only available if Bitcoin Core was built with wallet support, which is the default.

getaddressinfo

Returns information about the given Bitcoin address.

Some information will only be present if the address is in the active wallet.

getaddressinfo "address"

Parameters


  • id (string; required): a request ID (example: test).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • <address> (string; required): the Bitcoin address for which to get information.

Returns

{                                   (json object)
  "address" : "str",                (string) The bitcoin address validated.
  "scriptPubKey" : "hex",           (string) The hex-encoded scriptPubKey generated by the address.
  "ismine" : true|false,            (boolean) If the address is yours.
  "iswatchonly" : true|false,       (boolean) If the address is watchonly.
  "solvable" : true|false,          (boolean) If we know how to spend coins sent to this address, ignoring the possible lack of private keys.
  "desc" : "str",                   (string, optional) A descriptor for spending coins sent to this address (only when solvable).
  "isscript" : true|false,          (boolean) If the key is a script.
  "ischange" : true|false,          (boolean) If the address was used for change output.
  "iswitness" : true|false,         (boolean) If the address is a witness address.
  "witness_version" : n,            (numeric, optional) The version number of the witness program.
  "witness_program" : "hex",        (string, optional) The hex value of the witness program.
  "script" : "str",                 (string, optional) The output script type. Only if isscript is true and the redeemscript is known. Possible
                                    types: nonstandard, pubkey, pubkeyhash, scripthash, multisig, nulldata, witness_v0_keyhash,
                                    witness_v0_scripthash, witness_unknown.
  "hex" : "hex",                    (string, optional) The redeemscript for the p2sh address.
  "pubkeys" : [                     (json array, optional) Array of pubkeys associated with the known redeemscript (only if script is multisig).
    "str",                          (string)
    ...
  ],
  "sigsrequired" : n,               (numeric, optional) The number of signatures required to spend multisig output (only if script is multisig).
  "pubkey" : "hex",                 (string, optional) The hex value of the raw public key for single-key addresses (possibly embedded in P2SH or P2WSH).
  "embedded" : {                    (json object, optional) Information about the address embedded in P2SH or P2WSH, if relevant and known.
    ...                             Includes all getaddressinfo output fields for the embedded address, excluding metadata (timestamp, hdkeypath, hdseedid)
                                    and relation to the wallet (ismine, iswatchonly).
  },
  "iscompressed" : true|false,      (boolean, optional) If the pubkey is compressed.
  "timestamp" : xxx,                (numeric, optional) The creation time of the key, if available, expressed in UNIX epoch time.
  "hdkeypath" : "str",              (string, optional) The HD keypath, if the key is HD and available.
  "hdseedid" : "hex",               (string, optional) The Hash160 of the HD seed.
  "hdmasterfingerprint" : "hex",    (string, optional) The fingerprint of the master key.
  "labels" : [                      (json array) Array of labels associated with the address. Currently limited to one label but returned
                                    as an array to keep the API stable if multiple labels are enabled in the future.
    "str",                          (string) Label name (defaults to "").
    ...
  ]
}

Request example

curl -X POST https://rpc.ankr.com/btc \
-d '{
      "id": "test",
      "method": "getaddressinfo",
      "params": ["bc1q09vm5lfy0j5reeulh4x5752q25uqqvz34hufdl"]
}'