Skip to content

Commit

Permalink
[cgo] refs fibercrypto#116 Finalized cipher.bip44
Browse files Browse the repository at this point in the history
  • Loading branch information
Maykel Arias Torres committed Jan 18, 2020
1 parent 659c57a commit 61b077e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 60 deletions.
2 changes: 1 addition & 1 deletion include/cipher.bip44.bip44.go.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
typedef GoUint32_ bip44_CoinType;
typedef GoUint32_ bip44__CoinType;
91 changes: 32 additions & 59 deletions lib/cgo/cipher.bip44.bip44.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package main

import (
"unsafe"

"github.com/SkycoinProject/skycoin/src/cipher/bip44"
)

Expand All @@ -10,93 +12,64 @@ import (
#include <stdlib.h>
#include "skytypes.h"
#include "skyfee.h"
*/
import "C"

//export SKY_bip44_NewCoin
func SKY_bip44_NewCoin(_seed []byte, _coinType uint32, _arg0 *C.Coin__Handle) (___err_code uint32) {
__arg0, ___return_err := bip44.NewCoin(_seed, bip44.CoinType(_coinType))
___err_code = libErrorCode(___return_err)
if ___return_err == nil {
*_arg0 = registerCoinHandle(__arg0)
func SKY_bip44_NewCoin(_seed []byte, _coinType *C.bip44__CoinType, _arg2 *C.Coin__Handle) (____error_code uint32) {
seed := *(*[]byte)(unsafe.Pointer(&_seed))
coinType := *(*bip44.CoinType)(unsafe.Pointer(_coinType))
__arg2, ____return_err := bip44.NewCoin(seed, coinType)
____error_code = libErrorCode(____return_err)
if ____return_err == nil {
*_arg2 = registerCoinHandle(__arg2)
}
return
}

//export SKY_bip44_Coin_Account
func SKY_bip44_Coin_Account(_c C.Coin__Handle, account uint32, _arg0 *C.Account__Handle) (___err_code uint32) {
c, okc := lookupCoinHandle(_c)
func SKY_bip44_Coin_Account(_c *C.Coin__Handle, _account uint32, _arg1 *C.Account__Handle) (____error_code uint32) {
c, okc := lookupCoinHandle(*_c)
if !okc {
___err_code = SKY_BAD_HANDLE
____error_code = SKY_BAD_HANDLE
return
}
ac, err := c.Account(account)
___err_code = libErrorCode(err)
if err == nil {
*_arg0 = registerAccountHandle(ac)
account := _account
__arg1, ____return_err := c.Account(account)
____error_code = libErrorCode(____return_err)
if ____return_err == nil {
*_arg1 = registerAccountHandle(__arg1)
}
return
}

//export SKY_bip44_Account_External
func SKY_bip44_Account_External(_a C.Account__Handle, _arg0 *C.PrivateKey__Handle) (___err_code uint32) {
a, oka := lookupAccountHandle(_a)
func SKY_bip44_Account_External(_a *C.Account__Handle, _arg0 *C.PrivateKey__Handle) (____error_code uint32) {
a, oka := lookupAccountHandle(*_a)
if !oka {
___err_code = SKY_BAD_HANDLE
____error_code = SKY_BAD_HANDLE
return
}

p, __return_err := a.External()
___err_code = libErrorCode(__return_err)
if __return_err == nil {
*_arg0 = registerPrivateKeyHandle(p)

__arg0, ____return_err := a.External()
____error_code = libErrorCode(____return_err)
if ____return_err == nil {
*_arg0 = registerPrivateKeyHandle(__arg0)
}
return
}

//export SKY_bip44_Account_Change
func SKY_bip44_Account_Change(_a C.Account__Handle, _arg0 *C.PrivateKey__Handle) (___err_code uint32) {
a, oka := lookupAccountHandle(_a)
func SKY_bip44_Account_Change(_a *C.Account__Handle, _arg0 *C.PrivateKey__Handle) (____error_code uint32) {
a, oka := lookupAccountHandle(*_a)
if !oka {
___err_code = SKY_BAD_HANDLE
____error_code = SKY_BAD_HANDLE
return
}

p, __return_err := a.Change()
___err_code = libErrorCode(__return_err)
if __return_err == nil {
*_arg0 = registerPrivateKeyHandle(p)

__arg0, ____return_err := a.Change()
____error_code = libErrorCode(____return_err)
if ____return_err == nil {
*_arg0 = registerPrivateKeyHandle(__arg0)
}
return
}

//export SKY_bip44_Account_String
func SKY_bip44_Account_String(_a C.Account__Handle, _arg0 *C.GoString_) (___err_code uint32) {

a, oka := lookupAccountHandle(_a)
if !oka {

___err_code = SKY_BAD_HANDLE
return
}

__arg0 := a.String()
copyString(__arg0, _arg0)
return
}

//export SKY_bip44_Account_GetPrivateKey
func SKY_bip44_Account_GetPrivateKey(_a C.Account__Handle, _arg0 *C.PrivateKey__Handle) (___err_code uint32) {

a, oka := lookupAccountHandle(_a)
if !oka {

___err_code = SKY_BAD_HANDLE
return
}

*_arg0 = registerPrivateKeyHandle(a.PrivateKey)
return
}

0 comments on commit 61b077e

Please sign in to comment.