0

I would like to find out the immediate last transaction of addressA.

But so far, I can only do this, bit-li gettransaction <txid> then bit-cli decoderawtransaction <hex>

But I want to do something like this:

bit-cli lasttransactionto <addressA>

How can I do that, without knowing the tx id??

0

Bitcoind doesn't index by address, but you can scan the uxto set for outpoints which are spent to the address of interest:

Alternatively, Libbitcoin-server indexes all transactions by address per default:

  • Thank you, I think, I will download libbitcoin but right now, I am doing it like this, but I am not sure if it is good approach or not, curl https://localhost/api/addr/<AddressA> | python -m json.tool | grep -A1 transactions | grep -v transactions | tr -d ',\" ' then, as usual like before bit-cli gettransaction <lastoutput> then, bit-cli decoderawtransaction <hex> | grep -A1 addresses | grep -v addresses | tr -d '" -' | grep -v AddressB | tail -1 – Rakib Fiha Feb 4 at 18:26
  • You can also import the address as watch-only into the wallet (using importaddress) in Bitcoin Core, and have the wallet rescan the chain for relevant transactions. – Pieter Wuille Feb 6 at 5:42
  • @PieterWuille Ah yes, as chris belchers electrum personal server does... – James C. Feb 6 at 7:48
  • Rescanning the entire chain takes a long time, doesn't it? The problem I am having with my approach is that, if my address (to addr) gets exposed then spammer may flood my address with thousands of small amount of tx. Then, my code will be unable to pick up the right address(from addr). I know there are solutions out there but I dont know how to do it. haha – Rakib Fiha Feb 11 at 7:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.