Xpub for HD wallets

1

I have a cold storage in my one of the computers.Also in my project server I have run bitcoin-cli. So I want to remove priv key from here and set the public key from cold storage. I read that it will more secure and I can spend my coins only from cold storage. How can I implement this mechanism ?

Thanks!

Yur Gasparyan

Posted 2018-10-10T10:27:23.443

Reputation: 181

Answers

1

You can't do this with bitcoin core since it uses hardened derivation so you can't derive addresses using the extended public key. You should use electrum for this instead. An electrum watch-only wallet can mirror the addresses of a an electrum seeded wallet. So just create an electrum wallet on your desktop as normal and then grab the master public key aka extended public key via wallet menu > information. You can then derive addresses using that. The easiest way would be to install electrum on the server, restore the wallet using the xpub:

electrum restore xpub...

Then you can use the addrequest command with the --force switch to generate addresses:

electrum addrequest --force 0.1

The JSON code that is output will contain a unique address everytime. Note you may have to increase the gap limit on the seeded wallet on your desktop via wallet.change_gap_limit(200) on the console tab (view > show console).

Electrum also has a JSON RPC interface as well but you will have to research how to use that yourself.

Abdussamad

Posted 2018-10-10T10:27:23.443

Reputation: 1 850

Is there a fullnode for BitcoinCash that supports xpub?Sudip Bhattarai 2019-07-31T02:39:53.590

thanks for reply. So I have run the following commands, and at first I have created an account called default_wallet. than when I have run electrum addrequest --force 0.1 it maybe creates an address and I got the follwing response

    "URI": "bitcoin:12RDcyE2YRFy6d9NcMhPE2ABszaqMqqqrG?amount=0.1",
    "address": "12RDcyE2YRFy6d9NcMhPE2ABszaqMqqqrG",
    "amount": 10000000,
    "amount (BTC)": "0.1",
    "exp": null,
    "id": "e2471abf54",
    "memo": "",
    "status": "Unknown",
    "time": 1539202269
}
Yur Gasparyan 2018-10-10T20:15:11.240

I want to know where did amount come from? and what is the amount ?Yur Gasparyan 2018-10-10T20:16:29.660

The addrequest command requires that you provide it an amount. However that amount is meaningless so just enter anything you like. The amount is the 0.1 part of the command i gave above.Abdussamad 2018-10-11T05:42:25.117