Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: CoinSphere on May 11, 2013, 05:06:59 PM



Title: Deterministic address generating using watch-only address
Post by: CoinSphere on May 11, 2013, 05:06:59 PM
I use Armory client for home use. I keep most of my coins as offline paper and SD card backups (I built the client for my Raspberry pi and it seems to work well for this). I then use my watch-only addresses on my online computer. I know there is a bit of "magic" involving chain codes going on when I request my client to determine the next receiving address from my watch-only copy. My question is this: is there a version of this as a headless standalone program that would take a watch-only address, load it and have it generate receive address deterministically and on demand (say through JSON-RPC or similar protocol)? I've scanned over BIP 0032 and I'm sure I could hack something together myself, but I certainly don't want to reinvent the wheel.

Edit: please forgive me if I butchered any of the vernacular.


Title: Re: Deterministic address generating using watch-only address
Post by: etotheipi on May 12, 2013, 12:28:54 AM
I use Armory client for home use. I keep most of my coins as offline paper and SD card backups (I built the client for my Raspberry pi and it seems to work well for this). I then use my watch-only addresses on my online computer. I know there is a bit of "magic" involving chain codes going on when I request my client to determine the next receiving address from my watch-only copy. My question is this: is there a version of this as a headless standalone program that would take a watch-only address, load it and have it generate receive address deterministically and on demand (say through JSON-RPC or similar protocol)? I've scanned over BIP 0032 and I'm sure I could hack something together myself, but I certainly don't want to reinvent the wheel.

Edit: please forgive me if I butchered any of the vernacular.

You can do this pretty simply as a python script.  Here's the entire script:

Code:
from armoryengine import *
from sys import argv
wlt = PyBtcWallet().readWalletFile(argv[1]);
print wlt.getNextUnusedAddress().getAddrStr()

Here's the output of that script:
Code:
$ python getNextAddress.py armory_2b1i32B43_.watchonly.wallet
13oH966qRBKy5s9a8Uszq1yHegoTvtbi37
$ python getNextAddress.py armory_2b1i32B43_.watchonly.wallet
1486e8pQ1Hd2Zmdc3JXQ1pmUrUohbirCQ9
$ python getNextAddress.py armory_2b1i32B43_.watchonly.wallet
1QFuMJwsHDiY9EthT8afJqjUtVLHs75Q6e


Wrap that in a socket server or just invoke it as a system command.  Each call accesses the wallet file, calculates the next address, then marks that address as used in the wallet file.  

This will be a pain in Windows.  But if you're in linux, either install it or build from source.  Then you only need:  _CppBlockUtils.so, CppBlockUtils.py, armoryengine.py.  If it complains about needing anything else, you can probably just comment out those portions of armoryengine, which are unrelated to this operation.  Or just bundle the whole directory with it.

EDIT: actually checking whether money has been received is another story.  Likewise, creating transactions to be signed like this is possible but not trivial.  Let me know if you are interested in doing any more with it.



Title: Re: Deterministic address generating using watch-only address
Post by: CoinSphere on May 12, 2013, 01:46:09 AM
That's exactly what I need. Thanks. I'm sure I'll be wanting to do more later on, but for now that is an excellent starting point.

And I really love Armory. Guess I need to bite the bullet and delve into the code more.


Title: Re: Deterministic address generating using watch-only address
Post by: etotheipi on May 12, 2013, 01:52:16 AM
That's exactly what I need. Thanks. I'm sure I'll be wanting to do more later on, but for now that is an excellent starting point.

And I really love Armory. Guess I need to bite the bullet and delve into the code more.

Well, let me know when you do.  I am always happy to help people get into it (and maybe they'll eventually help out, too :)).

If you want to do some of your own exploration, download the repo and look at the "extras" directory.  Specifically:

sample_armory_code.py (lots of simple examples)
cli_sign_txdp.py  (for signing offline transactions from the command line)
createTxFromAddrList.py  (for creating an offline tx from online computer)
findpass.py  (for when you forget your wallet passphrase but remember enough to make brute-force feasible)
frag/unfrag_wallet.py (splitting your paper backup into M-of-N pieces)

Some of it was created a while ago before some major updates, so it may not all be 100%.  But I've tested most of it recently.


Title: Re: Deterministic address generating using watch-only address
Post by: CoinSphere on May 12, 2013, 02:15:38 AM
Sure thing. I'll look through the extras at the very least. Keep up the good work.