Skip to content

Commit

Permalink
[cgo] refs fibercrypto#105 Correcting errors in memory for `cipher.bi…
Browse files Browse the repository at this point in the history
…tcoin` for export to pyskycoin and libjava
  • Loading branch information
Maykel Arias Torres committed Sep 22, 2019
1 parent f5dc163 commit 9db5dc0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
18 changes: 10 additions & 8 deletions lib/cgo/cipher.bitcoin.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ package main
import "C"

import (
"reflect"
"unsafe"

cipher "github.com/skycoin/skycoin/src/cipher"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -98,13 +100,13 @@ 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
func SKY_cipher_BitcoinAddress_Checksum(_addr *C.cipher__BitcoinAddress, _arg0 *C.cipher__Checksum) {
addr := (*cipher.BitcoinAddress)(unsafe.Pointer(_addr))
cs := addr.Checksum()
C.memcpy(unsafe.Pointer(_arg0), unsafe.Pointer(&cs[0]), C.size_t(len(cs)))
}
}
5 changes: 3 additions & 2 deletions lib/cgo/cipher.crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 9db5dc0

Please sign in to comment.