Skip to content

Commit

Permalink
Merge pull request #10 from xinshuhao/master
Browse files Browse the repository at this point in the history
去除多余引用,修复一些bug
  • Loading branch information
Dragon Master authored Jun 15, 2019
2 parents de5eae6 + 35dc1e7 commit d7bd2fd
Show file tree
Hide file tree
Showing 28 changed files with 1,135 additions and 997 deletions.
8 changes: 4 additions & 4 deletions WaykichainWallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ func GenerateMnemonics() string {
//助记词转换地址
// netType: WAYKI_TESTNET or WAYKI_MAINTNET
func GetAddressFromMnemonic(words string, netType int) string {
address := commons.GenerateAddress(words, commons.Network(netType))
address := commons.GetAddressFromMnemonic(words, commons.Network(netType))
return address
}

//助记词转私钥
// netType: WAYKI_TESTNET or WAYKI_MAINTNET
func GetPrivateKeyFromMnemonic(words string, netType int) string {
privateKey := commons.GeneratePrivateKey(words, commons.Network(netType))
privateKey := commons.GetPrivateKeyFromMnemonic(words, commons.Network(netType))
return privateKey
}

//GetAddressFromPrivateKey get address from private key
// netType: WAYKI_TESTNET or WAYKI_MAINTNET
func GetAddressFromPrivateKey(words string, netType int) string {
address := commons.ImportPrivateKey(words, commons.Network(netType))
func GetAddressFromPrivateKey(privateKey string, netType int) string {
address := commons.GetAddressFromPrivateKey(privateKey, commons.Network(netType))
return address
}

Expand Down
18 changes: 9 additions & 9 deletions WaykichainWallet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestGetAddressFromMnemonic(t *testing.T) {
mnemonic := "empty regular curve turtle student prize toy accuse develop spike scatter ginger"
//seed := bip.NewSeed(mnemonic, "")
////fmt.Println(hex.EncodeToString(seed))
address := GetAddressFromMnemonic(mnemonic, WAYKI_MAINTNET)
address := GetAddressFromMnemonic(mnemonic, WAYKI_TESTNET)
if address == "" {
t.Error("GenerateAddress err!")
}
Expand Down Expand Up @@ -79,9 +79,9 @@ func TestSignDelegateTx(t *testing.T) {

func TestSignRegisterAccountTx(t *testing.T) {

privateKey := "Y9sx4Y8sBAbWDAqAWytYuUnJige3ZPwKDZp1SCDqqRby1YMgRG9c"
privateKey := "YAa1wFCfFnZ5bt4hg9MDeDevTMd1Nu874Mn83hEXwtfAL2vkQE9f"//"Y9sx4Y8sBAbWDAqAWytYuUnJige3ZPwKDZp1SCDqqRby1YMgRG9c"
var txParam RegisterAccountTxParam
txParam.ValidHeight = 7783
txParam.ValidHeight = 630314
txParam.Fees = 10000

hash, err := SignRegisterAccountTx(privateKey, &txParam)
Expand All @@ -93,10 +93,10 @@ func TestSignRegisterAccountTx(t *testing.T) {

func TestSignCommonTx(t *testing.T) {

privateKey := "Y7V1jwCRr8D3tyPTkcsjgBTHwZN45b1U3ueZfJ5oWVJqwcKpArou"
privateKey := "YAa1wFCfFnZ5bt4hg9MDeDevTMd1Nu874Mn83hEXwtfAL2vkQE9f"//"Y7V1jwCRr8D3tyPTkcsjgBTHwZN45b1U3ueZfJ5oWVJqwcKpArou"
var txParams CommonTxParam
txParams.ValidHeight = 14897
txParams.SrcRegId = "158-1"
txParams.ValidHeight = 630314//14897
txParams.SrcRegId = "630318-2"//"158-1"
txParams.DestAddr = "wSSbTePArv6BkDsQW9gpGCTX55AXVxVKbd"
txParams.Values = 10000
txParams.Fees = 10000
Expand All @@ -110,16 +110,16 @@ func TestSignCommonTx(t *testing.T) {

func TestSignRegisterContractTx(t *testing.T) {

privateKey := "Y9sx4Y8sBAbWDAqAWytYuUnJige3ZPwKDZp1SCDqqRby1YMgRG9c"
privateKey := "YAa1wFCfFnZ5bt4hg9MDeDevTMd1Nu874Mn83hEXwtfAL2vkQE9f"//"Y9sx4Y8sBAbWDAqAWytYuUnJige3ZPwKDZp1SCDqqRby1YMgRG9c"

script, err := ioutil.ReadFile("./demo/data/hello.lua")
if err != nil {
t.Error("Read contract script file err: ", err)
}

var txParam RegisterContractTxParam
txParam.ValidHeight = 20999
txParam.SrcRegId = "7849-1"
txParam.ValidHeight = 630314//20999
txParam.SrcRegId = "630318-2"//"7849-1"
txParam.Fees = 110000000
txParam.Script = script
txParam.Description = "My hello contract!!!"
Expand Down
81 changes: 0 additions & 81 deletions commons/BIP44Util.go

This file was deleted.

3 changes: 2 additions & 1 deletion commons/WaykiCallContractTx.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/hex"

"github.com/btcsuite/btcutil"
hash2 "github.com/WaykiChain/wicc-wallet-utils-go/commons/hash"
)

type WaykiCallContractTx struct {
Expand Down Expand Up @@ -49,7 +50,7 @@ func (tx WaykiCallContractTx) doSignTx(wifKey *btcutil.WIF) []byte {
writer.WriteVarInt(int64(tx.Fees))
writer.WriteVarInt(int64(tx.Values))
writer.WriteBytes(tx.Contract)
hash, _ := HashDoubleSha256(buf.Bytes())
hash := hash2.DoubleHash256(buf.Bytes())

key := wifKey.PrivKey
ss, _ := key.Sign(hash)
Expand Down
3 changes: 2 additions & 1 deletion commons/WaykiCommonTx.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/hex"

"github.com/btcsuite/btcutil"
hash2 "github.com/WaykiChain/wicc-wallet-utils-go/commons/hash"
)

type WaykiCommonTx struct {
Expand Down Expand Up @@ -49,7 +50,7 @@ func (tx WaykiCommonTx) doSignTx(wifKey *btcutil.WIF) []byte {
writer.WriteVarInt(int64(tx.Values))
writer.WriteVarInt(0) // write the empty contract script data

hash, _ := HashDoubleSha256(buf.Bytes())
hash := hash2.DoubleHash256(buf.Bytes())
key := wifKey.PrivKey
ss, _ := key.Sign(hash)
return ss.Serialize()
Expand Down
3 changes: 2 additions & 1 deletion commons/WaykiDelegateTx.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/hex"

"github.com/btcsuite/btcutil"
hash2 "github.com/WaykiChain/wicc-wallet-utils-go/commons/hash"
)

type OperVoteFund struct {
Expand Down Expand Up @@ -58,7 +59,7 @@ func (tx WaykiDelegateTx) doSignTx(wifKey *btcutil.WIF) []byte {
writer.WriteVarInt(fund.VoteValue)
}
writer.WriteVarInt(int64(tx.Fees))
hash, _ := HashDoubleSha256(buf.Bytes())
hash := hash2.DoubleHash256(buf.Bytes())

key := wifKey.PrivKey
ss, _ := key.Sign(hash)
Expand Down
Loading

0 comments on commit d7bd2fd

Please sign in to comment.