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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
/**
* Simplified version of the contract to be signed, meant to obsolete
* 'struct ContractNBO'.
*/
struct Contract
{
/**
* Purpose header for the signature over contract
*/
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
/**
* Hash of the JSON contract in UTF-8 including 0-termination,
* using JSON_COMPACT encoding with sorted fields.
*/
struct GNUNET_HashCode h_contract_details;
};
GNUNET_NETWORK_STRUCT_BEGIN
struct ContractNBO
{
/**
* Purpose header for the signature over contract
*/
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
/**
* The transaction identifier. NOTE: it was m[13]. TODO:
* change the API accordingly!
*/
uint64_t m;
/**
* Expiry time
*/
struct GNUNET_TIME_AbsoluteNBO t;
/**
* The invoice amount
*/
struct TALER_AmountNBO amount;
/**
* The hash of the merchant's wire details (bank account information), with a nounce
*/
struct GNUNET_HashCode h_wire;
/**
* Hash of the JSON contract in UTF-8 including 0-termination,
* using JSON_COMPACT encoding with sorted fields.
*/
struct GNUNET_HashCode h_contract_details;
};
GNUNET_NETWORK_STRUCT_END
/**
* Take the global wire details and return a JSON containing them,
* compliantly with the Taler's API.
* @param wire the merchant's wire details
* @param nounce the nounce for hashing the wire details with
* @param edate when the beneficiary wants this transfer to take place
* @return JSON representation of the wire details, NULL upon errors
*/
json_t *
MERCHANT_get_wire_json (const struct MERCHANT_WIREFORMAT_Sepa *wire,
uint64_t nounce,
struct GNUNET_TIME_Absolute edate);
/**
* Take from the frontend the (partly) generated contract and fill
* the missing values in it; for example, the SEPA details.
* Moreover, it stores the contract in the DB.
* @param j_contract parsed contract, originated by the frontend. It will be
* hold the new values.
* @param db_conn the handle to the local DB
* @param contract where to store the (subset of the) contract to be (still) signed
* @param timestamp contract's timestamp (shall be generated by the merchant)
* @param expiry the time when the contract will expire
* @param edate when the merchant wants to receive the wire transfer corresponding
* to this deal (this value is also a field inside the 'wire' JSON format)
* @param nounce the nounce used to hash the wire details
* @param contract_str where to store the hashed (stringified) contract
* @return GNUNET_OK on success; GNUNET_SYSERR upon errors
*/
/**
* TODO: inspect reference counting and, accordingly, free those json_t*(s)
* still allocated */
uint32_t
MERCHANT_handle_contract (const json_t *j_contract,
PGconn *db_conn,
struct Contract *contract,
struct GNUNET_TIME_Absolute timestamp,
struct GNUNET_TIME_Absolute expiry,
struct GNUNET_TIME_Absolute edate,
uint64_t nounce,
const char *contract_str);
|