-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lib] refs #992 - Update SKY_cli_CreateTxFromWallet to deal with wall…
…et encryption
- Loading branch information
Showing
6 changed files
with
92 additions
and
28 deletions.
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,20 @@ | ||
package main | ||
|
||
/* | ||
#include <string.h> | ||
#include <stdlib.h> | ||
#include "skytypes.h" | ||
*/ | ||
import "C" | ||
|
||
import ( | ||
cli "github.com/skycoin/skycoin/src/api/cli" | ||
) | ||
|
||
//export SKY_cli_NewPasswordReader | ||
func SKY_cli_NewPasswordReader(_p []byte) C.PasswordReader__Handle { | ||
pr := cli.NewPasswordReader(_p) | ||
return registerPasswordReaderHandle(pr) | ||
} |
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
package main | ||
|
||
const ( | ||
SKY_OK = 0 | ||
SKY_ERROR = 0xFFFFFFFF | ||
SKY_OK = 0 | ||
) | ||
|
||
func libErrorCode(err error) uint32 { | ||
|
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,56 @@ | ||
package main | ||
|
||
/* | ||
#include <string.h> | ||
#include <stdlib.h> | ||
#include "skytypes.h" | ||
*/ | ||
import "C" | ||
|
||
import ( | ||
cli "github.com/skycoin/skycoin/src/api/cli" | ||
"unsafe" | ||
) | ||
|
||
type Handle uint64 | ||
|
||
var ( | ||
handleMap = make(map[Handle]interface{}) | ||
) | ||
|
||
func registerHandle(obj interface{}) Handle { | ||
ptr := &obj | ||
handle := *(*Handle)(unsafe.Pointer(&ptr)) | ||
handleMap[handle] = obj | ||
return handle | ||
} | ||
|
||
func lookupHandleObj(handle Handle) (interface{}, bool) { | ||
obj, ok := handleMap[handle] | ||
return obj, ok | ||
} | ||
|
||
func registerPasswordReaderHandle(obj cli.PasswordReader) C.PasswordReader__Handle { | ||
return (C.PasswordReader__Handle)(registerHandle(obj)) | ||
} | ||
|
||
func lookupPasswordReaderHandle(handle C.PasswordReader__Handle) (cli.PasswordReader, bool) { | ||
obj, ok := lookupHandleObj(Handle(handle)) | ||
if ok { | ||
if obj, isOK := (obj).(cli.PasswordReader); isOK { | ||
return obj, true | ||
} | ||
} | ||
return nil, false | ||
} | ||
|
||
func closeHandle(handle Handle) { | ||
delete(handleMap, handle) | ||
} | ||
|
||
//export SKY_handle_close | ||
func SKY_handle_close(handle C.Handle) { | ||
closeHandle(Handle(handle)) | ||
} |
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