decodeRawTransaction
Overview
The 'decodeRawTransaction' method decodes a raw transaction and returns detailed information about the transaction in a JSON format. Utilizing this method will consume 1 API credit.
Request
- shell
- csharp
- php
- python
- javascript
- go
- ruby
- java
curl link \
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": "decodeRawTransaction",
"params": []
}' \
'https://bitcoin-mainnet.node.coinapi.io'
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://bitcoin-mainnet.node.coinapi.io");
request.Headers.Add("accept", "application/json");
request.Headers.Add("X-CoinAPI-Key", "73034021-THIS-IS-SAMPLE-KEY");
var content = new StringContent("{\r\n \"jsonrpc\": \"1.0\",\r\n \"id\": \"1\",\r\n \"method\": \"decodeRawTransaction\",\r\n \"params\": []\r\n}\r\n", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
<?php
$client = new Client();
$headers = [
'Content-Type' => 'application/json',
'accept' => 'application/json',
'X-CoinAPI-Key' => '73034021-THIS-IS-SAMPLE-KEY'
];
$body = '{
"jsonrpc": "1.0",
"id": "1",
"method": "decodeRawTransaction",
"params": []
}';
$request = new Request('POST', 'https://bitcoin-mainnet.node.coinapi.io', $headers, $body);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();
?>
import requests
import json
url = "https://bitcoin-mainnet.node.coinapi.io"
payload = json.dumps({
"jsonrpc": "1.0",
"id": "1",
"method": "decodeRawTransaction",
"params": []
})
headers = {
'Content-Type': 'application/json',
'accept': 'application/json',
'X-CoinAPI-Key': '73034021-THIS-IS-SAMPLE-KEY'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var settings = {
"url": "https://bitcoin-mainnet.node.coinapi.io",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/json",
"accept": "application/json",
"X-CoinAPI-Key": "73034021-THIS-IS-SAMPLE-KEY"
},
"data": JSON.stringify({
"jsonrpc": "1.0",
"id": "1",
"method": "decodeRawTransaction",
"params": []
}),
};
$.ajax(settings).done(function (response) {
console.log(response);
});
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://bitcoin-mainnet.node.coinapi.io"
method := "POST"
payload := strings.NewReader(`{`+"
"+`
"jsonrpc": "1.0",`+"
"+`
"id": "1",`+"
"+`
"method": "decodeRawTransaction",`+"
"+`
"params": []`+"
"+`
}`+"
"+`
`)
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("accept", "application/json")
req.Header.Add("X-CoinAPI-Key", "73034021-THIS-IS-SAMPLE-KEY")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
require "uri"
require "json"
require "net/http"
url = URI("https://bitcoin-mainnet.node.coinapi.io")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["accept"] = "application/json"
request["X-CoinAPI-Key"] = "73034021-THIS-IS-SAMPLE-KEY"
request.body = JSON.dump({
"jsonrpc": "1.0",
"id": "1",
"method": "decodeRawTransaction",
"params": []
})
response = https.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n \"jsonrpc\": \"1.0\",\r\n \"id\": \"1\",\r\n \"method\": \"decodeRawTransaction\",\r\n \"params\": []\r\n}\r\n");
Request request = new Request.Builder()
.url("https://bitcoin-mainnet.node.coinapi.io")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("accept", "application/json")
.addHeader("X-CoinAPI-Key", "73034021-THIS-IS-SAMPLE-KEY")
.build();
Response response = client.newCall(request).execute();
Request Parameters
- hexString (string, required): The raw transaction represented as a hex string.
- isWitness (boolean): Indicates whether the transaction hex is a serialized witness transaction. Accepts "true" or "false" values.
Response
-
txid: The unique identifier of the transaction.
-
hash: The hash of the transaction, which may vary from the txid for witness transactions.
-
size: The size of the transaction in bytes.
-
vsize: The virtual size of the transaction, which may differ from the "size" for witness transactions.
-
weight: The weight of the transaction, calculated as a value between vsize4 - 3 and vsize4.
-
version: The version of the block where the transaction is recorded.
-
locktime: The locktime of the transaction.
-
vin (JSON array): Contains information about the transaction's input vectors. Each element in the array represents an input vector and contains the following fields:
- txid: The transaction ID.
- vout: The output number.
- scriptSig: Contains information about the script's signature.
- asm: The script's public key as a string.
- hex: The hex-encoded witness data.
- txinwitness (JSON array): An array of JSON objects containing hex-encoded witness data.
- sequence: The script sequence number.
-
vout (JSON array): Contains information about the transaction outputs. Each element in the array contains:
- value: The value of the output in BTC.
- n: The output index.
- scriptPubKey (JSON object): Contains information about the PubKey script, including:
- asm: The script's public key as a string.
- desc: The inferred descriptor for the output.
- hex: The hex representation of the script's public key.
- address: The associated Bitcoin address.
- type: The type of script, such as pubkeyhash or multisig.
Errors
- Invalid Request: This error is returned if the request format is incorrect.
- Internal Error: This error is returned if there's a server-side issue processing the request.
Rate Limits
Please note that there are rate limits applied to the API to ensure fair usage. Free-tier users are limited to 100 requests per day, while premium users can make up to 1000 or more requests per day.
Support
If you encounter any issues or have further questions regarding the decodeRawTransaction method, please contact our support team at [email protected].