From dd99908e15ef2a7720aa82d5a7448b52f70e1cad Mon Sep 17 00:00:00 2001 From: xinshuhao Date: Tue, 19 Nov 2019 15:15:01 +0800 Subject: [PATCH] fix bug --- WaykichainWallet.go | 6 ++++-- commons/WaykiCdpLiquidateTx.go | 2 +- commons/WaykiCdpRedeemTx.go | 2 +- commons/WaykiCdpStakeTx.go | 2 +- commons/WaykiDexCancelTx.go | 2 +- commons/WaykiDexLimitTx.go | 2 +- commons/WaykiDexMarketTx.go | 2 +- commons/WaykiUCoinTransferTx.go | 2 +- 8 files changed, 11 insertions(+), 9 deletions(-) diff --git a/WaykichainWallet.go b/WaykichainWallet.go index c964831..ba4e6d9 100644 --- a/WaykichainWallet.go +++ b/WaykichainWallet.go @@ -61,7 +61,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)) @@ -72,7 +73,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)) diff --git a/commons/WaykiCdpLiquidateTx.go b/commons/WaykiCdpLiquidateTx.go index 3f245c6..88e544d 100644 --- a/commons/WaykiCdpLiquidateTx.go +++ b/commons/WaykiCdpLiquidateTx.go @@ -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)) diff --git a/commons/WaykiCdpRedeemTx.go b/commons/WaykiCdpRedeemTx.go index 73e1054..428feba 100644 --- a/commons/WaykiCdpRedeemTx.go +++ b/commons/WaykiCdpRedeemTx.go @@ -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)) diff --git a/commons/WaykiCdpStakeTx.go b/commons/WaykiCdpStakeTx.go index 3879ec3..daebf45 100644 --- a/commons/WaykiCdpStakeTx.go +++ b/commons/WaykiCdpStakeTx.go @@ -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)) diff --git a/commons/WaykiDexCancelTx.go b/commons/WaykiDexCancelTx.go index f79be59..fb14805 100644 --- a/commons/WaykiDexCancelTx.go +++ b/commons/WaykiDexCancelTx.go @@ -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)) diff --git a/commons/WaykiDexLimitTx.go b/commons/WaykiDexLimitTx.go index d8f2a57..0dd4e86 100644 --- a/commons/WaykiDexLimitTx.go +++ b/commons/WaykiDexLimitTx.go @@ -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)) diff --git a/commons/WaykiDexMarketTx.go b/commons/WaykiDexMarketTx.go index 1cb8f05..dcc6866 100644 --- a/commons/WaykiDexMarketTx.go +++ b/commons/WaykiDexMarketTx.go @@ -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)) diff --git a/commons/WaykiUCoinTransferTx.go b/commons/WaykiUCoinTransferTx.go index a15a84f..e767d74 100644 --- a/commons/WaykiUCoinTransferTx.go +++ b/commons/WaykiUCoinTransferTx.go @@ -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))