Skip to content

Commit

Permalink
support 2 and 3 pubkey wallets
Browse files Browse the repository at this point in the history
  • Loading branch information
cbarraford committed Jul 9, 2019
1 parent c43ffd7 commit 2000d70
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions x/multisig/client/rest/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ func transactionsHandler(cliCtx context.CLIContext, storeName string) http.Handl

type multiSign struct {
Signatures []string `json:"signatures"`
Slots string `json:"slots"`
}

func multiSignHandler(cliCtx context.CLIContext) http.HandlerFunc {
Expand Down Expand Up @@ -137,8 +138,42 @@ func multiSignHandler(cliCtx context.CLIContext) http.HandlerFunc {
}
}

// prepend base string "CgUIAhIBwB"
signatures = append([]string{"CgUIAhIBwB"}, signatures...)
var totalPrefix string
switch len(slots) {
case 2:
totalPrefix = "Ah"
slots = fmt.Printf("%s0", slots)
case 3:
totalPrefix = "Ax"
//case 4:
//totalPrefix = "BB"
default:
rest.WriteErrorResponse(w, http.StatusBadRequest, fmt.Sprintf("Number of public keys (%d) in this wallet is not currently supported", len(slots)))
}

var sigPrefix string
switch slots {
case "001":
sigPrefix = "IB"
case "010":
sigPrefix = "QB"
case "011":
sigPrefix = "YB"
case "100":
sigPrefix = "qB"
case "101":
sigPrefix = "oB"
case "110":
sigPrefix = "wB"
case "111":
sigPrefix = "4B"
default:
rest.WriteErrorResponse(w, http.StatusBadRequest, fmt.Sprintf("Number of public keys (%d) in this wallet is not currently supported", len(slots)))
}

prefix := fmt.Sprintf("CgUI%sIB%s", totalPrefix, sigPrefix)

signatures = append([]string{prefix}, signatures...)
multisignature := strings.Join(signatures[:], "JA")

w.Header().Set("Content-Type", "application/json; charset=utf-8")
Expand Down

0 comments on commit 2000d70

Please sign in to comment.