tagion_wallet_create_bill

Create bill from wallet information

version(none)
extern (C)
int
tagion_wallet_create_bill
(
const double amount
,
const uint8_t* pubkey
,
const size_t pubkey_len
,
const(int64_t) time
,
uint8_t** bill_buf
,
size_t* bill_buf_len
)

Parameters

amount double

the amount for the new bill

pubkey uint8_t*

pointer to the pubkey

pubkey_len size_t

length of the public key

time const(int64_t)

timestamp as the number of hnsecs since midnight, January 1st, 1 A.D. for the current time.

bill_buf uint8_t**

pointer to the bill buffer that is returned

bill_buf_len size_t*

length of the returned bill buffer

Return Value

Type: int

ErrorCode

Examples

ApiWallet wallet;
wallet.createWallet("wowo", "1234");
const double amount = 213.2f;
const pkey = wallet.getCurrentPubkey;
const time = currentTime;

uint8_t* bill_buf;
size_t bill_buf_len;
int rt = tagion_wallet_create_bill(amount, &pkey[0], pkey.length, cast(const(int64_t)) time, &bill_buf, &bill_buf_len);
assert(rt == ErrorCode.none);

const read_bill = TagionBill(Document(bill_buf[0..bill_buf_len].idup));
assert(read_bill.value == TagionCurrency(amount));
assert(read_bill.time == time);
assert(read_bill.owner == wallet.getCurrentPubkey);