bitfinexcom / smidgen

MIT License
43 stars 16 forks source link

Restore wallet with multisig addresses #40

Closed joshirio closed 6 years ago

joshirio commented 6 years ago

First, let me say how great this tool is and thank you for creating it. It's the only multisig tool for IOTA right now that actually works. I'm planning to use smidgen as the backend to create a simple cold wallet GUI based on multisig where one of the two parties signs the transaction on an offline computer. This simple wallet could eventually become also a simple multisig GUI in addition to the cold signing workflow.

Now, the real issue, as far as I understand, there's currently no command to restore multisig addresses, which were potentially used previously. After a snapshot or if the user loses the file (state of the multisig), restoring the multisig wallet with the seeds by using multisig create, creates only the first multisig address (main address) without checking further key indexes.

What would be a way to populate the file with the latest non used multisig address? If there's none (currently), is it possible to implement a command to generate/add multisig addresses to the file?

I understand this is beta, but I hope there will be an address restore feature in the future.

robertkowalski commented 6 years ago

Thank you!

What would be a way to populate the file with the latest non used multisig address?

Right now, there is none, except doing it manually.

If there's none (currently), is it possible to implement a command to generate/add multisig addresses to the file?

yes, probably. we already have that for non-multisig addresses: https://github.com/bitfinexcom/smidgen#regenerate-addresses---amount----json----depth----mwm----force----provider

robertkowalski commented 6 years ago

ok, so how we attach right now with non-multisig addresses is by touching the address with a 0-transfer, sending 0i to the address:

https://github.com/bitfinexcom/smidgen/blob/26f756a999671e47f96a07058fedc2539bcf603b/lib/cmds/generate-address.js#L20-L27

let's take a look at the wallet textfile:

{
  "next": null,
  "current": {
    "parties": [
      {
        "id": "party1",
        "security": 2,
        "indexMain": 2,
        "indexRemainder": 3,
       },
       "id": "party2"
[... more json]

in the field current you see some metadata we use to determine who has to sign in which order.

Later there is the current address field:

   "mainAddress": "XXXX"

Just as additional information, I think its not needed, the old addresses are also available for all previously generated addresses, those in the last section of the wallet file:

"last": [

What we can do is:

We read the old wallet file. We get the current main address. It should be sufficent to send 0i to the current mainAddress from another account. This will resurrect the balances / reconnect the wallet.

Hope this helps.

Btw in https://github.com/bitfinexcom/smidgen/pull/43/commits/abf1e8923c74f66ece1019c31a5c3ff8a35afa40 added support for sending 0i via commandline :)

robertkowalski commented 6 years ago

i just added smidgen multisig reattach