Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wallet restore and document #3237

Merged
merged 8 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions docs/src/guides/wallet.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,15 @@ To create a wallet named `ord`, the default, for use with `ord wallet`, run:
ord wallet create
```

This will print out your seed phrase mnemonic, store it somewhere safe.

```
{
"mnemonic": "dignity buddy actor toast talk crisp city annual tourist orient similar federal",
"passphrase": ""
}
```

If you want to specify a different name or use an `ord server` running on a
non-default URL you can set these options:

Expand All @@ -193,6 +202,71 @@ To see all available wallet options you can run:
ord wallet help
```

Restoring and Dumping Wallet
----------------------------

The `ord` wallet uses descriptors, so you can export the output descriptors and
import them into another descriptor-based wallet. To export the wallet
descriptors, which include your private keys:

```
$ ord wallet dump
==========================================
= THIS STRING CONTAINS YOUR PRIVATE KEYS =
= DO NOT SHARE WITH ANYONE =
==========================================
{
"wallet_name": "ord",
"descriptors": [
{
"desc": "tr([551ac972/86'/1'/0']tprv8h4xBhrfZwX9o1XtUMmz92yNiGRYjF9B1vkvQ858aN1UQcACZNqN9nFzj3vrYPa4jdPMfw4ooMuNBfR4gcYm7LmhKZNTaF4etbN29Tj7UcH/0/*)#uxn94yt5",
"timestamp": 1296688602,
"active": true,
"internal": false,
"range": [
0,
999
],
"next": 0
},
{
"desc": "tr([551ac972/86'/1'/0']tprv8h4xBhrfZwX9o1XtUMmz92yNiGRYjF9B1vkvQ858aN1UQcACZNqN9nFzj3vrYPa4jdPMfw4ooMuNBfR4gcYm7LmhKZNTaF4etbN29Tj7UcH/1/*)#djkyg3mv",
"timestamp": 1296688602,
"active": true,
"internal": true,
"range": [
0,
999
],
"next": 0
}
]
}
```

An `ord` wallet can be restored from a mnemonic:

```
ord wallet restore --from mnemonic
```

Type your mnemonic and press return.

To restore from a descriptor in `descriptor.json`:

```
cat descriptor.json | ord wallet restore --from descriptor
```

To restore from a descriptor in the clipboard:

```
ord wallet restore --from descriptor
```

Paste the descriptor into the terminal and press CTRL-D on unix and CTRL-Z
on Windows.

Receiving Sats
--------------

Expand Down
3 changes: 2 additions & 1 deletion src/subcommand/wallet/restore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ impl Restore {
);

let mut buffer = String::new();
io::stdin().read_to_string(&mut buffer)?;

match self.from {
Source::Descriptor => {
io::stdin().read_to_string(&mut buffer)?;
ensure!(
self.passphrase.is_none(),
"descriptor does not take a passphrase"
Expand All @@ -39,6 +39,7 @@ impl Restore {
Wallet::initialize_from_descriptors(name, settings, wallet_descriptors.descriptors)?;
}
Source::Mnemonic => {
io::stdin().read_line(&mut buffer)?;
let mnemonic = Mnemonic::from_str(&buffer)?;
Wallet::initialize(
name,
Expand Down
Loading