forked from fibercrypto/libfibercrypto
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cgo] refs fibercrypto#5 Added
coin.mocks.WalletStorage
- Loading branch information
Maykel Arias Torres
committed
Mar 26, 2020
1 parent
03bcf20
commit 0290e0f
Showing
4 changed files
with
106 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package main | ||
|
||
import ( | ||
"errors" | ||
"unsafe" | ||
|
||
core "github.com/fibercrypto/fibercryptowallet/src/core" | ||
) | ||
|
||
/* | ||
#include <string.h> | ||
#include <stdlib.h> | ||
#include "fctypes.h" | ||
#include "fccallback.h" | ||
*/ | ||
import "C" | ||
|
||
//export FC_mocks_WalletStorage_Decrypt | ||
func FC_mocks_WalletStorage_Decrypt(__m *C.WalletStorageMocks__Handle, _walletName string, _password *C.PasswordReader) (____error_code uint32) { | ||
_m, ok_m := lookupWalletStorageMocksHandle(*__m) | ||
if !ok_m { | ||
____error_code = FC_BAD_HANDLE | ||
return | ||
} | ||
walletName := _walletName | ||
password := func(pString string, pKVS core.KeyValueStore) (string, error) { | ||
var pStringOut C.GoString_ | ||
var pStringIn C.GoString_ | ||
copyString(pString, &pStringIn) | ||
pKVSHandle := registerKeyValueStoreHandle(&pKVS) | ||
result := C.callPasswordReader(_password, pStringIn, pKVSHandle, &pStringOut) | ||
closeHandle(Handle(pKVSHandle)) | ||
if result == FC_OK { | ||
pStringOut_ := *(*string)(unsafe.Pointer(&pStringOut)) | ||
return string(pStringOut_), nil | ||
} | ||
return "", errors.New("Error in PasswdReader") | ||
} | ||
_m.Decrypt(walletName, password) | ||
return | ||
} | ||
|
||
//export FC_mocks_WalletStorage_Encrypt | ||
func FC_mocks_WalletStorage_Encrypt(__m *C.WalletStorageMocks__Handle, _walletName string, _password *C.PasswordReader) (____error_code uint32) { | ||
_m, ok_m := lookupWalletStorageMocksHandle(*__m) | ||
if !ok_m { | ||
____error_code = FC_BAD_HANDLE | ||
return | ||
} | ||
walletName := _walletName | ||
password := func(pString string, pKVS core.KeyValueStore) (string, error) { | ||
var pStringOut C.GoString_ | ||
var pStringIn C.GoString_ | ||
copyString(pString, &pStringIn) | ||
pKVSHandle := registerKeyValueStoreHandle(&pKVS) | ||
result := C.callPasswordReader(_password, pStringIn, pKVSHandle, &pStringOut) | ||
closeHandle(Handle(pKVSHandle)) | ||
if result == FC_OK { | ||
pStringOut_ := *(*string)(unsafe.Pointer(&pStringOut)) | ||
return string(pStringOut_), nil | ||
} | ||
return "", errors.New("Error in PasswdReader") | ||
} | ||
_m.Encrypt(walletName, password) | ||
return | ||
} | ||
|
||
//export FC_mocks_WalletStorage_IsEncrypted | ||
func FC_mocks_WalletStorage_IsEncrypted(__m *C.WalletStorageMocks__Handle, _walletName string, _arg1 *bool) (____error_code uint32) { | ||
_m, ok_m := lookupWalletStorageMocksHandle(*__m) | ||
if !ok_m { | ||
____error_code = FC_BAD_HANDLE | ||
return | ||
} | ||
walletName := _walletName | ||
__arg1, ____return_err := _m.IsEncrypted(walletName) | ||
____error_code = libErrorCode(____return_err) | ||
if ____return_err == nil { | ||
*_arg1 = __arg1 | ||
} | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters