-
Notifications
You must be signed in to change notification settings - Fork 0
[Feat] Add XRPL #67
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
base: main
Are you sure you want to change the base?
[Feat] Add XRPL #67
Changes from 12 commits
c1282ce
3b2095c
702a869
6637368
ffe4457
d66cf75
98e393e
a663316
b65571a
a4d5e6b
4c14139
d1f39ff
c9afe1e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,8 +15,9 @@ import ( | |
|
|
||
| const ( | ||
| privateKeyLabel = "Private key (provide an existing private key)" | ||
| familySeedLabel = "Family seed (provide an existing family seed)" | ||
| mnemonicLabel = "Mnemonic (recover from an existing mnemonic phrase)" | ||
| defaultLabel = "Generate new address (no private key or mnemonic needed)" | ||
| defaultLabel = "Generate new address (no secret or mnemonic needed)" | ||
| ) | ||
|
|
||
| const ( | ||
|
|
@@ -28,6 +29,7 @@ const ( | |
| // AddKeyInput is the input for adding a key to the keychain. | ||
| type AddKeyInput struct { | ||
| PrivateKey string | ||
| FamilySeed string | ||
| Mnemonic string | ||
| CoinType uint64 | ||
| Account uint64 | ||
|
|
@@ -92,7 +94,7 @@ keys add eth test-key`), | |
|
|
||
| // if no private key, mnemonic, or remote signer info is provided, prompt interactively | ||
| if input.PrivateKey == "" && input.Mnemonic == "" && input.RemoteSigner.Address == "" && | ||
| input.RemoteSigner.Url == "" { | ||
| input.RemoteSigner.Url == "" && input.FamilySeed == "" { | ||
| input, err = showHuhPrompt() | ||
| if err != nil { | ||
| return err | ||
|
|
@@ -119,6 +121,7 @@ keys add eth test-key`), | |
| } | ||
|
|
||
| cmd.Flags().String(flagPrivateKey, "", "add key with the given private key") | ||
| cmd.Flags().String(flagFamilySeed, "", "add key with the given family seed") | ||
| cmd.Flags().String(flagMnemonic, "", "add key with the given mnemonic") | ||
| cmd.Flags().Uint64(flagCoinType, defaultCoinType, "coin type number for HD derivation") | ||
| cmd.Flags().Uint64(flagWalletAccount, 0, "account number in the HD derivation path") | ||
|
Comment on lines
123
to
127
|
||
|
|
@@ -281,14 +284,20 @@ func validateAddKeyInput(input *AddKeyInput) error { | |
| hasPrivateKey := input.PrivateKey != "" | ||
| hasMnemonic := input.Mnemonic != "" | ||
| hasRemoteSigner := input.RemoteSigner.Address != "" || input.RemoteSigner.Url != "" | ||
| hasFamilySeed := input.FamilySeed != "" | ||
|
|
||
| // if a private key is provided, no other input should be present | ||
| if hasPrivateKey && (hasMnemonic || hasRemoteSigner) { | ||
| if hasPrivateKey && (hasMnemonic || hasRemoteSigner || hasFamilySeed) { | ||
| return fmt.Errorf("private key cannot be provided with mnemonic or remote signer") | ||
| } | ||
|
|
||
| // if a family seed is provided, no other input should be present | ||
| if hasFamilySeed && (hasPrivateKey || hasMnemonic || hasRemoteSigner) { | ||
| return fmt.Errorf("family seed cannot be provided with private key or remote signer") | ||
| } | ||
|
|
||
| // if a mnemonic is provided, no other input should be present | ||
| if hasMnemonic && (hasPrivateKey || hasRemoteSigner) { | ||
| if hasMnemonic && (hasPrivateKey || hasRemoteSigner || hasFamilySeed) { | ||
| return fmt.Errorf("mnemonic cannot be provided with private key or remote signer") | ||
| } | ||
tanut32039 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
@@ -434,6 +443,11 @@ func parseKeysAddInputFromFlag(cmd *cobra.Command) (*AddKeyInput, error) { | |
| return nil, err | ||
| } | ||
|
|
||
| input.FamilySeed, err = cmd.Flags().GetString(flagFamilySeed) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| input.PrivateKey, err = cmd.Flags().GetString(flagPrivateKey) | ||
| if err != nil { | ||
tanut32039 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return nil, err | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.