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

gun init with arbitrary descriptor #62

Closed
LLFourn opened this issue Dec 17, 2021 · 1 comment
Closed

gun init with arbitrary descriptor #62

LLFourn opened this issue Dec 17, 2021 · 1 comment

Comments

@LLFourn
Copy link
Collaborator

LLFourn commented Dec 17, 2021

We should be able to initialize the wallet with an arbitrary descriptor like gun init <external-descriptor> [<internal-descriptor>]

With no change descriptor:

gun init descriptor "wpkh([AAB893A5/84'/0'/0']xpub661MyMwAqRbcFGjD5niBpcDJ1evbWb51fZ5N29BZRykhud3gEefAvjKvoqGVYXBnBS8JqN1cqCpZg8qJqSPjn9dJNamSXJj/0/*

With a change descriptor:

gun init descriptor "wpkh([AAB893A5/84'/0'/0']xpub661MyMwAqRbcFGjD5niBpcDJ1evbWb51fZ5N29BZRykhud3gEefAvjKvoqGVYXBnBS8JqN1cqCpZg8qJqSPjn9dJNamSXJj/0/*)" "wpkh([AAB893A5/84'/0'/0']xpub661MyMwAqRbcFGjD5niBpcDJ1evbWb51fZ5N29BZRykhud3gEefAvjKvoqGVYXBnBS8JqN1cqCpZg8qJqSPjn9dJNamSXJj/1/*)"

The above should simplify to the below:

gun init xpub "[AAB893A5/84'/0'/0']xpub661MyMwAqRbcFGjD5niBpcDJ1evbWb51fZ5N29BZRykhud3gEefAvjKvoqGVYXBnBS8JqN1cqCpZg8qJqSPjn9dJNamSXJj" 

Implementation

I think the way this information should be stored should just be in the WalletKey enum like:

enum WalletKey {
    SeedWordsFile,
    Descriptor  { external: String, internal: Option<String> }
} 

And in the config.json like:

{ 
   "kind": "descriptor",
   "external" : "wpkh([AAB893A5/84'/0'/0']xpub661MyMwAqRbcFGjD5niBpcDJ1evbWb51fZ5N29BZRykhud3gEefAvjKvoqGVYXBnBS8JqN1cqCpZg8qJqSPjn9dJNamSXJj/0/*)",
   "internal" "wpkh([AAB893A5/84'/0'/0']xpub661MyMwAqRbcFGjD5niBpcDJ1evbWb51fZ5N29BZRykhud3gEefAvjKvoqGVYXBnBS8JqN1cqCpZg8qJqSPjn9dJNamSXJj/1/*)"
}

Signing

I think the right thing to do is output the PSBT if a transaction is not finalized after signing. They should be output to psbt-output-dir (default should be $GUN_DIR/psbts). The filename should be <tentative-txid>.psbt. You can get the tentative-txid by doing psbt.extract_tx().txid().

At the moment let's just hang and wait for the user to sign the PSBT there. Whenever they press enter read the file back in and check if it has been signed. Once it has been signed, broadcast it.

Choosing the network

Right now we have a mandatory <network> argument to init. This should just be made into a optional --network argument with the default being "bitcoin"

Init with seed

The existing gun init should go under gun init seed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant