silent payments: file-based key import/export - #56
Conversation
|
High level comment, we should allow the spend key to be passed by either private scalar or x-only public key in the file. This would allow us to use hardware signers and still use this import format. I suggest changing the file format to have an enum either |
Extend `wallet generate-keys` with `--out <path>`. The file refuses to overwrite an existing path. Format: 4-byte magic `SPKF`, 32-byte scan secret, 1-byte spend tag, 32-byte spend material. Tag 0 stores the spend secret (software wallet); tag 1 stores the x-only spend public key (hardware-signer / watch-only setup). Incompatible revisions bump the magic. A new `wallet::io::FileExt` trait carries `save`/`load` so other file-backed types can reuse the path handling.
Add `--sp-keys-file <path>`. When set, the node loads the binary keys file before block scanning and imports it. Failures (missing file, bad magic, invalid key) abort startup so a misconfigured keys-file path surfaces clearly rather than as a silently-unimported wallet. The IPC handler's inline import logic moves to a new `Wallet::import_keys(scan_key, spend_xonly)` shared with the startup path.
keys_file.rs now has a SpendKey { Secret(SecretKey), XOnlyPublic(XOnlyPublicKey) } enum and a 1-byte tag. |
|
I'm going to pull and test locally but looking good to me |
| scan_key: SecretKey, | ||
| spend_xonly: XOnlyPublicKey, | ||
| ) -> Result<(), ::silentpayments::Error> { | ||
| let spend_pub = PublicKey::from_x_only_public_key(spend_xonly, Parity::Even); |
There was a problem hiding this comment.
I don't know much about the semantics of taproot, but I assume it's defined all x-only keys are even parity? I only ask because it seems strange the from_x_only_public_key function would need a parity argument at all if it's just going to be passed as Even every time
There was a problem hiding this comment.
I believe from_x_only_public_key is just the secp256k1 primitive and not taproot-specific.
|
Tested locally and received a payment. Nice job let's keep it rollin ACK 6981b69 |
Implements file imports from #55:
wallet::io::FileExttrait that carriessave/loadso file-backed types can reuse the path handling.wallet generate-keys --out <path>writes a binary keys file (mode 0o600 on Unix, refuses to overwrite).wallet import-keys-file <path>reads it back.--sp-keys-file <path>(node option) auto-imports on startup; load errors warn and continue.