Skip to content

Commit

Permalink
Merge pull request #13 from omisego/zero-x-inputs
Browse files Browse the repository at this point in the history
filter out '0x' if present in privatekey input
  • Loading branch information
Pongch authored Feb 19, 2019
2 parents ea5d7d2 + 04ee669 commit 89854a5
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions plasma_cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ func (d *plasmaDeposit) depositToPlasmaContract() {
if err != nil {
log.Fatal(err)
}

privateKey, err := crypto.HexToECDSA(d.privateKey)
privateKey, err := crypto.HexToECDSA(filterZeroX(d.privateKey))
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -407,7 +407,7 @@ func (s *standardExitUTXOData) plasmaStartStandardExit(ethereumClient string, co
log.Fatal(err)
}

privateKey, err := crypto.HexToECDSA(private)
privateKey, err := crypto.HexToECDSA(filterZeroX(private))
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -468,6 +468,15 @@ func removeLeadingZeroX(item string) string {
return cleanedString
}

//filter our key string with 0x
func filterZeroX(item string) string {
if strings.Contains(item, "0x") {
return removeLeadingZeroX(item)
} else {
return item
}
}

//Retrieve the UTXO exit data from the UTXO position
func getUTXOExitData(watcher string, utxoPosition int) standardExitUTXOData {
// Build request
Expand Down Expand Up @@ -523,7 +532,7 @@ func (p *processExit) plasmaProcessExits(numberExitsToProcess int64) {
log.Fatal(err)
}

privateKey, err := crypto.HexToECDSA(p.privateKey)
privateKey, err := crypto.HexToECDSA(filterZeroX(p.privateKey))
if err != nil {
log.Fatal(err)
}
Expand Down

0 comments on commit 89854a5

Please sign in to comment.