Skip to main content

Decodescript

Overview

The decodescript RPC method allows you to decode a hex-encoded script, facilitating a deeper understanding of the script's structure and components. Each call to this method will consume 1 API credit.

Request

wget --no-check-certificate --quiet \
--method POST \
--timeout=0 \
--header 'Content-Type: application/json' \
--header 'accept: application/json' \
--header 'X-CoinAPI-Key: 73034021-THIS-IS-SAMPLE-KEY' \
--body-data '{
"jsonrpc": "1.0",
"id": "1",
"method": "Decodescript",
"params": []
}' \ 'https://bitcoin-mainnet.node.coinapi.io'

Parameters

'hexstring' (required)

  • Type: string
  • Description: The hex-encoded script that needs to be decoded.

Returns

The method returns an object with the following properties:

'asm'

  • Type: string
  • Description: Represents the script public key in a string format.

type

  • Type: string
  • Description: Specifies the output type. It can be one of the following: nonstandard, pubkey, pubkeyhash, scripthash, multisig, nulldata, witness_v0_scripthash, witness_v0_keyhash, witness_v1_taproot, or witness_unknown.

reqSigs

  • Type: integer
  • Description: Indicates the number of required signatures.

addresses

  • Type: JSON array
  • Description: A JSON array containing the addresses involved in the transaction.

str

  • Type: string
  • Description: The Bitcoin address associated with the script.

p2sh

  • type: string (optional)
  • Description: The address of the P2SH script that wraps this redeem script. This field is not returned if the script is already a P2SH.

segwit

  • Type: object (optional)

  • Description: Contains information about the witness script public key that wraps this redeem script. This field is not returned if the script is a P2SH or witness. The object contains the following properties:

    • 'asm': The script public key in string format.
    • 'hex': The hex representation of the script's public key in string format.
    • 'type': The type of the script public key.
    • 'reqSigs': The number of required signatures.
    • 'addresses': A JSON array of addresses involved.
    • 'str': The segwit address.
    • 'p2sh-segwit': The address of the P2SH script wrapping this witness redeem script.