Coder Social home page Coder Social logo

Comments (7)

Stonica avatar Stonica commented on September 27, 2024 1

Thanks for your help

from libbitcoin-client.

evoskuil avatar evoskuil commented on September 27, 2024

It would be helpful if you could clarify "real time", since "all Bitcoin addresses" are a vast amount of historical data.

from libbitcoin-client.

evoskuil avatar evoskuil commented on September 27, 2024

In other words, if something has happened in the distant past, "real time" isn't a meaningful concept.

from libbitcoin-client.

Stonica avatar Stonica commented on September 27, 2024

"realtime" here:
I need to update my list of bitcoin addresses with positive balance just any address balance turned to zero or a new address got non-zero balance, as soon as possible.
It was better to say: I need a list of bitcoin addresses with non-zero balance which updates if any address balance is changed or new address got balance.

from libbitcoin-client.

evoskuil avatar evoskuil commented on September 27, 2024

That's helpful.

To obtain balances for all addresses, you need to query all addresses. There is an index of all addresses, with payments and therefore balance. You can query any address to obtain its balance. However there is no query to obtain all addresses. The only way to obtain all addresses is to query all transactions (which means all blocks).

Getting real-time changes is straightforward, you just subscribe to confirmed blocks or transactions. You will however have to handle the case of reorganization, since blocks/transactions can become unconfirmed.

from libbitcoin-client.

evoskuil avatar evoskuil commented on September 27, 2024

In Version3 you can query only standard addresses, basically p2sh and p2pkh. Version4 will support query for any type of payment, with or without any address format. But given your requirements, I would not query for addresses at all, I would simply query all blocks and then subscribe to new blocks (which includes reorgs).

I would then maintain a database of output scripts with an entry for each input and output against that script. To obtain balance you would simply run a summary query against each unique output script.

Note that for inputs this means obtaining the corresponding output script. This is done by querying for the transaction output that is referenced by the input. This is also easily accomplished using a transaction query.

Reorgs remove existing entries from the table. You would need to maintain the transaction hash for all entries to make this possible.

For standard payments (i.e. ones that actually have addresses) you can compute the address from the script and store it in the table. But not all transfers correspond to addresses.

from libbitcoin-client.

evoskuil avatar evoskuil commented on September 27, 2024

Note that libbitcoin's store is indexed for the purpose of validating the chain (i.e. as a node) to support mining and wallet queries. Its additional payments index exists so that, given an address, one can query for all payments to/from that address (and therefore may also obtain balance). This provides support for block explorers and SPV wallets.

Arbitrary queries against blockchain data (such as all addresses with a certain balance) require a general purpose query engine or creation of a custom index for each query.

from libbitcoin-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.