diff --git a/CHANGELOG.md b/CHANGELOG.md index 87956e3a9..a104a288f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -99,6 +99,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Added function `SKY_cli_GetWalletOutputs` - Added function `SKY_cli_GetBalanceOfAddresses` - Added datatype `GetOutputser__Handle` +- Added functions `SKY_coin_DeserializeTransactionHex` ### Removed diff --git a/lib/cgo/cipher.bip32.path.go b/lib/cgo/cipher.bip32.path.go index 93650079e..09c544d62 100644 --- a/lib/cgo/cipher.bip32.path.go +++ b/lib/cgo/cipher.bip32.path.go @@ -63,7 +63,7 @@ func SKY_bip32_Path_GetElements(handle C.Path__Handle, post int, _arg0 *C.bip32_ ____error_code = SKY_BAD_HANDLE return } - + *_arg0 = *(*C.bip32__PathNode)(unsafe.Pointer(&p.Elements[post])) return -} \ No newline at end of file +} diff --git a/lib/cgo/cipher.bip44.bip44.go b/lib/cgo/cipher.bip44.bip44.go index 5703fed6e..92192d099 100644 --- a/lib/cgo/cipher.bip44.bip44.go +++ b/lib/cgo/cipher.bip44.bip44.go @@ -96,6 +96,6 @@ func SKY_bip44_Account_GetPrivateKey(_a C.Account__Handle, _arg0 *C.PrivateKey__ return } - * _arg0 = registerPrivateKeyHandle(a.PrivateKey) + *_arg0 = registerPrivateKeyHandle(a.PrivateKey) return -} \ No newline at end of file +} diff --git a/lib/cgo/coin.transactions.go b/lib/cgo/coin.transactions.go index 2f92fecc8..53981872c 100644 --- a/lib/cgo/coin.transactions.go +++ b/lib/cgo/coin.transactions.go @@ -734,3 +734,15 @@ func SKY_coin_Transaction_SetInnerHash(handle *C.Transaction__Handle, _sha *C.ci tx.InnerHash = uxHash return } + +//export SKY_coin_DeserializeTransactionHex +func SKY_coin_DeserializeTransactionHex(_s string, _arg0 *C.Transaction__Handle) (___error_code uint32) { + + arg0, err := coin.DeserializeTransactionHex(_s) + + ___error_code = libErrorCode(err) + if err == nil { + *_arg0 = registerTransactionHandle(&arg0) + } + return +} diff --git a/lib/cgo/libsky_handle_helper.go b/lib/cgo/libsky_handle_helper.go index df78ea650..395af7871 100644 --- a/lib/cgo/libsky_handle_helper.go +++ b/lib/cgo/libsky_handle_helper.go @@ -142,11 +142,11 @@ func SKY_Handle_Strings_Sort(handle C.Strings__Handle) uint32 { } //export SKY_Handle_Strings_GetAt -func SKY_Handle_Strings_GetAt(handle C.Strings__Handle, index int, str *C.GoString_) uint32 { +func SKY_Handle_Strings_GetAt(handle C.Strings__Handle, index int, str *string) uint32 { obj, ok := lookupStringsHandle(handle) if ok { - copyString(obj[index], str) + *str = obj[index] return SKY_OK } @@ -165,6 +165,17 @@ func SKY_Handle_Strings_SetAt(handle C.Strings__Handle, index int, str *string) return SKY_OK } +//nolint megacheck +//export SKY_Handle_Strings_Get +func SKY_Handle_Strings_Get(handle C.Strings__Handle, arg0 *[]string) uint32 { + obj, ok := lookupStringsHandle(handle) + if !ok { + return SKY_BAD_HANDLE + } + arg0 = &obj + return SKY_OK +} + //export SKY_api_Handle_Client_GetWalletDir func SKY_api_Handle_Client_GetWalletDir(handle C.Client__Handle, walletDir *C.GoString_) uint32 { client, ok := lookupClientHandle(handle) diff --git a/lib/cgo/libsky_mem.go b/lib/cgo/libsky_mem.go index 0b1e64b94..cb84945fc 100644 --- a/lib/cgo/libsky_mem.go +++ b/lib/cgo/libsky_mem.go @@ -154,4 +154,4 @@ func copyTocoin_UxArray(src reflect.Value, dest *C.coin__UxArray) { dest.len = C.GoInt_(srcLen) } } -} \ No newline at end of file +} diff --git a/lib/cgo/params.distribution.go b/lib/cgo/params.distribution.go index 80239bff9..46e61f0b1 100644 --- a/lib/cgo/params.distribution.go +++ b/lib/cgo/params.distribution.go @@ -118,7 +118,8 @@ func SKY_params_Distribution_GetAddresses(_d C.Distribution__Handle, _arg0 *C.St ____error_code = SKY_BAD_HANDLE return } - *_arg0 = registerStringsHandle(d.Addresses) + arg0 := d.Addresses + *_arg0 = registerStringsHandle(arg0) return } @@ -229,13 +230,7 @@ func SKY_params_Distribution_LockedAddressesDecoded(_d C.Distribution__Handle, _ //export SKY_params_Distribution_GetMainNetDistribution func SKY_params_Distribution_GetMainNetDistribution(_d *C.Distribution__Handle) (____error_code uint32) { - d, ok := lookupDistributionHandle(*_d) - if !ok { - ____error_code = SKY_BAD_HANDLE - return - } - *d = params.MainNetDistribution - *_d = registerDistributionHandle(d) + *_d = registerDistributionHandle(¶ms.MainNetDistribution) return } diff --git a/lib/cgo/tests/check_cipher.bitcoin.c b/lib/cgo/tests/check_cipher.bitcoin.c index a6073fce1..d86879dcc 100644 --- a/lib/cgo/tests/check_cipher.bitcoin.c +++ b/lib/cgo/tests/check_cipher.bitcoin.c @@ -40,18 +40,16 @@ START_TEST(TestBitcoinAddress) error = SKY_cipher_PubKeyFromHex(*pubKeyStr, &pubkey); ck_assert_msg(error == SKY_OK, "Create PubKey from Hex"); - GoString_ str = {NULL, 0}; + GoString str = {NULL, 0}; SKY_cipher_BitcoinAddressFromPubKey(&pubkey, &btcAddr); SKY_cipher_BitcoinAddress_String(&btcAddr, &str); - registerMemCleanup((void*)str.p); - GoString tmpStr = {str.p, str.n}; - ck_assert_str_eq(str.p, addrStr->p); + ck_assert(isGoStringEq(*addrStr, str)); error = SKY_cipher_BitcoinAddressFromSecKey(&seckey, &btcAddr); ck_assert(error == SKY_OK); GoString_ tmpstr = {buff, 0}; - SKY_cipher_BitcoinAddress_String(&btcAddr, &tmpstr); - ck_assert_str_eq(tmpStr.p, addrStr->p); + SKY_cipher_BitcoinAddress_String(&btcAddr, &str); + ck_assert(isGoStringEq(*addrStr, str)); } } END_TEST diff --git a/lib/cgo/tests/check_coin.transactions.c b/lib/cgo/tests/check_coin.transactions.c index 5472679bf..075d6fe4b 100644 --- a/lib/cgo/tests/check_coin.transactions.c +++ b/lib/cgo/tests/check_coin.transactions.c @@ -618,12 +618,10 @@ START_TEST(TestTransactionSerialization) Transaction__Handle handle = 0; makeTransaction(&handle); unsigned char buffer[1024]; - GoSlice_ data = {buffer, 0, 1024}; - result = SKY_coin_Transaction_Serialize(handle, &data); + GoSlice d = {buffer, 0, 1024}; + result = SKY_coin_Transaction_Serialize(handle, &d); ck_assert(result == SKY_OK); - registerMemCleanup(data.data); Transaction__Handle handle2 = 0; - GoSlice d = {data.data, data.len, data.cap}; result = SKY_coin_TransactionDeserialize(d, &handle2); ck_assert(result == SKY_OK); ck_assert(isTransactionHandleEq(&handle, &handle2)); diff --git a/lib/cgo/tests/cipher.testsuite.c b/lib/cgo/tests/cipher.testsuite.c index 169d7601b..6f2d7bda5 100644 --- a/lib/cgo/tests/cipher.testsuite.c +++ b/lib/cgo/tests/cipher.testsuite.c @@ -393,7 +393,7 @@ void ValidateSeedData(SeedTestData* seedData, InputTestData* inputData) keys.len = keys.cap = 0; keys.data = NULL; - SKY_cipher_GenerateDeterministicKeyPairs(seedData->Seed, seedData->Keys.len, (GoSlice_*)&keys); + SKY_cipher_GenerateDeterministicKeyPairs(seedData->Seed, seedData->Keys.len, &keys); ck_assert_msg(keys.data != NULL, "SKY_cipher_GenerateDeterministicKeyPairs must allocate memory slice with zero cap"); diff --git a/lib/swig/dynamic/mem.i b/lib/swig/dynamic/mem.i index 03c68d100..01572a325 100644 --- a/lib/swig/dynamic/mem.i +++ b/lib/swig/dynamic/mem.i @@ -25,7 +25,7 @@ GoStringMap, PasswordReader__Handle_, Transaction__Handle, Transactions__Handle, CreatedTransaction__Handle, CreatedTransactionOutput__Handle, CreatedTransactionInput__Handle, CreateTransactionResponse__Handle, - Block__Handle, SignedBlock__Handle, BlockBody__Handle, BuildInfo_Handle, Number_Handle, Signature_Handle,AddressUxOuts_Handle + Block__Handle, SignedBlock__Handle, BlockBody__Handle, BuildInfo_Handle, Number_Handle, Signature_Handle,AddressUxOuts_Handle,Distribution__Handle } %apply Handle* { Wallet__Handle*, Options__Handle*, ReadableEntry__Handle*, ReadableWallet__Handle*, WebRpcClient__Handle*, @@ -33,5 +33,5 @@ CLI__Handle*, Context__Handle*, GoStringMap_*, PasswordReader__Handle*, Transaction__Handle*, Transactions__Handle*, CreatedTransaction__Handle*, CreatedTransactionOutput__Handle*, CreatedTransactionInput__Handle*, CreateTransactionResponse__Handle*, - Block__Handle*, SignedBlock__Handle*, BlockBody__Handle*, BuildInfo_Handle*, Number_Handle*, Signature_Handle*,AddressUxOuts_Handle* + Block__Handle*, SignedBlock__Handle*, BlockBody__Handle*, BuildInfo_Handle*, Number_Handle*, Signature_Handle*,AddressUxOuts_Handle*,Distribution__Handle* } \ No newline at end of file