From 9db5dc0ea78a9070f298f47d7bc2d23cd7e00972 Mon Sep 17 00:00:00 2001 From: Maykel Arias Torres Date: Sat, 21 Sep 2019 21:57:57 -0400 Subject: [PATCH] [cgo] refs #105 Correcting errors in memory for `cipher.bitcoin` for export to pyskycoin and libjava --- lib/cgo/cipher.bitcoin.go | 18 ++++++++++-------- lib/cgo/cipher.crypto.go | 5 +++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/cgo/cipher.bitcoin.go b/lib/cgo/cipher.bitcoin.go index 24e9d3080..b66905dc8 100644 --- a/lib/cgo/cipher.bitcoin.go +++ b/lib/cgo/cipher.bitcoin.go @@ -10,6 +10,7 @@ package main import "C" import ( + "reflect" "unsafe" cipher "github.com/skycoin/skycoin/src/cipher" @@ -49,10 +50,10 @@ func SKY_cipher_BitcoinAddressFromSecKey(_secKey *C.cipher__SecKey, _arg1 *C.cip } //export SKY_cipher_BitcoinWalletImportFormatFromSeckey -func SKY_cipher_BitcoinWalletImportFormatFromSeckey(_seckey *C.cipher__SecKey, _arg1 *string) { +func SKY_cipher_BitcoinWalletImportFormatFromSeckey(_seckey *C.cipher__SecKey, _arg1 *C.GoString_) { seckey := (*cipher.SecKey)(unsafe.Pointer(_seckey)) - *_arg1 = cipher.BitcoinWalletImportFormatFromSeckey(*seckey) - + s := cipher.BitcoinWalletImportFormatFromSeckey(*seckey) + copyString(s, _arg1) } //export SKY_cipher_BitcoinAddressFromBytes @@ -82,9 +83,10 @@ func SKY_cipher_BitcoinAddress_Null(_addr *C.cipher__BitcoinAddress) bool { } //export SKY_cipher_BitcoinAddress_Bytes -func SKY_cipher_BitcoinAddress_Bytes(_addr *C.cipher__BitcoinAddress, _arg0 *[]byte) { +func SKY_cipher_BitcoinAddress_Bytes(_addr *C.cipher__BitcoinAddress, _arg0 *C.GoSlice_) { addr := (*cipher.BitcoinAddress)(unsafe.Pointer(_addr)) - *_arg0 = addr.Bytes() + bytes := addr.Bytes() + copyToGoSlice(reflect.ValueOf(bytes), _arg0) } //export SKY_cipher_BitcoinAddress_Verify @@ -98,8 +100,8 @@ func SKY_cipher_BitcoinAddress_Verify(_addr *C.cipher__BitcoinAddress, _key *C.c //export SKY_cipher_BitcoinAddress_String func SKY_cipher_BitcoinAddress_String(_addr *C.cipher__BitcoinAddress, _arg1 *C.GoString_) { addr := (*cipher.BitcoinAddress)(unsafe.Pointer(_addr)) - __arg1 := addr.String() - copyString(__arg1,_arg1) + s := addr.String() + copyString(s, _arg1) } //export SKY_cipher_BitcoinAddress_Checksum @@ -107,4 +109,4 @@ func SKY_cipher_BitcoinAddress_Checksum(_addr *C.cipher__BitcoinAddress, _arg0 * addr := (*cipher.BitcoinAddress)(unsafe.Pointer(_addr)) cs := addr.Checksum() C.memcpy(unsafe.Pointer(_arg0), unsafe.Pointer(&cs[0]), C.size_t(len(cs))) -} +} \ No newline at end of file diff --git a/lib/cgo/cipher.crypto.go b/lib/cgo/cipher.crypto.go index faa78c9a3..9f262006a 100644 --- a/lib/cgo/cipher.crypto.go +++ b/lib/cgo/cipher.crypto.go @@ -130,9 +130,10 @@ func SKY_cipher_SecKey_Verify(_sk *C.cipher__SecKey) (____error_code uint32) { } //export SKY_cipher_SecKey_Hex -func SKY_cipher_SecKey_Hex(_sk *C.cipher__SecKey, _arg1 *string) (____error_code uint32) { +func SKY_cipher_SecKey_Hex(_sk *C.cipher__SecKey, _arg1 *C.GoString_) (____error_code uint32) { sk := (*cipher.SecKey)(unsafe.Pointer(_sk)) - *_arg1 = sk.Hex() + __arg1 := sk.Hex() + copyString(__arg1, _arg1) return }