Bitcoin Forum
May 22, 2024, 12:17:41 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Bitcoin RPC - How to get transaction history from a address  (Read 127 times)
?QuestionMark? (OP)
Member
**
Offline Offline

Activity: 79
Merit: 28


View Profile
December 23, 2020, 03:15:35 PM
Merited by Heisenberg_Hunter (1)
 #1

I'm currently working on a bitcoin blockchain explorer for personal use. Everything is working fine so far but I have problems to implement the possibility to search for addresses and list all made transactions. I'm using bitcoin rpc and PHP.

After some internet search I found the RPC command importaddress but I read that it would need to rescan the whole blockchain which takes to long. Then I found the command scantxouset which
lets me scan the txout's. But I can't figure out to use this command even after visiting several websites. I'm not very familiar with JSON.
One was: https://developer.bitcoin.org/reference/rpc/scantxoutset.html
Another problem is that this command can only search for unspent outputs.

Anyone has a idea how I can achieve to get all transactions made from a given address.

ranochigo
Legendary
*
Offline Offline

Activity: 2982
Merit: 4193



View Profile
December 23, 2020, 03:23:09 PM
Last edit: December 23, 2020, 04:04:23 PM by ranochigo
 #2

Bitcoin Core doesn't keep a transaction index of transactions that are not pertinent to the addresses generated by your client by default. By enabling txindex (txindex=1) will make Bitcoin Core build the transaction database index and index them for the transactions to be found easily.

But AFAIK, Bitcoin Core won't specifically calculate the balance or organise the TXes related to "all the addresses" because addresses isn't really represented as such in the protocol level. You can try crawling through the Blockchain and see if you can index them yourself.

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
?QuestionMark? (OP)
Member
**
Offline Offline

Activity: 79
Merit: 28


View Profile
December 23, 2020, 04:01:48 PM
 #3

Im using txindex=1 for searching for transactions. But as you said its just for transactions.
As you suggested I will maybe try to index it by myself and store it in an mysql database. I first have to find out how exactly I will do it but I think its the best way.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!