Skip to content

Commit

Permalink
[cgo] refs #105 Added datatype Path__Handle
Browse files Browse the repository at this point in the history
  • Loading branch information
Maykel Arias Torres committed Sep 4, 2019
1 parent de34f48 commit 92d8cf6
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
5 changes: 5 additions & 0 deletions include/skytypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,11 @@ typedef Handle PublicKey__Handle;
*/
typedef Handle PrivateKey__Handle;

/**
* Path__Handle Handle, struct bip32.Path
*/
typedef Handle Path__Handle;

/**
* Coin__Handle Handle, struct bip44.Coin
*/
Expand Down
36 changes: 33 additions & 3 deletions lib/cgo/cipher.bip32.path.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,44 @@ func SKY_bip32_PathNode_Hardened(_pk *C.bip32__PathNode) (____error_code uint32)
return
}

// nolint megacheck
//export SKY_bip32_ParsePath
func SKY_bip32_ParsePath(_p string, _arg0 *C.bip32__Path) (____error_code uint32) {
func SKY_bip32_ParsePath(_p string, _arg0 *C.Path__Handle) (____error_code uint32) {

p, err := bip32.ParsePath(_p)
____error_code = libErrorCode(err)
if err == nil {
_arg0 = (*C.bip32__Path)(unsafe.Pointer(p))
*_arg0 = registerPathHandle(p)
}
return
}

//export SKY_bip32_Path_Count
func SKY_bip32_Path_Count(handle C.Path__Handle, _arg0 *int) (____error_code uint32) {
p, okp := lookupPathHandle(handle)

if !okp {
____error_code = SKY_BAD_HANDLE
return
}

*_arg0 = len(p.Elements)
return
}

//export SKY_bip32_Path_GetElements
func SKY_bip32_Path_GetElements(handle C.Path__Handle, post int, _arg0 *C.bip32__PathNode) (____error_code uint32) {
p, okp := lookupPathHandle(handle)

if !okp {
____error_code = SKY_BAD_HANDLE
return
}

if len(p.Elements) <= post {
____error_code = SKY_BAD_HANDLE
return
}

*_arg0 = *(*C.bip32__PathNode)(unsafe.Pointer(&p.Elements[post]))
return
}

0 comments on commit 92d8cf6

Please sign in to comment.