Tam Vo
Tam Vo

Reputation: 177

List transactions from given address in bitcoind

Is there anyway to list all transactions from given address by using API RPC to bitcoind? Actually, I'm using btcd and most non-wallet functions are the same with bitcoind, but I can't find any methods to do that.

Upvotes: 7

Views: 10963

Answers (4)

Blockchair API

A good API nowadays is Blockchair, e.g. to get all transactions with an output to 1MVpQJA7FtcDrwKC6zATkZvZcxqma4JixS which was the address of cryptograffiti.info by increasing date:

#!/usr/bin/env bash
set -eu
d=data/cryptograffiti-blockchair
i=0
# max allowed
limit=100
rm -rf "$d"
mkdir -p "$d"
while true; do
  f="$d/$i"
  echo curl "https://api.blockchair.com/bitcoin/outputs?offset=$((i * limit))&limit=$limit&s=time(asc)&q=recipient(1MVpQJA7FtcDrwKC6zATkZvZcxqma4JixS)"
  curl "https://api.blockchair.com/bitcoin/outputs?offset=$((i * limit))&limit=$limit&s=time(desc)&q=recipient(1MVpQJA7FtcDrwKC6zATkZvZcxqma4JixS)" | jq -r '.data[].transaction_hash' > "$f"
  if [ "$(wc -l "$f" | cut -f1 -d' ')" -lt "$limit" ]; then
    break
  fi
  i=$((i+1))
done
cat "$d"/* > data/cryptograffiti

You can build this interactively from the UI at: https://blockchair.com/bitcoin/outputs?s=time(desc)&q=recipient(1MVpQJA7FtcDrwKC6zATkZvZcxqma4JixS)

TODO: that was to address, find from address. There's on obvious corresponding "inputs" endpoint.

Tested on Ubuntu 23.10.

Upvotes: 0

leishman
leishman

Reputation: 1047

Due to the way the transactions are indexed you cannot perform this kind of query with Bitcoind, I'm assuming the case is the same for btcd.

If you would like to get this information, you have a few options:

  • Parse the Blockchain yourself and store the data in a new, more heavily-indexed DB
  • Use a 3rd party service like Chain.com or Blockchain.info
  • Run a different type of node. Toshi is an open source Ruby implementation of Bitcoin by Coinbase. The DB of this node allows for richer queries, but requires an order of magnitude more storage.

Edit: Toshi is no longer maintained and chain.com no longer provides this API afaik.

Upvotes: 7

Manan
Manan

Reputation: 93

btcd recently merged in a feature that creates an address index that can be used to query for specific address

https://github.com/btcsuite/btcd/issues/190

To enable this feature, run btcd with the addrindex flag, like so -

btcd --addrindex

Transactions can queried over RPC using the new searchrawtransactions rpc call. It takes a while to create the address index, so wait until it has completed indexing to be able to use this index

Upvotes: 2

user3122589
user3122589

Reputation:

As I know there is no method to list all transaction from given bitcoin address. But you can use account for that.

You can create one bitcoin address per account. And there is method to list all transactions for given account listtransactions.

Read more about account: https://en.bitcoin.it/wiki/Accounts_explained

Bitcoind API calls list: https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_Calls_list

Upvotes: 0

Related Questions