From 6bce3136e25cca6d54b23b874157481b1df1c3a7 Mon Sep 17 00:00:00 2001 From: Apisit Toompakdee Date: Mon, 30 Jul 2018 14:36:14 +0900 Subject: [PATCH] claim ong method --- neoutils/mobile_test.go | 8 ++++---- neoutils/ont.go | 14 ++++++++++++++ neoutils/ont_test.go | 14 ++++++++++++++ neoutils/utils_test.go | 6 +++--- neoutils/version.go | 5 ++++- 5 files changed, 39 insertions(+), 8 deletions(-) diff --git a/neoutils/mobile_test.go b/neoutils/mobile_test.go index dd7a388..8a7738e 100644 --- a/neoutils/mobile_test.go +++ b/neoutils/mobile_test.go @@ -10,7 +10,7 @@ import ( ) func TestMintTokensFromMobile(t *testing.T) { - scriptHash := "5f03828cb45198eedd659d264b6d3a1c889978ce" + scriptHash := "0x3e390ae61acb6713389c8fbbd47d1d69c32655a3" wif := "" wallet, _ := neoutils.GenerateFromWIF(wif) @@ -19,9 +19,9 @@ func TestMintTokensFromMobile(t *testing.T) { neo := string(smartcontract.NEO) // gas := string(smartcontract.GAS) amount := float64(2) - remark := "o3x" - network := "private" - networkFeeAmountInGAS := float64(0.0011) + remark := "O3XMOONLIGHT2" + network := "test" + networkFeeAmountInGAS := float64(0) tx, err := neoutils.MintTokensRawTransactionMobile(network, scriptHash, wif, neo, amount, remark, networkFeeAmountInGAS) if err != nil { log.Printf("%v", err) diff --git a/neoutils/ont.go b/neoutils/ont.go index a02c7e0..9d9d671 100644 --- a/neoutils/ont.go +++ b/neoutils/ont.go @@ -19,3 +19,17 @@ func OntologyTransfer(endpoint string, gasPrice int, gasLimit int, wif string, a return txid, nil } + +func ClaimONG(endpoint string, gasPrice int, gasLimit int, wif string) (string, error) { + raw, err := ontmobile.WithdrawONG(uint(gasPrice), uint(gasLimit), endpoint, wif) + if err != nil { + return "", err + } + + txid, err := ontmobile.SendRawTransaction(endpoint, fmt.Sprintf("%x", raw.Data)) + if err != nil { + return "", err + } + + return txid, nil +} diff --git a/neoutils/ont_test.go b/neoutils/ont_test.go index 70b6fe2..b6adebf 100644 --- a/neoutils/ont_test.go +++ b/neoutils/ont_test.go @@ -22,3 +22,17 @@ func TestONTTransfer(t *testing.T) { } log.Printf("tx id =%v", txid) } + +func TestClaimONG(t *testing.T) { + endpoint := "http://dappnode2.ont.io:20336" + wif, _ := neoutils.NEP2Decrypt("", "") + + gasPrice := int(500) + gasLimit := int(20000) + txid, err := neoutils.ClaimONG(endpoint, gasPrice, gasLimit, wif) + if err != nil { + log.Printf("err %v", err) + return + } + log.Printf("tx id =%v", txid) +} diff --git a/neoutils/utils_test.go b/neoutils/utils_test.go index c1533d9..0d8024a 100644 --- a/neoutils/utils_test.go +++ b/neoutils/utils_test.go @@ -29,7 +29,7 @@ func TestSmartContractScripthashToAddress(t *testing.T) { } func TestNEOAddressToScriptHash(t *testing.T) { - hash := NEOAddressToScriptHashWithEndian("AeNkbJdiMx49kBStQdDih7BzfDwyTNVRfb", binary.LittleEndian) + hash := NEOAddressToScriptHashWithEndian("ASi48wqdF9avm91pWwdphcAmaDJQkPNdNt", binary.LittleEndian) b, _ := hex.DecodeString(hash) log.Printf("\nlittle endian %v \nbig endian %x", hash, ReverseBytes(b)) } @@ -49,7 +49,7 @@ func TestValidateNEOAddressInvalidAddress(t *testing.T) { } func TestConverting(t *testing.T) { - hexByteArray := "07ca92e5b37b4fff" //500000000000000000 + hexByteArray := "c02709" //500000000000000000 //hex := "005c7c875e" = 405991873536 value := ConvertByteArrayToBigInt(hexByteArray) vvv := float64(value.Int64()) / float64(math.Pow10(8)) @@ -91,7 +91,7 @@ func TestHash256(t *testing.T) { } func TestPublicKeyToNEOAddress(t *testing.T) { - publicKey := "02ac3cecf6a5909c199fb5d6840577680c232fe3d5594c6514cc7897c4dd384728" + publicKey := "022c9652d3ad5cc065aa9147dc2ad022f80001e8ed233de20f352950d351d472b7" b, _ := hex.DecodeString(publicKey) address := PublicKeyToNEOAddress(b) log.Printf("%v", address) diff --git a/neoutils/version.go b/neoutils/version.go index d60d057..06b669b 100644 --- a/neoutils/version.go +++ b/neoutils/version.go @@ -1,11 +1,14 @@ package neoutils const ( - VERSION = "1.2.0" + VERSION = "1.2.1" ) //RELEASE NOTES +// V.1.2.1 +// - Added ClaimONG + // V.1.2.0 // - Added generate multisignature address redeem script // - Added gasPrice and gasLimit to ontology transfer method