sparrowwallet / sparrow

Desktop Bitcoin Wallet focused on security and privacy. Free and open source.
https://sparrowwallet.com/
Apache License 2.0
1.21k stars 173 forks source link

Feature request: Support lnd AEZEED seed import #120

Open jimbojw opened 3 years ago

jimbojw commented 3 years ago

Background: Instead of using BIP-39, the lnd lightning implementation uses a cipher seed scheme called AEZEED. Implementation (Go) and details here: https://github.com/lightningnetwork/lnd/tree/master/aezeed

Feature request: Support the lnd AEZEED cipher seed format as an input mechanism in the Sparrow software wallet import dialog. This would allow users to recover/manage on-chain balances from an lnd wallet.

Workaround: A tool called guggero/chantools has a command called showrootkey that can retrieve the BIP-32 xprv. As of Sparrow v1.4.0, this can be imported directly in the software wallet import dialog.

Implementation notes: The part of the chantools code that converts the AEZEED mnemonic into the xprv starts on line 104 of lnd/aezeed.go:

    var mnemonic aezeed.Mnemonic
    copy(mnemonic[:], cipherSeedMnemonic)

    // If we're unable to map it back into the ciphertext, then either the
    // mnemonic is wrong, or the passphrase is wrong.
    cipherSeed, err := mnemonic.ToCipherSeed(passphraseBytes)
    if err != nil {
        return nil, time.Unix(0, 0), fmt.Errorf("failed to decrypt "+
            "seed with passphrase: %v", err)
    }
    rootKey, err := hdkeychain.NewMaster(cipherSeed.Entropy[:], params)
    if err != nil {
        return nil, time.Unix(0, 0), fmt.Errorf("failed to derive " +
            "master extended key")
    }
    return rootKey, cipherSeed.BirthdayTime(), nil

It looks like the mnemonic.ToCipherSeed() method is responsible for converting the AEZEED mnemonic into entropy bits. Note that hdkeychain is from btcsuite/btcutil.

6102bitcoin commented 3 years ago

Outstanding Action: As with WIF paper wallet import, nice to have but may be significant work for a niche feature. Proposed Priority: Low