BitcoinMethods

getmempoolancestors

The getmempoolancestors RPC Method returns all in-mempool ancestors for a transaction in the mempool.

getmempoolancestors

Overview

The 'getmempoolancestors' RPC Method returns all in-mempool ancestors for a transaction in the mempool.

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","method":"getmempoolancestors","params": [],"id":1}' \
   '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\",\"method\":\"getmempoolancestors\",\"params\": [],\"id\":1}", 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",
  "method": "getmempoolancestors",
  "params": [],
  "id": 1
}';
$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",
"method": "getmempoolancestors",
"params": [],
"id": 1
})
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",
    "method": "getmempoolancestors",
    "params": [],
    "id": 1
  }),
};

$.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","method":"getmempoolancestors","params": [],"id":1}`)

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

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

txid (string, required): The transaction id, and it must be in mempool verbose (string): default=false. It's true for a JSON object and false for array of transaction ids

Response

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": 1234567.890123
}

(for verbose = false) hex: The transaction id of an in-mempool ancestor transaction (for verbose = true) transactionid: The transaction id vsize: The virtual transaction size as defined in BIP 141. This is different from actual serialized size for witness transactions as witness data is discounted weight: The transaction weight as defined in BIP 141 time: The local time transaction entered pool in seconds since 1 Jan 1970 GMT height: The block height when the transaction entered pool descendantcount: The number of in-mempool descendant transactions (including this one) descendantsize: The virtual transaction size of in-mempool descendants (including this one) ancestorcount: The number of in-mempool ancestor transactions (including this one) wtxid: The hash of serialized transaction, including witness data fees: A JSON array containing information about the transaction fee paid by the transaction base: The transaction fee in BTC modified: The transaction fee with fee deltas used for mining priority in BTC ancestor: The modified fees of in-mempool ancestors (including this one) in BTC descendant: The modified fees of in-mempool descendants (including this one) in BTC depends: Unconfirmed transactions used as inputs for this transaction hex: The parent transaction id spentby: Unconfirmed transactions spending outputs from this transaction hex: The child transaction id bip125-replaceable: Whether this transaction could be replaced due to BIP125 (replace-by-fee) unbroadcast: Whether this transaction is currently unbroadcast (initial broadcast not yet acknowledged by any peers)

Service StatusGitHub SDK