Skip to content

Commit

Permalink
[cgo] refs fibercrypto#116 Finalized cli.create_rawtx
Browse files Browse the repository at this point in the history
  • Loading branch information
Maykel Arias Torres committed Jan 18, 2020
1 parent 107646e commit d71e80e
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 8 deletions.
25 changes: 19 additions & 6 deletions include/cli.create_rawtx.go.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
/**
* Structure used to specify amounts transferred in a transaction.
*/
typedef struct {
GoString_ Addr; ///< Sender / receipient address.
GoInt64_ Coins; ///< Amount transferred (e.g. measured in SKY)
typedef struct{
GoString_ Addr;
GoUint64_ Coins;
} cli__SendAmount;
typedef struct{
GoString_ Addr;
GoString_ Coins;
} cli__sendAmountJSON;
typedef struct{
GoString_ Wallet;
GoString_ Address;
} cli__walletAddress;
typedef GoInterface_ cli__GetOutputser;
typedef struct{
GoString_ WalletID;
GoString_ Address;
GoString_ ChangeAddress;
GoSlice_ SendAmounts;
cli__PasswordReader Password;
} cli__createRawTxnArgs;
99 changes: 97 additions & 2 deletions lib/cgo/cli.create_rawtx.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ package main
import (
"unsafe"

"github.com/SkycoinProject/skycoin/src/transaction"

cipher "github.com/SkycoinProject/skycoin/src/cipher"
cli "github.com/SkycoinProject/skycoin/src/cli"
coin "github.com/SkycoinProject/skycoin/src/coin"
transaction "github.com/SkycoinProject/skycoin/src/transaction"
)

/*
Expand All @@ -16,9 +15,105 @@ import (
#include <stdlib.h>
#include "skytypes.h"
#include "skyfee.h"
*/
import "C"

//export SKY_cli_CreateRawTxnFromWallet
func SKY_cli_CreateRawTxnFromWallet(_c *C.GetOutputser__Handle, _walletFile, _chgAddr string, _toAddrs []C.cli__SendAmount, _pr *C.PasswordReader__Handle, _distParams *C.Distribution__Handle, _arg5 *C.Transaction__Handle) (____error_code uint32) {
__c, okc := lookupGetOutputserHandle(*_c)
if !okc {
____error_code = SKY_BAD_HANDLE
return
}
c := *__c
walletFile := _walletFile
chgAddr := _chgAddr
toAddrs := *(*[]cli.SendAmount)(unsafe.Pointer(&_toAddrs))
__pr, okpr := lookupPasswordReaderHandle(*_pr)
if !okpr {
____error_code = SKY_BAD_HANDLE
return
}
pr := *__pr
__distParams, okdistParams := lookupDistributionHandle(*_distParams)
if !okdistParams {
____error_code = SKY_BAD_HANDLE
return
}
distParams := *__distParams
__arg5, ____return_err := cli.CreateRawTxnFromWallet(c, walletFile, chgAddr, toAddrs, pr, distParams)
____error_code = libErrorCode(____return_err)
if ____return_err == nil {
*_arg5 = registerTransactionHandle(__arg5)
}
return
}

//export SKY_cli_CreateRawTxnFromAddress
func SKY_cli_CreateRawTxnFromAddress(_c *C.GetOutputser__Handle, _addr, _walletFile, _chgAddr string, _toAddrs []C.cli__SendAmount, _pr *C.PasswordReader__Handle, _distParams *C.Distribution__Handle, _arg5 *C.Transaction__Handle) (____error_code uint32) {
__c, okc := lookupGetOutputserHandle(*_c)
if !okc {
____error_code = SKY_BAD_HANDLE
return
}
c := *__c
addr := _addr
walletFile := _walletFile
chgAddr := _chgAddr
toAddrs := *(*[]cli.SendAmount)(unsafe.Pointer(&_toAddrs))
__pr, okpr := lookupPasswordReaderHandle(*_pr)
if !okpr {
____error_code = SKY_BAD_HANDLE
return
}
pr := *__pr
__distParams, okdistParams := lookupDistributionHandle(*_distParams)
if !okdistParams {
____error_code = SKY_BAD_HANDLE
return
}
distParams := *__distParams
__arg5, ____return_err := cli.CreateRawTxnFromAddress(c, addr, walletFile, chgAddr, toAddrs, pr, distParams)
____error_code = libErrorCode(____return_err)
if ____return_err == nil {
*_arg5 = registerTransactionHandle(__arg5)
}
return
}

//export SKY_cli_CreateRawTxn
func SKY_cli_CreateRawTxn(_c *C.GetOutputser__Handle, _wlt *C.Wallet__Handle, _inAddrs []string, _chgAddr string, _toAddrs []C.cli__SendAmount, _password []byte, _distParams *C.Distribution__Handle, _arg7 *C.Transaction__Handle) (____error_code uint32) {
__c, okc := lookupGetOutputserHandle(*_c)
if !okc {
____error_code = SKY_BAD_HANDLE
return
}
c := *__c
__wlt, okwlt := lookupWalletHandle(*_wlt)
if !okwlt {
____error_code = SKY_BAD_HANDLE
return
}
wlt := *__wlt
inAddrs := *(*[]string)(unsafe.Pointer(&_inAddrs))
chgAddr := _chgAddr
toAddrs := *(*[]cli.SendAmount)(unsafe.Pointer(&_toAddrs))
password := *(*[]byte)(unsafe.Pointer(&_password))
__distParams, okdistParams := lookupDistributionHandle(*_distParams)
if !okdistParams {
____error_code = SKY_BAD_HANDLE
return
}
distParams := *__distParams
__arg7, ____return_err := cli.CreateRawTxn(c, wlt, inAddrs, chgAddr, toAddrs, password, distParams)
____error_code = libErrorCode(____return_err)
if ____return_err == nil {
*_arg7 = registerTransactionHandle(__arg7)
}
return
}

//export SKY_cli_NewTransaction
func SKY_cli_NewTransaction(_utxos []C.transaction__UxBalance, _keys []C.cipher__SecKey, _outs []C.coin__TransactionOutput, _arg3 *C.Transaction__Handle) (____error_code uint32) {
utxos := *(*[]transaction.UxBalance)(unsafe.Pointer(&_utxos))
Expand Down

0 comments on commit d71e80e

Please sign in to comment.