Skip to content

Commit 0f54714

Browse files
polespinasaachow101
authored andcommitted
doc: update offline-signing-tutorial to use exportwatchonlywallet rpc
1 parent 6e8cddb commit 0f54714

File tree

1 file changed

+8
-50
lines changed

1 file changed

+8
-50
lines changed

doc/offline-signing-tutorial.md

Lines changed: 8 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ In this tutorial we have two hosts, both running Bitcoin v25.0
1515
* `offline` host which is disconnected from all networks (internet, Tor, wifi, bluetooth etc.) and does not have, or need, a copy of the blockchain.
1616
* `online` host which is a regular online node with a synced blockchain.
1717

18-
We are going to first create an `offline_wallet` on the offline host. We will then create a `watch_only_wallet` on the online host using public key descriptors exported from the `offline_wallet`. Next we will receive some coins into the wallet. In order to spend these coins we'll create an unsigned PSBT using the `watch_only_wallet`, sign the PSBT using the private keys in the `offline_wallet`, and finally broadcast the signed PSBT using the online host.
18+
We are going to first create an `offline_wallet` on the offline host. We will then create a `watch_only_wallet` on the online host using a wallet file exported from the `offline_wallet`. Next we will receive some coins into the wallet. In order to spend these coins we'll create an unsigned PSBT using the `watch_only_wallet`, sign the PSBT using the private keys in the `offline_wallet`, and finally broadcast the signed PSBT using the online host.
1919

2020
### Requirements
2121
- [jq](https://jqlang.github.io/jq/) installation - This tutorial uses jq to process certain fields from JSON RPC responses, but this convenience is optional.
@@ -39,72 +39,30 @@ We are going to first create an `offline_wallet` on the offline host. We will th
3939
> [!NOTE]
4040
> The use of a passphrase is crucial to encrypt the wallet.dat file. This encryption ensures that even if an unauthorized individual gains access to the offline host, they won't be able to access the wallet's contents. Further details about securing your wallet can be found in [Managing the Wallet](https://github.com/bitcoin/bitcoin/blob/master/doc/managing-wallets.md#12-encrypting-the-wallet)
4141
42-
2. Export the public key-only descriptors from the offline host to a JSON file named `descriptors.json`. We use `jq` here to extract the `.descriptors` field from the full RPC response.
43-
42+
2. Export the wallet in a watch-only format to a .dat file named `watch_only_wallet.dat`.
4443
```sh
45-
[offline]$ ./build/bin/bitcoin-cli -signet -rpcwallet="offline_wallet" listdescriptors \
46-
| jq -r '.descriptors' \
47-
>> /path/to/descriptors.json
44+
[offline]$ ./build/bin/bitcoin-cli -signet -named exportwatchonlywallet \
45+
destination=/path/to/watch_only_wallet.dat
4846
```
4947

5048
> [!NOTE]
51-
> The `descriptors.json` file will be transferred to the online machine (e.g. using a USB flash drive) where it can be imported to create a related watch-only wallet.
49+
> The `watch_only_wallet.dat` file will be transferred to the online machine (e.g. using a USB flash drive) where it can be imported to create a related watch-only wallet.
5250
5351
### Create the online `watch_only_wallet`
5452

55-
1. On the online machine create a blank watch-only wallet which has private keys disabled and is named `watch_only_wallet`. This is achieved by using the `createwallet` options: `disable_private_keys=true, blank=true`.
56-
53+
On the online machine import the watch-only wallet. This wallet will have the private keys disabled and is named `watch_only_wallet`. This is achieved by using the `restorewallet` rpc call.
5754
The `watch_only_wallet` wallet will be used to track and validate incoming transactions, create unsigned PSBTs when spending coins, and broadcast signed and finalized PSBTs.
5855

59-
> [!NOTE]
60-
> `disable_private_keys` indicates that the wallet should refuse to import private keys, i.e. will be a dedicated watch-only wallet.
61-
6256
```sh
63-
[online]$ ./build/bin/bitcoin-cli -signet -named createwallet \
57+
[online]$ ./build/bin/bitcoin-cli -signet -named restorewallet \
6458
wallet_name="watch_only_wallet" \
65-
disable_private_keys=true \
66-
blank=true
59+
backup_file=/path/to/watch_only_wallet.dat
6760

6861
{
6962
"name": "watch_only_wallet"
7063
}
7164
```
7265

73-
2. Import the `offline_wallet`s public key descriptors to the online `watch_only_wallet` using the `descriptors.json` file created on the offline wallet.
74-
75-
```sh
76-
[online]$ ./build/bin/bitcoin-cli -signet -rpcwallet="watch_only_wallet" importdescriptors "$(cat /path/to/descriptors.json)"
77-
78-
[
79-
{
80-
"success": true
81-
},
82-
{
83-
"success": true
84-
},
85-
{
86-
"success": true
87-
},
88-
{
89-
"success": true
90-
},
91-
{
92-
"success": true
93-
},
94-
{
95-
"success": true
96-
},
97-
{
98-
"success": true
99-
},
100-
{
101-
"success": true
102-
}
103-
]
104-
```
105-
> [!NOTE]
106-
> Multiple success values indicate that multiple descriptors, for different address types, have been successfully imported. This allows generating different address types on the `watch_only_wallet`.
107-
10866
### Fund the `offline_wallet`
10967

11068
At this point, it's important to understand that both the `offline_wallet` and online `watch_only_wallet` share the same public keys. As a result, they generate the same addresses. Transactions can be created using either wallet, but valid signatures can only be added by the `offline_wallet` as only it has the private keys.

0 commit comments

Comments
 (0)