Autore: William Swanson Data: To: libbitcoin Oggetto: [Libbitcoin] Wallet-watcher service
Hello,
Now that the URI parser and HD wallet keys are out of the way, my next
task is to implement a wallet-watcher service.
This module is basically responsible for sitting on an obelisk
connection and watching for incoming transactions. That way, when
funds enter or leave the wallet, our GUI can respond appropriately.
Equally importantly, this module will maintain a list of UTXO's for
the wallet to pull from when spending funds. This list can be written
to disk and re-loaded, so we can avoid re-fetching all transactions
each time the app starts up (only new things would need to be
fetched).
I currently do about 50-70 transactions per month using the legacy
banking system, or about 600-800 transactions per year. If we take
this as a rough order of magnitude, we can expect our serious users to
eventually have a few thousand distinct bitcoin addresses in their
wallets (each transaction would get a fresh change address).
Obelisk supports subscriptions, but I don't think it can handle
thousands of subscriptions at once from the same client. Plus, there
is no reason to be constantly checking old change addresses that will
probably never be used again. We could probably re-check these old
addresses once a week or so without causing problems. So, for each
address in the wallet, the watcher service needs some sort of "check
frequency" heuristic to keep the server load manageable, as well as a
"last check" timestamp.
Note that I don't want to put any intelligence in the watcher itself;
the higher-level wallet will tell the module which addresses to check
and how often.
In the future, the wallet watcher server could learn to act as an SPV
bitcoin network node, solving the check frequency problem and allowing
it to work securely with untrusted obelisk servers.
Since this is something all wallets need, I think it makes sense to
put it in one of the libbitcoin libraries, rather than keeping it
proprietary. The question is, which one? It probably belongs in
libwallet, but that would create a new dependency between libwallet
and obelisk. Maybe it belongs in libobelisk itself? Thoughts?