BitcoinMethods

getrawmempool

The getrawmempool retrieves all transaction IDs currently held in the memory pool utilizing the getrawmempool RPC method. This method presents the data as a JSON array containing string transaction...

getrawmempool

Overview

The 'getrawmempool' retrieves all transaction IDs currently held in the memory pool utilizing the 'getrawmempool' RPC method. This method presents the data as a JSON array containing string transaction IDs.

Request

shell

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":"2.0","id":1,"method":"getrawmempool","params": [ ]}' \
   'https://bitcoin-mainnet.node.coinapi.io'

csharp

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("{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"getrawmempool\",\"params\": [ ]}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

php

<?php
$client = new Client();
$headers = [
  'Content-Type' => 'application/json',
  'accept' => 'application/json',
  'X-CoinAPI-Key' => '73034021-THIS-IS-SAMPLE-KEY'
];
$body = '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getrawmempool",
  "params": []
}';
$request = new Request('POST', 'https://bitcoin-mainnet.node.coinapi.io', $headers, $body);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();

?>

python

import http.client
import json

conn = http.client.HTTPSConnection("mainnet-bitcoin.node.coinapi.io")
payload = json.dumps({
"jsonrpc": "2.0",
"id": 1,
"method": "getrawmempool",
"params": []
})
headers = {
'Content-Type': 'application/json',
'accept': 'application/json',
'X-CoinAPI-Key': '73034021-THIS-IS-SAMPLE-KEY'
}
conn.request("POST", "/", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

javascript

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": "2.0",
    "id": 1,
    "method": "getrawmempool",
    "params": []
  }),
};

$.ajax(settings).done(function (response) {
  console.log(response);
});

go

package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

url := "https://bitcoin-mainnet.node.coinapi.io"
method := "POST"

payload := strings.NewReader(`{"jsonrpc":"2.0","id":1,"method":"getrawmempool","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))
}

ruby

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": "2.0",
"id": 1,
"method": "getrawmempool",
"params": []
})

response = https.request(request)
puts response.read_body

java

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"getrawmempool\",\"params\": [ ]}");
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

verbose (Boolean)

  • Default: 'false'
  • When set to 'true', it returns a JSON object. Conversely, when set to false, it returns an array of transaction IDs.

mempool_sequence (Boolean)

  • Default: 'false'
  • If true, the return will include a JSON object containing the transaction list along with an associated mempool sequence number.

Response

Response when verbose is true:

{
  "transactionid": "12345abcdef12345abcdef12345abcdef12345abcdef12345abcdef12345abcdef",
  "vsize": 567,
  "weight": 1234,
  "time": 1677745678,
  "height": 678901,
  "descendantcount": 3,
  "descendantsize": 789,
  "ancestorcount": 2,
  "ancestorsize": 456,
  "wtxid": "abcdef12345abcdef12345abcdef12345abcdef12345abcdef12345abcdef123",
  "fees": {
    "base": 0.00012345,
    "modified": 0.00012356,
    "ancestor": 0.00012367,
    "descendant": 0.00012378
  },
  "depends": ["txid1", "txid2"],
  "hex": "abcdef12345abcdef12345",
  "spentby": ["txid3", "txid4"],
  "hex": "abcdef12345abcdef12346",
  "bip125-replaceable": true,
  "unbroadcast": false,
  "error": null
}
{
  "txids": [
    "abcdef12345abcdef12345abcdef12345abcdef12345abcdef12345abcdef123",
    "12345abcdef12345abcdef12345abcdef12345abcdef12345abcdef12345abcdef"
  ],
  "hex": "abcdef12345abcdef12346",
  "mempool_sequence": 12345
}

When verbose is true:

  • transactionid: Identifies the transaction.
  • vsize: The virtual transaction size as detailed in BIP 141, different from the actual serialized size for witness transactions due to the discounted witness data.
  • weight: The transaction weight, as prescribed in BIP 141.
  • time: Records the local time the transaction entered the pool, denoted in seconds since January 1, 1970 (GMT).
  • height: Indicates the block height at the time the transaction entered the pool.
  • descendantcount: Counts the number of in-mempool descendant transactions (including the current transaction).
  • descendantsize: Calculates the virtual transaction size of the in-mempool descendants (including the current transaction).
  • ancestorcount: Counts the number of in-mempool ancestor transactions (including the current transaction).
  • ancestorsize: Calculates the virtual transaction size of the in-mempool ancestors (including the current transaction).
  • wtxid: Represents the hash of the serialized transaction, including witness data.
  • fees: A JSON object encapsulating details about the transaction fee paid by the transaction, including:
    • base: Transaction fee in BTC.
    • modified: Transaction fee with fee deltas used for mining priority, measured in BTC.
    • ancestor: Modified fees of in-mempool ancestors (inclusive) in BTC.
    • descendant: Modified fees of in-mempool descendants (inclusive) in BTC.
  • depends: Lists unconfirmed transactions used as inputs for the current transaction.
  • hex: Displays the parent transaction ID.
  • spentby: Notes unconfirmed transactions that are utilizing outputs from the current transaction.
  • hex: Exhibits the child transaction ID.
  • bip125-replaceable: Denotes whether the transaction can be replaced according to BIP125 (replace-by-fee).
  • unbroadcast: Marks if the transaction is currently unbroadcast (no initial broadcast acknowledgment from peers).
  • error: If applicable, displays an error message.

When verbose is false:

  • txids: A JSON array containing transaction IDs.
  • hex: Specifies the transaction ID.
  • mempool_sequence: Denotes the mempool sequence value.
Service StatusGitHub SDK