Watch-only-Wallets

From Snowblossom Wiki
Revision as of 06:00, 30 October 2018 by Fireduck (talk | contribs) (migration)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Watch only wallets

To create a watch only wallet, first take your normal wallet and do an export_watch only:

Assuming sbc is an alias to SnowBlossomClient

sbc regular.conf export_watch_only watch.txt

You can inspect watch.txt and see that it has only addresses, address specs and no keys.

Then make your watch only config, which needs the config parameter:

watch_only=true

When you first start it, it will show this error, which is normal.

$ sbc client-empty.conf
Aug 19, 2018 3:45:08 PM snowblossom.client.SnowBlossomClient <init>
INFO: Starting SnowBlossomClient version 1.3.0-dev
Aug 19, 2018 3:45:08 PM snowblossom.lib.NetworkParams loadFromConfig
INFO: Using network teapot - testnet
Aug 19, 2018 3:45:08 PM snowblossom.client.Purse <init>
WARNING: Directory wallets/teapot-empty does not contain wallet, creating new wallet
Total: 0.000000 (0.000000 pending) (0.000000 spendable)
Wallet Keys: 0, Addresses: 0, Fresh pool: 0
Here is an unused address:
Exception in thread "main" java.lang.RuntimeException: Unable to create new address on watch only wallet.
        at snowblossom.client.WalletUtil.genNewKey(WalletUtil.java:66)
        at snowblossom.client.Purse.getUnusedAddress(Purse.java:78)
        at snowblossom.client.Purse.getUnusedAddress(Purse.java:102)
        at snowblossom.client.SnowBlossomClient.main(SnowBlossomClient.java:65)

Then do the import:

sbc watch.conf import watch.txt

Now you can see they are correct. The regular wallet has addresses and keys:

$ sbc regular.conf
Aug 19, 2018 3:47:14 PM snowblossom.client.SnowBlossomClient <init>
INFO: Starting SnowBlossomClient version 1.3.0-dev
Aug 19, 2018 3:47:14 PM snowblossom.lib.NetworkParams loadFromConfig
INFO: Using network teapot - testnet
Total: 543281.999093 (0.000000 pending) (543281.999093 spendable)
Wallet Keys: 26, Addresses: 26, Fresh pool: 20
  1of1 ECDSA: 26
Here is an unused address:
snowtest:rwzjykzctzla9y62u9xx7yvmk6tkazqhenp48f0p

The watch only wallet has addresses and no keys:

$ sbc watch.conf
Aug 19, 2018 3:47:39 PM snowblossom.client.SnowBlossomClient <init>
INFO: Starting SnowBlossomClient version 1.3.0-dev
Aug 19, 2018 3:47:39 PM snowblossom.lib.NetworkParams loadFromConfig
INFO: Using network teapot - testnet
Total: 543281.999093 (0.000000 pending) (543281.999093 spendable)
Wallet Keys: 0, Addresses: 26, Fresh pool: 20
  1of1 ECDSA: 26
Here is an unused address:
snowtest:rwzjykzctzla9y62u9xx7yvmk6tkazqhenp48f0p

Asking the watch only wallet to make a new key gets an error:

$ sbc watch.conf getfresh true true
Aug 19, 2018 3:48:08 PM snowblossom.client.SnowBlossomClient <init>
INFO: Starting SnowBlossomClient version 1.3.0-dev
Aug 19, 2018 3:48:08 PM snowblossom.lib.NetworkParams loadFromConfig
INFO: Using network teapot - testnet
Exception in thread "main" java.lang.RuntimeException: Unable to create new address on watch only wallet.
        at snowblossom.client.WalletUtil.genNewKey(WalletUtil.java:66)
        at snowblossom.client.Purse.getUnusedAddress(Purse.java:78)
        at snowblossom.client.SnowBlossomClient.main(SnowBlossomClient.java:109)

To update the watch only wallet (with new keys from the regular wallet as it makes them) simply redo the export_watch_only and import steps. That will get any new addresses to the watch only wallet.

This is safe to do while the regular client is running (as rpcserver for example).

However, if the watch client is running, it will need to be restarted to see the new addresses.

The rpc import_wallet can be used without needing a restart: https://github.com/snowblossomcoin/snowblossom/wiki/JSON-RPC-Commands#import_wallet