(ctx *cli.Context)
| 77 | } |
| 78 | |
| 79 | func genMultiSigAddress(ctx *cli.Context) error { |
| 80 | pkstr := strings.TrimSpace(strings.Trim(ctx.String(utils.GetFlagName(utils.AccountMultiPubKeyFlag)), ",")) |
| 81 | m := ctx.Uint(utils.GetFlagName(utils.AccountMultiMFlag)) |
| 82 | if pkstr == "" || m == 0 { |
| 83 | PrintErrorMsg("Missing argument. %s or %s expected.", |
| 84 | utils.GetFlagName(utils.AccountMultiMFlag), |
| 85 | utils.GetFlagName(utils.AccountMultiPubKeyFlag)) |
| 86 | cli.ShowSubcommandHelp(ctx) |
| 87 | return nil |
| 88 | } |
| 89 | |
| 90 | pks := strings.Split(pkstr, ",") |
| 91 | pubKeys := make([]keypair.PublicKey, 0, len(pks)) |
| 92 | for _, pk := range pks { |
| 93 | pk := strings.TrimSpace(pk) |
| 94 | if pk == "" { |
| 95 | continue |
| 96 | } |
| 97 | data, err := hex.DecodeString(pk) |
| 98 | pubKey, err := keypair.DeserializePublicKey(data) |
| 99 | if err != nil { |
| 100 | return fmt.Errorf("invalid pub key:%s", pk) |
| 101 | } |
| 102 | pubKeys = append(pubKeys, pubKey) |
| 103 | } |
| 104 | pkSize := len(pubKeys) |
| 105 | if !(1 <= m && int(m) <= pkSize && pkSize > 1 && pkSize <= constants.MULTI_SIG_MAX_PUBKEY_SIZE) { |
| 106 | PrintErrorMsg("Invalid argument. %s must > 1 and <= %d, and m must > 0 and < number of pub key.", |
| 107 | utils.GetFlagName(utils.AccountMultiPubKeyFlag), |
| 108 | constants.MULTI_SIG_MAX_PUBKEY_SIZE) |
| 109 | cli.ShowSubcommandHelp(ctx) |
| 110 | return nil |
| 111 | } |
| 112 | addr, err := types.AddressFromMultiPubKeys(pubKeys, int(m)) |
| 113 | if err != nil { |
| 114 | return err |
| 115 | } |
| 116 | |
| 117 | PrintInfoMsg("Pub key list:") |
| 118 | for i, pubKey := range pubKeys { |
| 119 | addr := types.AddressFromPubKey(pubKey) |
| 120 | PrintInfoMsg("Index %d Address:%s PubKey:%x ", i+1, addr.ToBase58(), keypair.SerializePublicKey(pubKey)) |
| 121 | } |
| 122 | PrintInfoMsg("\nMultiSigAddress:%s", addr.ToBase58()) |
| 123 | return nil |
| 124 | } |
| 125 | |
| 126 | func multiSigToTx(ctx *cli.Context) error { |
| 127 | SetRpcPort(ctx) |
nothing calls this directly
no test coverage detected