Skip to content

Commit

Permalink
Merge pull request #17 from xinshuhao/master
Browse files Browse the repository at this point in the history
修复cdp dex 签名错误bug
  • Loading branch information
xiaoshui208 authored Nov 19, 2019
2 parents 9fc0196 + dd99908 commit 54a3bc9
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 9 deletions.
6 changes: 4 additions & 2 deletions WaykichainWallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ func CheckPrivateKey(privateKey string, netType int) (bool, error) {
// netType: WAYKI_TESTNET or WAYKI_MAINTNET
func GetAddressFromMnemonic(words string, netType int) (string, error) {
wordArr:=strings.Split(words," ")
if(len(wordArr)!=12){
isValid:=commons.IsMnemonicValid(words)
if(len(wordArr)!=12||!isValid){
return "", ERR_INVALID_MNEMONIC
}
address := commons.GetAddressFromMnemonic(words, commons.Network(netType))
Expand All @@ -74,7 +75,8 @@ func GetAddressFromMnemonic(words string, netType int) (string, error) {
// netType: WAYKI_TESTNET or WAYKI_MAINTNET
func GetPrivateKeyFromMnemonic(words string, netType int) (string, error) {
wordArr:=strings.Split(words," ")
if(len(wordArr)!=12){
isValid:=commons.IsMnemonicValid(words)
if(len(wordArr)!=12||!isValid){
return "", ERR_INVALID_MNEMONIC
}
privateKey := commons.GetPrivateKeyFromMnemonic(words, commons.Network(netType))
Expand Down
2 changes: 1 addition & 1 deletion commons/WaykiCdpLiquidateTx.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (tx WaykiCdpLiquidateTx) doSignTx(wifKey *btcutil.WIF) []byte {
if(tx.UserId!=nil){
writer.WriteUserId(tx.UserId)
}else if(tx.PubKey!=nil){
writer.WriteReverse(tx.PubKey)
writer.WritePubKeyId(tx.PubKey)
}
writer.WriteString(tx.FeeSymbol)
writer.WriteVarInt(int64(tx.Fees))
Expand Down
2 changes: 1 addition & 1 deletion commons/WaykiCdpRedeemTx.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (tx WaykiCdpRedeemTx) doSignTx(wifKey *btcutil.WIF) []byte {
if(tx.UserId!=nil){
writer.WriteUserId(tx.UserId)
}else if(tx.PubKey!=nil){
writer.WriteReverse(tx.PubKey)
writer.WritePubKeyId(tx.PubKey)
}
writer.WriteString(tx.FeeSymbol)
writer.WriteVarInt(int64(tx.Fees))
Expand Down
2 changes: 1 addition & 1 deletion commons/WaykiCdpStakeTx.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (tx WaykiCdpStakeTx) doSignTx(wifKey *btcutil.WIF) []byte {
if(tx.UserId!=nil){
writer.WriteUserId(tx.UserId)
}else if(tx.PubKey!=nil){
writer.WriteReverse(tx.PubKey)
writer.WritePubKeyId(tx.PubKey)
}
writer.WriteString(tx.FeeSymbol)
writer.WriteVarInt(int64(tx.Fees))
Expand Down
2 changes: 1 addition & 1 deletion commons/WaykiDexCancelTx.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (tx WaykiDexCancelTx) doSignTx(wifKey *btcutil.WIF) []byte {
if(tx.UserId!=nil){
writer.WriteUserId(tx.UserId)
}else if(tx.PubKey!=nil){
writer.WriteReverse(tx.PubKey)
writer.WritePubKeyId(tx.PubKey)
}
writer.WriteString(tx.FeeSymbol)
writer.WriteVarInt(int64(tx.Fees))
Expand Down
2 changes: 1 addition & 1 deletion commons/WaykiDexLimitTx.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (tx WaykiDexSellLimitTx) doSignTx(wifKey *btcutil.WIF) []byte {
if(tx.UserId!=nil){
writer.WriteUserId(tx.UserId)
}else if(tx.PubKey!=nil){
writer.WriteReverse(tx.PubKey)
writer.WritePubKeyId(tx.PubKey)
}
writer.WriteString(tx.FeeSymbol)
writer.WriteVarInt(int64(tx.Fees))
Expand Down
2 changes: 1 addition & 1 deletion commons/WaykiDexMarketTx.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (tx WaykiDexMarketTx) doSignTx(wifKey *btcutil.WIF) []byte {
if(tx.UserId!=nil){
writer.WriteUserId(tx.UserId)
}else if(tx.PubKey!=nil){
writer.WriteReverse(tx.PubKey)
writer.WritePubKeyId(tx.PubKey)
}
writer.WriteString(tx.FeeSymbol)
writer.WriteVarInt(int64(tx.Fees))
Expand Down
2 changes: 1 addition & 1 deletion commons/WaykiUCoinTransferTx.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (tx WaykiUCoinTransferTx) doSignTx(wifKey *btcutil.WIF) []byte {
if(tx.UserId!=nil){
writer.WriteUserId(tx.UserId)
}else if(tx.PubKey!=nil){
writer.WriteReverse(tx.PubKey)
writer.WritePubKeyId(tx.PubKey)
}
writer.WriteString(tx.FeeSymbol)
writer.WriteVarInt(int64(tx.Fees))
Expand Down

0 comments on commit 54a3bc9

Please sign in to comment.