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

Add a document on how to recover a Liana wallet using Bitcoin Core 25.0 #375

Closed
darosior opened this issue Mar 24, 2023 · 7 comments
Closed
Assignees

Comments

@darosior
Copy link
Member

No description provided.

@darosior darosior self-assigned this Mar 24, 2023
@darosior darosior added this to Liana v1 Apr 4, 2023
@darosior darosior moved this to Nice to have in Liana v1 Apr 28, 2023
@pythcoiner
Copy link
Collaborator

just tried that today:

bitcoin-cli createwallet liana_restore
'[{"desc": "wsh(andor(pk([a5c6xxxx/48'/0'/0'/2']xpub6E3yjBcNhpWPoUxxxxxxxxxxxrwNV5is7cpypaYVkmnxTbrx1GMrYjN7p9F7Hr184UjgXFCSzitZ6q9UtXdTfnZv8UaS1VTvidYGdCkoq7k/<0;1>/*),older(65535),or_d(pk([a5c6xxxx/84'/0'/0']xpub6DUuCx6R9qdwWeTgYQbwtHFC6HT3QdxKVm3rxxxxxxxxxxxxxxxxxxxxxxxxxGpUjhEWJWUx9EkkvMeXTTpkwmFAzjLfgHssFFzsohnV8Sh4To/<0;1>/*),and_v(v:pk([1801xxxx/84'/0'/0']xpub6D7RmbwBaHXkSjxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxecADgycn4ayon3vkcbEMfMw23Q3E8KJao2H8wfngQe8Nf44m6eyHnvpD1qR/<0;1>/*),older(4400)))))#dn2236k4", "range": [0,10000], "timestamp": 1682920310}]'

then i got this response:

[
  {
    "success": false,
    "error": {
      "code": -5,
      "message": "A function is needed within P2WSH"
    }
  }
]

@darosior
Copy link
Member Author

It's because Bitcoin Core doesn't yet support "multipath" key expressions (bitcoin/bitcoin#22838). You'll be able to import the descriptor if you split it between receive and change:

wsh(andor(pk([a5c6xxxx/48'/0'/0'/2']xpub6E3yjBcNhpWPoUxxxxxxxxxxxrwNV5is7cpypaYVkmnxTbrx1GMrYjN7p9F7Hr184UjgXFCSzitZ6q9UtXdTfnZv8UaS1VTvidYGdCkoq7k/0/*),older(65535),or_d(pk([a5c6xxxx/84'/0'/0']xpub6DUuCx6R9qdwWeTgYQbwtHFC6HT3QdxKVm3rxxxxxxxxxxxxxxxxxxxxxxxxxGpUjhEWJWUx9EkkvMeXTTpkwmFAzjLfgHssFFzsohnV8Sh4To/0/*),and_v(v:pk([1801xxxx/84'/0'/0']xpub6D7RmbwBaHXkSjxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxecADgycn4ayon3vkcbEMfMw23Q3E8KJao2H8wfngQe8Nf44m6eyHnvpD1qR/0/*),older(4400)))))
wsh(andor(pk([a5c6xxxx/48'/0'/0'/2']xpub6E3yjBcNhpWPoUxxxxxxxxxxxrwNV5is7cpypaYVkmnxTbrx1GMrYjN7p9F7Hr184UjgXFCSzitZ6q9UtXdTfnZv8UaS1VTvidYGdCkoq7k/1/*),older(65535),or_d(pk([a5c6xxxx/84'/0'/0']xpub6DUuCx6R9qdwWeTgYQbwtHFC6HT3QdxKVm3rxxxxxxxxxxxxxxxxxxxxxxxxxGpUjhEWJWUx9EkkvMeXTTpkwmFAzjLfgHssFFzsohnV8Sh4To/1/*),and_v(v:pk([1801xxxx/84'/0'/0']xpub6D7RmbwBaHXkSjxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxecADgycn4ayon3vkcbEMfMw23Q3E8KJao2H8wfngQe8Nf44m6eyHnvpD1qR/1/*),older(4400)))))

@pythcoiner
Copy link
Collaborator

receive and changes are /0/* and /1/* at end of xpub?

@darosior
Copy link
Member Author

darosior commented May 14, 2023 via email

@pythcoiner
Copy link
Collaborator

it will alway be 0 & 1? maybe a python script can be useful for user who want recover in core?

@darosior darosior moved this to Nice to have in Liana v2 Jul 13, 2023
@pythcoiner
Copy link
Collaborator

Here the steps to recover on Bitcoin core (signet) from descriptor wsh(or_d(pk([40259ab7/48'/1'/0'/2']tpubDFcY6nTiMAWBd5d2bS8JZvjcaLjC6GE6XnPAJAPUkVj5wa5Pyb4gumx1ZWvnXQ8tmorCmpAyai69K9hD2mGQUeNkuXfjztsfqnE5FMk1CCh/<0;1>/*),and_v(v:pkh([842a626e/48'/1'/0'/2']tpubDENBboujRvpkS8SgZsrpqG2BCUBoaAc4c57jHFe1NwKAtfVjDZDUadQKYv4pkAEF2afPv6TtQ2BoYFJAPLbuKpL1usiySERZekGo4JmnWhh/<0;1>/*),older(65535))))#deguz53x:

Create wallet:

bitcoin-cli -signet createwallet 'liana_recovery' true

output:

{
  "name": "liana_recovery"
}

Import descriptor:

bitcoin-cli -signet -rpcwallet=liana_recovery importdescriptors '[{"desc": "wsh(or_d(pk([40259ab7/48'/1'/0'/2']tpubDFcY6nTiMAWBd5d2bS8JZvjcaLjC6GE6XnPAJAPUkVj5wa5Pyb4gumx1ZWvnXQ8tmorCmpAyai69K9hD2mGQUeNkuXfjztsfqnE5FMk1CCh/0/*),and_v(v:pkh([842a626e/48'/1'/0'/2']tpubDENBboujRvpkS8SgZsrpqG2BCUBoaAc4c57jHFe1NwKAtfVjDZDUadQKYv4pkAEF2afPv6TtQ2BoYFJAPLbuKpL1usiySERZekGo4JmnWhh/0/*),older(65535))))#7g3cds5h", "range": [0,10000], "timestamp": 1682920310}, {"desc": "wsh(or_d(pk([40259ab7/48'/1'/0'/2']tpubDFcY6nTiMAWBd5d2bS8JZvjcaLjC6GE6XnPAJAPUkVj5wa5Pyb4gumx1ZWvnXQ8tmorCmpAyai69K9hD2mGQUeNkuXfjztsfqnE5FMk1CCh/1/*),and_v(v:pkh([842a626e/48'/1'/0'/2']tpubDENBboujRvpkS8SgZsrpqG2BCUBoaAc4c57jHFe1NwKAtfVjDZDUadQKYv4pkAEF2afPv6TtQ2BoYFJAPLbuKpL1usiySERZekGo4JmnWhh/1/*),older(65535))))#njcmmphw", "range": [0,10000], "timestamp": 1682920310}]'

(here original descriptor might to be split in 2 descriptor (receive + change), and each checksum re-processed)

output:

[
  {
    "success": true
  },
  {
    "success": true
  }
]

Check wallet infos:

bitcoin-cli -signet -rpcwallet=liana_recovery getwalletinfo

output:

{
  "walletname": "liana_recovery",
  "walletversion": 169900,
  "format": "sqlite",
  "balance": 0.01575593,
  "unconfirmed_balance": 0.00000000,
  "immature_balance": 0.00000000,
  "txcount": 5,
  "keypoolsize": 0,
  "keypoolsize_hd_internal": 0,
  "paytxfee": 0.00000000,
  "private_keys_enabled": false,
  "avoid_reuse": false,
  "scanning": false,
  "descriptors": true,
  "external_signer": false
}

Create spending tx:

bitcoin-cli -signet -rpcwallet=liana_recovery sendall '["tb1qed7lyessqcecav5uxultf6zc8nefd9kalgaa7dwrglcc6ld5vd3qe20spe"]' null "unset" 20

output:

{
  "psbt": "cHNidP8BALACAAAAA8Ms485HnnpglFFToTOMhyoFspUwcydbtr7Oe0cju/HYAAAAAAD9////MEK+0DRfAs+nLoFgsOeHD3sAq00x+mldkOOxvwUeHw0AAAAAAP3///+2JGYCXJ9JwW7XppZFW6oXGXP4GXC+jacj8v3U1VZv8gEAAAAA/f///wGN9BcAAAAAACIAIMt98mYQBjOOspw3PrToWDzylpbd+jvfNcNH8Y19tGNiAAAAAAABAH0CAAAAAbuuo6PMGF0d9d+07OxD8H64e23mJ1Tq3tSmTvTpie2sAAAAAAD+////AkBCDwAAAAAAIgAgy33yZhAGM46ynDc+tOhYPPKWlt36O981w0fxjX20Y2I61w1BSwYAABYAFKFdJuaJFK5HoS2etlvok4dTxqs+8TkCAAEBK0BCDwAAAAAAIgAgy33yZhAGM46ynDc+tOhYPPKWlt36O981w0fxjX20Y2IBBUQhApVoqmBo/jMxzCCpvdcbwdhJDthL0+GB7WGHQ6DELIEQrHNkdqkULwYnq2qWrWGTkA0Y/IsE+NjzFHaIrQP//wCyaCIGApVoqmBo/jMxzCCpvdcbwdhJDthL0+GB7WGHQ6DELIEQHEAlmrcwAAAAAQAAAAAAAAACAAAAAAAAAAEAAAAiBgMQKlFFwRGRkmA1hC/gCOASBlnO1OtEl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ZOQDRj8iwT42PMUdoitA///ALJoIgIClWiqYGj+MzHMIKm91xvB2EkO2EvT4YHtYYdDoMQsgRAcQCWatzAAAAABAAAAAAAAAAIAAAAAAAAAAQAAACICAxAqUUXBEZGSYDWEL+AI4BIGWc7U60SVV9WZfkbPLFkEHIQqYm4wAAAAAQAAAAAAAAACAAAAAAAAAAEAAAAA",
  "complete": false
}

darosior added a commit that referenced this issue Aug 28, 2023
fcfad2d import descriptor w/o replacing hardened identifier (pythcoiner)
eb1e013 recover walkthrough (pythcoiner)

Pull request description:

  xref #375

ACKs for top commit:
  darosior:
    ACK fcfad2d. I'll have a second pass for the syntax and expliciting a couple things. Thanks!

Tree-SHA512: c2713d0db8240b844c3a4cf3d97044a5846bba903c1209f08ce903475525d5145b9555fa693eed326e3d4a8e85577922adfb366664ec162303cb0bf3a4aae2a0
@darosior
Copy link
Member Author

A guide was added (see #619 and #636). It can most probably be improved, but we've now got a solid base so i think this can be closed. Anyone feel free to PR enhancements to the documentation.

Special thanks go to @pythcoiner for this.

@darosior darosior moved this from Nice to have to Done in Liana v2 Aug 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Nice to have
Status: Done
Development

No branches or pull requests

2 participants