From e91229a9f707e02328ab1cab35dff4c13fdc0242 Mon Sep 17 00:00:00 2001 From: "martin.zemanek" Date: Tue, 21 May 2024 13:51:15 +0200 Subject: [PATCH 1/2] BTC RPC docs update --- .../rpc-btc/rpc-btc-createrawtransaction.md | 120 ++++++++++++++ .../rpc-btc/rpc-btc-decoderawtransaction.md | 151 ++++++++++++++++++ 2 files changed, 271 insertions(+) create mode 100644 v1.0/RPC Nodes/rpc-utxo/rpc-btc/rpc-btc-createrawtransaction.md create mode 100644 v1.0/RPC Nodes/rpc-utxo/rpc-btc/rpc-btc-decoderawtransaction.md diff --git a/v1.0/RPC Nodes/rpc-utxo/rpc-btc/rpc-btc-createrawtransaction.md b/v1.0/RPC Nodes/rpc-utxo/rpc-btc/rpc-btc-createrawtransaction.md new file mode 100644 index 00000000..75c7a5e0 --- /dev/null +++ b/v1.0/RPC Nodes/rpc-utxo/rpc-btc/rpc-btc-createrawtransaction.md @@ -0,0 +1,120 @@ +--- +title: "createrawtransaction" +slug: "rpc-btc-createrawtransaction" +excerpt: "Bitcoin RPC" +hidden: false +metadata: + description: "Bitcoin RPC" + image: [] + keywords: "btc, rpc" + robots: "index" +createdAt: "Wed Mar 06 2024 10:35:44 GMT+0000 (Coordinated Universal Time)" +updatedAt: "Sat Apr 06 2024 14:43:58 GMT+0000 (Coordinated Universal Time)" +--- +[block:html] +{ + "html": "
\n
Archive Method
\n

Only on the full archive nodes. Complex queries might take longer and incur additional cost

\n
" +} +[/block] + + +### How to use it + + + +```typescript +// yarn add @tatumio/tatum + +import { TatumSDK, Bitcoin, Network } from '@tatumio/tatum' + +const tatum = await TatumSDK.init({network: Network.BITCOIN}) + +const result = await tatum.rpc.createRawTransaction([ + { + "txid": "abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234", + "vout": 0 + } + ], + { + "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa": 0.01 + }) + +await tatum.destroy() // Destroy Tatum SDK - needed for stopping background jobs +``` + + + +### Overview + +The `createrawtransaction` RPC method creates an unsigned raw transaction that spends a set of previous transaction outputs to a set of new addresses with specific amounts. The method can be used to create custom transactions, which can then be signed and broadcast to the Bitcoin network. + +[block:embed] +{ + "html": false, + "url": "https://codepen.io/tatum-devrel/pen/oNQarzo", + "href": "https://codepen.io/tatum-devrel/pen/oNQarzo", + "typeOfEmbed": "iframe", + "height": "300px", + "width": "100%", + "iframe": true, + "provider": "codepen.io" +} +[/block] + +### Parameters + +- `inputs`: (array, required) An array of objects, each specifying a previous transaction output to spend. + - `txid`: (string, required) The transaction ID of the previous transaction output to spend. + - `vout`: (numeric, required) The index of the output to spend from the previous transaction. + - `sequence`: (numeric, optional) default=depends on the value of the 'replaceable' and 'locktime' arguments) The sequence number +- `outputs`: (object, required) An object with the key-value pairs representing the receiving address and the amount to be sent (in BTC). +- `locktime`: (numeric, optional, default=0) The lock time for the transaction. It can be used to specify the earliest time or block height at which the transaction can be included in a block. +- `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. + +### Return Object + +- (string) A hex-encoded raw transaction. + +### JSON Examples + +Request example: + +{% code overflow="wrap" lineNumbers="true" %} + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "createrawtransaction", + "params": [ + [ + { + "txid": "abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234", + "vout": 0 + } + ], + { + "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa": 0.01 + } + ] +} +``` + +{% endcode %} + +Response example: + +{% code overflow="wrap" lineNumbers="true" %} + +```json +{ + "result": "02000000013412cdab3412cdab3412cdab3412cdab3412cdab3412cdab3412cdab3412cdab0000000000fdffffff0140420f00000000001976a91462e907b15cbf27d5425399ebf6f0fb50ebb88f1888ac00000000", + "error": null, + "id": 1 +} + +``` + +{% endcode %} + +\\ diff --git a/v1.0/RPC Nodes/rpc-utxo/rpc-btc/rpc-btc-decoderawtransaction.md b/v1.0/RPC Nodes/rpc-utxo/rpc-btc/rpc-btc-decoderawtransaction.md new file mode 100644 index 00000000..6d9bd89e --- /dev/null +++ b/v1.0/RPC Nodes/rpc-utxo/rpc-btc/rpc-btc-decoderawtransaction.md @@ -0,0 +1,151 @@ +--- +title: "decoderawtransaction" +slug: "rpc-btc-decoderawtransaction" +excerpt: "Bitcoin RPC" +hidden: false +metadata: + description: "Bitcoin RPC" + image: [] + keywords: "btc, rpc" + robots: "index" +createdAt: "Wed Mar 06 2024 10:35:44 GMT+0000 (Coordinated Universal Time)" +updatedAt: "Sat Apr 06 2024 14:43:58 GMT+0000 (Coordinated Universal Time)" +--- +[block:html] +{ + "html": "
\n
Archive Method
\n

Only on the full archive nodes. Complex queries might take longer and incur additional cost

\n
" +} +[/block] + + +### How to use it + + + +```typescript +// yarn add @tatumio/tatum + +import { TatumSDK, Bitcoin, Network } from '@tatumio/tatum' + +const tatum = await TatumSDK.init({network: Network.BITCOIN}) + +const result = await tatum.rpc.decodeRawTransaction("02000000013412cdab3412cdab3412cdab3412cdab3412cdab3412cdab3412cdab3412cdab0000000000fdffffff0140420f00000000001976a91462e907b15cbf27d5425399ebf6f0fb50ebb88f1888ac00000000") + +await tatum.destroy() // Destroy Tatum SDK - needed for stopping background jobs +``` + + + +### Overview + +The `decoderawtransaction` RPC method decodes a serialized (hex-encoded) raw transaction and displays its information in a human-readable format. This method is useful for inspecting raw transactions before broadcasting them to the Bitcoin network or for debugging purposes. + +[block:embed] +{ + "html": false, + "url": "https://codepen.io/tatum-devrel/pen/xxQMegr", + "href": "https://codepen.io/tatum-devrel/pen/xxQMegr", + "typeOfEmbed": "iframe", + "height": "300px", + "width": "100%", + "iframe": true, + "provider": "codepen.io" +} +[/block] + +### Parameters + +- `hex_string`: (string, required) The serialized raw transaction in hex format. + +### Return Object + +An object containing the decoded raw transaction information: + +- `txid`: (string) The transaction ID. +- `hash`: (string) The transaction hash. +- `version`: (numeric) The transaction version. +- `size`: (numeric) The transaction size in bytes. +- `vsize`: (numeric) The virtual transaction size in bytes. +- `weight`: (numeric) The transaction weight. +- `locktime`: (numeric) The lock time for the transaction. +- `vin`: (array) An array of objects, each representing an input of the transaction. + - `txid`: (string) The transaction ID of the previous transaction output to spend. + - `vout`: (numeric) The index of the output to spend from the previous transaction. + - `scriptSig`: (object) The script used to redeem the previous transaction output. + - `asm`: (string) The assembly representation of the script. + - `hex`: (string) The hex-encoded script. + - `sequence`: (numeric) The sequence number. +- `vout`: (array) An array of objects, each representing an output of the transaction. + - `value`: (numeric) The amount sent to the output. + - `n`: (numeric) The index of the output. + - `scriptPubKey`: (object) The script used to lock the output. + - `asm`: (string) The assembly representation of the script. + - `hex`: (string) The hex-encoded script. + - `reqSigs`: (numeric) The required number of signatures. + - `type`: (string) The type of the script (e.g., 'pubkeyhash'). + - `addresses`: (array) An array of Bitcoin addresses associated with the output. + +### JSON Examples + +Request example: + +{% code overflow="wrap" lineNumbers="true" %} + +```json +{ + "jsonrpc": "2.0", + "method": "decoderawtransaction", + "params": ["02000000013412cdab3412cdab3412cdab3412cdab3412cdab3412cdab3412cdab3412cdab0000000000fdffffff0140420f00000000001976a91462e907b15cbf27d5425399ebf6f0fb50ebb88f1888ac00000000"], + "id": 1 +} +``` + +{% endcode %} + +Response example: + +{% code overflow="wrap" lineNumbers="true" %} + +```json +{ + "result": { + "txid": "9f5f5e6d36b6a284f52626be505175e43900009e7aa1b88fce74fcd30f0dc258", + "hash": "9f5f5e6d36b6a284f52626be505175e43900009e7aa1b88fce74fcd30f0dc258", + "version": 2, + "size": 85, + "vsize": 85, + "weight": 340, + "locktime": 0, + "vin": [ + { + "txid": "abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234", + "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": 1 +} +``` + +{% endcode %} + +\\ From b9af9305ea67d5dfd56b422d2c586b3ce50a7589 Mon Sep 17 00:00:00 2001 From: "martin.zemanek" Date: Tue, 21 May 2024 13:51:15 +0200 Subject: [PATCH 2/2] update categories --- v1.0/RPC Nodes/rpc-utxo/rpc-btc/rpc-btc-createrawtransaction.md | 1 + v1.0/RPC Nodes/rpc-utxo/rpc-btc/rpc-btc-decoderawtransaction.md | 1 + 2 files changed, 2 insertions(+) diff --git a/v1.0/RPC Nodes/rpc-utxo/rpc-btc/rpc-btc-createrawtransaction.md b/v1.0/RPC Nodes/rpc-utxo/rpc-btc/rpc-btc-createrawtransaction.md index 75c7a5e0..a8b1a33f 100644 --- a/v1.0/RPC Nodes/rpc-utxo/rpc-btc/rpc-btc-createrawtransaction.md +++ b/v1.0/RPC Nodes/rpc-utxo/rpc-btc/rpc-btc-createrawtransaction.md @@ -2,6 +2,7 @@ title: "createrawtransaction" slug: "rpc-btc-createrawtransaction" excerpt: "Bitcoin RPC" +category: "6620f7e31ea673003624a8ce" hidden: false metadata: description: "Bitcoin RPC" diff --git a/v1.0/RPC Nodes/rpc-utxo/rpc-btc/rpc-btc-decoderawtransaction.md b/v1.0/RPC Nodes/rpc-utxo/rpc-btc/rpc-btc-decoderawtransaction.md index 6d9bd89e..1c795ed7 100644 --- a/v1.0/RPC Nodes/rpc-utxo/rpc-btc/rpc-btc-decoderawtransaction.md +++ b/v1.0/RPC Nodes/rpc-utxo/rpc-btc/rpc-btc-decoderawtransaction.md @@ -2,6 +2,7 @@ title: "decoderawtransaction" slug: "rpc-btc-decoderawtransaction" excerpt: "Bitcoin RPC" +category: "6620f7e31ea673003624a8ce" hidden: false metadata: description: "Bitcoin RPC"