-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
R4R: Make gaiacli keys show
multisig-ready
#2554
Changes from 5 commits
322a029
6ae767d
50a2f96
8d24465
ca049fd
230c69b
6ace08b
cd49e97
6664cd5
68f869a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,16 @@ package keys | |
|
||
import ( | ||
"fmt" | ||
"github.com/cosmos/cosmos-sdk/crypto/keys" | ||
"github.com/tendermint/tendermint/crypto" | ||
"net/http" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/gorilla/mux" | ||
"github.com/pkg/errors" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
"github.com/tendermint/tendermint/crypto/multisig" | ||
"github.com/tendermint/tendermint/libs/cli" | ||
) | ||
|
||
|
@@ -18,30 +22,61 @@ const ( | |
FlagPublicKey = "pubkey" | ||
// FlagBechPrefix defines a desired Bech32 prefix encoding for a key. | ||
FlagBechPrefix = "bech" | ||
|
||
flagMultiSigThreshold = "multisig-threshold" | ||
) | ||
|
||
var _ keys.Info = (keys.Info)(nil) | ||
alessio marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
type multiSigKey struct { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's presently not used elsewhere. |
||
name string | ||
key crypto.PubKey | ||
} | ||
|
||
func (m multiSigKey) GetName() string { return m.name } | ||
func (m multiSigKey) GetType() keys.KeyType { return keys.TypeLocal } | ||
func (m multiSigKey) GetPubKey() crypto.PubKey { return m.key } | ||
func (m multiSigKey) GetAddress() sdk.AccAddress { return sdk.AccAddress(m.key.Address()) } | ||
|
||
func showKeysCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "show [name]", | ||
Short: "Show key info for the given name", | ||
Long: `Return public details of one local key.`, | ||
Args: cobra.ExactArgs(1), | ||
Args: cobra.MinimumNArgs(1), | ||
RunE: runShowCmd, | ||
} | ||
|
||
cmd.Flags().String(FlagBechPrefix, "acc", "The Bech32 prefix encoding for a key (acc|val|cons)") | ||
cmd.Flags().Bool(FlagAddress, false, "output the address only (overrides --output)") | ||
cmd.Flags().Bool(FlagPublicKey, false, "output the public key only (overrides --output)") | ||
cmd.Flags().UintP(flagMultiSigThreshold, "m", 1, "K out of N required signatures") | ||
alessio marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return cmd | ||
} | ||
|
||
func runShowCmd(cmd *cobra.Command, args []string) error { | ||
name := args[0] | ||
func runShowCmd(cmd *cobra.Command, args []string) (err error) { | ||
var info keys.Info | ||
|
||
info, err := GetKeyInfo(name) | ||
if err != nil { | ||
return err | ||
if len(args) == 1 { | ||
info, err = GetKeyInfo(args[0]) | ||
if err != nil { | ||
return err | ||
} | ||
} else { | ||
pks := make([]crypto.PubKey, len(args)) | ||
alessio marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for i, keyName := range args { | ||
info, err := GetKeyInfo(keyName) | ||
if err != nil { | ||
return err | ||
} | ||
pks[i] = info.GetPubKey() | ||
} | ||
multikey := multisig.NewPubKeyMultisigThreshold(viper.GetInt(flagMultiSigThreshold), pks) | ||
info = multiSigKey{ | ||
name: "multi", | ||
alessio marked this conversation as resolved.
Show resolved
Hide resolved
|
||
key: multikey, | ||
} | ||
} | ||
|
||
isShowAddr := viper.GetBool(FlagAddress) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,6 +74,16 @@ gaiad tendermint show-validator | |
We strongly recommend _NOT_ using the same passphrase for multiple keys. The Tendermint team and the Interchain Foundation will not be responsible for the loss of funds. | ||
::: | ||
|
||
#### Multisig public keys | ||
|
||
You can generate and print a multisig public key by typing: | ||
|
||
```bash | ||
gaiacli show -m K key1 key2...keyK | ||
``` | ||
|
||
`K` is the minimum number of private keys that must have signed the transactions that carry the generated public key. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be minimum weight, and each shown key should show its own weight. |
||
|
||
### Account | ||
|
||
#### Get Tokens | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a case where we'd want this exposed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I there is presently no case for it to be exposed.