diff --git a/include/fctypes.h b/include/fctypes.h index 77613bc..80aae32 100644 --- a/include/fctypes.h +++ b/include/fctypes.h @@ -146,12 +146,19 @@ typedef GoInt64_ Handle; * String Slice Handle */ typedef Handle Strings__Handle; -typedef Handle core__SecKey; -typedef Handle core__PubKey; -typedef Handle core__Address; -typedef Handle core__AddressIterator; -typedef Handle core__TxnSigner; -typedef Handle core__TxnSignerIterator; -typedef Handle core__CryptoAccount; +/** + * AltcoinPlugin__Handle Handle, interface core.AltcoinPlugin + */ +typedef Handle AltcoinPlugin__Handle; + +/** + * TxnSigner__Handle Handle, interface core.TxnSigner + */ +typedef Handle TxnSigner__Handle; + +/** + * Wallet__Handle Handle, interface core.Wallet + */ +typedef Handle Wallet__Handle; #endif diff --git a/lib/cgo/libfc_handle.go b/lib/cgo/libfc_handle.go index af7a695..4dcab1d 100644 --- a/lib/cgo/libfc_handle.go +++ b/lib/cgo/libfc_handle.go @@ -1,5 +1,9 @@ package main +import ( + "github.com/fibercrypto/fibercryptowallet/src/core" +) + /* #include @@ -60,3 +64,43 @@ func lookupStringsHandle(handle C.Strings__Handle) ([]string, bool) { } return nil, false } + +func lookupAltcoinPluginHandle(handle C.AltcoinPlugin__Handle) (*core.AltcoinPlugin, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*core.AltcoinPlugin); isOK { + return obj, true + } + } + return nil, false +} + +func registerAltcoinPluginHandle(obj *core.AltcoinPlugin) C.AltcoinPlugin__Handle { + return (C.AltcoinPlugin__Handle)(registerHandle(obj)) +} + +func lookupWalletHandle(handle C.Wallet__Handle) (*core.Wallet, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*core.Wallet); isOK { + return obj, true + } + } + return nil, false +} + +func registerWalletHandle(obj *core.Wallet) C.Wallet__Handle { + return (C.Wallet__Handle)(registerHandle(obj)) +} +func lookupTxnSignerHandle(handle C.TxnSigner__Handle) (*core.TxnSigner, bool) { + obj, ok := lookupHandle(C.Handle(handle)) + if ok { + if obj, isOK := (obj).(*core.TxnSigner); isOK { + return obj, true + } + } + return nil, false +} +func registerTxnSignerHandle(obj *core.TxnSigner) C.TxnSigner__Handle { + return (C.TxnSigner__Handle)(registerHandle(obj)) +} diff --git a/lib/cgo/util.pluginutil.go b/lib/cgo/util.pluginutil.go index b48cc2b..274f488 100644 --- a/lib/cgo/util.pluginutil.go +++ b/lib/cgo/util.pluginutil.go @@ -1,6 +1,11 @@ package main -import "github.com/fibercrypto/fibercryptowallet/src/util" +import ( + "unsafe" + + core "github.com/fibercrypto/fibercryptowallet/src/core" + util "github.com/fibercrypto/fibercryptowallet/src/util" +) /* @@ -12,10 +17,46 @@ import "github.com/fibercrypto/fibercryptowallet/src/util" import "C" //export FC_util_AltcoinCaption -func FC_util_AltcoinCaption(_arg0 string, _arg1 *C.GoString_) (____error_code uint32) { - callNode() - arg0 := string(_arg0) - arg1 := util.AltcoinCaption(arg0) - copyString(arg1, _arg1) +func FC_util_AltcoinCaption(_ticker string, _arg1 *C.GoString_) (____error_code uint32) { + ticker := _ticker + __arg1 := util.AltcoinCaption(ticker) + copyString(__arg1, _arg1) + return +} + +//export FC_util_AltcoinQuotient +func FC_util_AltcoinQuotient(_ticker string, _arg1 *uint64) (____error_code uint32) { + ticker := _ticker + __arg1, ____return_err := util.AltcoinQuotient(ticker) + ____error_code = libErrorCode(____return_err) + if ____return_err == nil { + *_arg1 = __arg1 + } + return +} + +//export FC_util_RegisterAltcoin +func FC_util_RegisterAltcoin(_p *C.AltcoinPlugin__Handle) (____error_code uint32) { + __p, okp := lookupAltcoinPluginHandle(*_p) + if !okp { + ____error_code = FC_BAD_HANDLE + return + } + p := *__p + util.RegisterAltcoin(p) + return +} + +//export FC_util_LookupSignerByUID +func FC_util_LookupSignerByUID(_wlt *C.Wallet__Handle, _id *C.core__UID, _arg2 *C.TxnSigner__Handle) (____error_code uint32) { + __wlt, okwlt := lookupWalletHandle(*_wlt) + if !okwlt { + ____error_code = FC_BAD_HANDLE + return + } + wlt := *__wlt + id := *(*core.UID)(unsafe.Pointer(_id)) + __arg2 := util.LookupSignerByUID(wlt, id) + *_arg2 = registerTxnSignerHandle(&__arg2) return }