-
Notifications
You must be signed in to change notification settings - Fork 19
/
transaction-crypto-transfer.go
46 lines (36 loc) · 1.37 KB
/
transaction-crypto-transfer.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package hedera
// #include "hedera-transaction-crypto-transfer.h"
import "C"
import "unsafe"
type TransactionCryptoTransfer struct {
Transaction
}
func newTransactionCryptoTransfer(client *Client) TransactionCryptoTransfer {
return TransactionCryptoTransfer{Transaction{
C.hedera_transaction__crypto_transfer__new(client.inner)}}
}
func (tx TransactionCryptoTransfer) Operator(id AccountID) TransactionCryptoTransfer {
C.hedera_transaction_set_operator(tx.inner, id.c())
return tx
}
func (tx TransactionCryptoTransfer) Node(id AccountID) TransactionCryptoTransfer {
C.hedera_transaction_set_node(tx.inner, id.c())
return tx
}
func (tx TransactionCryptoTransfer) Memo(memo string) TransactionCryptoTransfer {
C.hedera_transaction_set_memo(tx.inner, C.CString(memo))
return tx
}
func (tx TransactionCryptoTransfer) Sign(key SecretKey) TransactionCryptoTransfer {
C.hedera_transaction_sign(tx.inner, key.inner)
return tx
}
func (tx TransactionCryptoTransfer) Transfer(id AccountID, amount int64) TransactionCryptoTransfer {
C.hedera_transaction__crypto_transfer__add_transfer(tx.inner, id.c(), C.int64_t(amount))
return tx
}
func (tx TransactionCryptoTransfer) Execute() (TransactionResponse, error) {
var res C.HederaTransactionResponse
err := C.hedera_transaction__crypto_transfer__execute(tx.inner, &res)
return *((*TransactionResponse)(unsafe.Pointer(&res))), hederaError(err)
}