muun / recovery

Muun recovery tool
https://muun.com
MIT License
198 stars 79 forks source link

ZPUB Generation #5

Open Goro2030 opened 3 years ago

Goro2030 commented 3 years ago

Is there a way to generate a ZPUB for the HD wallet to be able to see the balance of it ? Being this a multi-sig wallet, I'm not certain how that can be done ...

From what I've been reading (here), if I would know the 2 "Master private keys" (which I don't, at least they are not easily seen in the recovery pdf of course, nor are the groups of 4 letters ), then I could use a tool like this one:

https://unchained-capital.github.io/caravan/#/wallet

kapishon commented 3 years ago

mycelium

Goro2030 commented 3 years ago

mycelium

Hahaha ... no joke. Really, is there a way?

kapishon commented 3 years ago

I'm glad I made you laugh. it's healthy. have a nice day

slezica commented 3 years ago

Hello there!

Muun is multisig, has Lightning Network support, and uses other kinds of novel transaction output scripts. Generic watch tools and classic on-chain wallets are only capable of locating pay-to-public-key[-hash] scripts and (in some cases) plain multisig, but they can't handle complex scripts. In other words, they won't work with Muun or any other Lightning-enabled wallet.

This is why we wrote this specialized recovery tool, and made it open-source.

There's a BIP in the making right now (https://github.com/achow101/bips/blob/descriptors/bip-descriptors-general.mediawiki) that aims to standardize how tools scan the blockchain for wallet funds. When it matures, it will allow generic (and advanced) tools to work with complex scripts like the ones Muun and other Lightning wallets use.

All that said, your HD private keys are indeed contained in the Emergency Kit (the recovery PDF), and encrypted using the Recovery Code. This tool decrypts the keys using both components. If you follow main.go, you'll quickly spot where you could print your keys if you wanted to.

Goro2030 commented 3 years ago

Muun is multisig, has Lightning Network support, and uses other kinds of novel transaction output scripts. Generic watch tools and classic on-chain wallets are only capable of locating pay-to-public-key[-hash] scripts and (in some cases) plain multisig, but they can't handle complex scripts. In other words, they won't work with Muun or any other Lightning-enabled wallet.

There's one thing I never understood about the architecture of Muun: Somewhere, you have to have a funded Lightning channel to allow for the tx's of the user. Does the user funds it, or you have a big backbone that you control for that? If the channel is "with the user", what happens with any funding locked in the channel/s when you do the wallet recovery process?

There's a BIP in the making right now (https://github.com/achow101/bips/blob/descriptors/bip-descriptors-general.mediawiki) that aims to standardize how tools scan the blockchain for wallet funds. When it matures, it will allow generic (and advanced) tools to work with complex scripts like the ones Muun and other Lightning wallets use.

All that said, your HD private keys are indeed contained in the Emergency Kit (the recovery PDF), and encrypted using the Recovery Code. This tool decrypts the keys using both components. If you follow main.go, you'll quickly spot where you could print your keys if you wanted to.

In the meantime, while that BIP is developed and approved/implemented, wouldn't it be a good idea to use the codebase of your recovery tool and modify it to have it just output the balance of the wallet? Can it be done, technically?

Gracias @slezica !

slezica commented 3 years ago

Hey there! Sorry for the delay. Crazy days.

Muun relies on a heavily optimized implementation of submarine swaps to handle Lightning payments. In practice, this means all funds (whether received through LN or not) are quickly settled in on-chain transactions.

This approach has pros & cons. On one hand, it has enormous advantages for self-custody: since funds end up as UTXOs in the blockchain, the Recovery Tool can easily locate them and spend them. There's no private dynamic backup that can be lost. On the other hand, it introduces fees that are abnormally high for some outgoing Lightning payments.

In cases where a transaction is required to settle incoming payments, it's free of charge for the user (Muun covers any necessary fees). Outgoing payments that require transactions are paid for by the user.

We're currently working on the next version of our Lightning architecture, which will make great improvements on this. On-chain fees will be avoided in the large majority of cases, while preserving the on-chain boost to self-custody.

As for the second question, the tool can already do that :) after the scan, you'll see a summary of all addresses and funds. You can exit the tool right there, with no consequences. It doesn't have a special flag or interactive prompt for that, though.

Goro2030 commented 3 years ago

I've been playing with the code, and in trying to run a recovery process, I've noticed that the tool is not accounting for all the sats in my wallet . In my case, it's missing almost 1% of the balance.

Why is that happening? Maybe those funds are locked in the Lightning network backend?

slezica commented 3 years ago

Hey Goro!

We handle these cases via support, to keep the repository focused on code and development. Would you mind writing to support@muun.com, or sending a help/feedback request through the app?