fix use of struct TALER_DepositRequestPS (unfinished)
This commit is contained in:
parent
d61dbb3109
commit
15b362373f
@ -239,6 +239,28 @@ struct TALER_MINTDB_Deposit
|
||||
*/
|
||||
uint64_t transaction_id;
|
||||
|
||||
/**
|
||||
* Time when this request was generated. Used, for example, to
|
||||
* assess when (roughly) the income was achieved for tax purposes.
|
||||
* Note that the Mint will only check that the timestamp is not "too
|
||||
* far" into the future (i.e. several days). The fact that the
|
||||
* timestamp falls within the validity period of the coin's
|
||||
* denomination key is irrelevant for the validity of the deposit
|
||||
* request, as obviously the customer and merchant could conspire to
|
||||
* set any timestamp. Also, the Mint must accept very old deposit
|
||||
* requests, as the merchant might have been unable to transmit the
|
||||
* deposit request in a timely fashion (so back-dating is not
|
||||
* prevented).
|
||||
*/
|
||||
struct GNUNET_TIME_Absolute timestamp;
|
||||
|
||||
/**
|
||||
* How much time does the merchant have to issue a refund request?
|
||||
* Zero if refunds are not allowed. After this time, the coin
|
||||
* cannot be refunded.
|
||||
*/
|
||||
struct GNUNET_TIME_Absolute refund_deadline;
|
||||
|
||||
/**
|
||||
* Fraction of the coin's remaining value to be deposited, including
|
||||
* depositing fee (if any). The coin is identified by @e coin_pub.
|
||||
|
@ -64,9 +64,14 @@ verify_and_execute_deposit (struct MHD_Connection *connection,
|
||||
dr.purpose.size = htonl (sizeof (struct TALER_DepositRequestPS));
|
||||
dr.h_contract = deposit->h_contract;
|
||||
dr.h_wire = deposit->h_wire;
|
||||
dr.timestamp = GNUNET_TIME_absolute_hton (deposit->timestamp);
|
||||
dr.refund_deadline = GNUNET_TIME_absolute_hton (deposit->refund_deadline);
|
||||
dr.transaction_id = GNUNET_htonll (deposit->transaction_id);
|
||||
TALER_amount_hton (&dr.amount_with_fee,
|
||||
&deposit->amount_with_fee);
|
||||
TALER_amount_hton (&dr.deposit_fee,
|
||||
&deposit->deposit_fee);
|
||||
dr.merchant = deposit->merchant_pub;
|
||||
dr.coin_pub = deposit->coin.coin_pub;
|
||||
if (GNUNET_OK !=
|
||||
GNUNET_CRYPTO_ecdsa_verify (TALER_SIGNATURE_WALLET_COIN_DEPOSIT,
|
||||
@ -145,6 +150,8 @@ parse_and_handle_deposit_request (struct MHD_Connection *connection,
|
||||
TMH_PARSE_MEMBER_FIXED ("H_wire", &deposit.h_wire),
|
||||
TMH_PARSE_MEMBER_FIXED ("csig", &deposit.csig),
|
||||
TMH_PARSE_MEMBER_FIXED ("transaction_id", &deposit.transaction_id),
|
||||
TMH_PARSE_MEMBER_TIME_ABS ("timestamp", &deposit.timestamp),
|
||||
TMH_PARSE_MEMBER_TIME_ABS ("refund_deadline", &deposit.refund_deadline),
|
||||
TMH_PARSE_MEMBER_END
|
||||
};
|
||||
|
||||
@ -179,6 +186,7 @@ parse_and_handle_deposit_request (struct MHD_Connection *connection,
|
||||
|
||||
deposit.wire = wire;
|
||||
deposit.amount_with_fee = *amount;
|
||||
deposit.deposit_fee = *amount; // FIXME: get fee from denomination key!
|
||||
res = verify_and_execute_deposit (connection,
|
||||
&deposit);
|
||||
TMH_PARSE_release_data (spec);
|
||||
|
@ -689,6 +689,20 @@ TMH_PARSE_navigate_json (struct MHD_Connection *connection,
|
||||
break;
|
||||
}
|
||||
|
||||
case TMH_PARSE_JNC_RET_TIME_ABSOLUTE:
|
||||
{
|
||||
struct GNUNET_TIME_Absolute *where = va_arg (argp, void *);
|
||||
#if 0
|
||||
ret = TMH_PARSE_time_abs_json (connection,
|
||||
(json_t *) root,
|
||||
where);
|
||||
#endif
|
||||
GNUNET_assert (0); /* FIXME: not implemented (#3741) */
|
||||
(void) where;
|
||||
ret = GNUNET_SYSERR;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
GNUNET_break (0);
|
||||
ret = (MHD_YES ==
|
||||
@ -801,6 +815,16 @@ TMH_PARSE_json_data (struct MHD_Connection *connection,
|
||||
TMH_PARSE_JNC_RET_AMOUNT,
|
||||
&spec[i].destination);
|
||||
break;
|
||||
case TMH_PARSE_JNC_RET_TIME_ABSOLUTE:
|
||||
GNUNET_assert (sizeof (struct GNUNET_TIME_Absolute) ==
|
||||
spec[i].destination_size_in);
|
||||
ret = TMH_PARSE_navigate_json (connection,
|
||||
root,
|
||||
TMH_PARSE_JNC_FIELD,
|
||||
spec[i].field_name,
|
||||
TMH_PARSE_JNC_RET_TIME_ABSOLUTE,
|
||||
&spec[i].destination);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (GNUNET_YES != ret)
|
||||
@ -870,6 +894,8 @@ TMH_PARSE_release_data (struct TMH_PARSE_FieldSpecification *spec)
|
||||
0,
|
||||
sizeof (struct TALER_Amount));
|
||||
break;
|
||||
case TMH_PARSE_JNC_RET_TIME_ABSOLUTE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -126,7 +126,14 @@ enum TMH_PARSE_JsonNavigationCommand
|
||||
* Return a `struct TALER_Amount` which was
|
||||
* encoded within its own json object.
|
||||
*/
|
||||
TMH_PARSE_JNC_RET_AMOUNT
|
||||
TMH_PARSE_JNC_RET_AMOUNT,
|
||||
|
||||
/**
|
||||
* Return a `struct GNUNET_TIME_Absolute` which was
|
||||
* encoded within its own json object.
|
||||
* Param: struct GNUNET_TIME_Absolute *
|
||||
*/
|
||||
TMH_PARSE_JNC_RET_TIME_ABSOLUTE
|
||||
};
|
||||
|
||||
|
||||
@ -284,6 +291,14 @@ TMH_PARSE_release_data (struct TMH_PARSE_FieldSpecification *spec);
|
||||
*/
|
||||
#define TMH_PARSE_MEMBER_AMOUNT(field,amount) { field, amount, sizeof(*amount), 0, TMH_PARSE_JNC_RET_AMOUNT, 0 }
|
||||
|
||||
/**
|
||||
* Generate line in parser specification for an absolute time.
|
||||
*
|
||||
* @param field name of the field
|
||||
* @param atime a `struct GNUNET_TIME_Absolute *` to initialize
|
||||
*/
|
||||
#define TMH_PARSE_MEMBER_TIME_ABS(field,atime) { field, atime, sizeof(*atime), 0, TMH_PARSE_JNC_RET_TIME_ABSOLUTE, 0 }
|
||||
|
||||
/**
|
||||
* Generate line in parser specification indicating the end of the spec.
|
||||
*/
|
||||
|
@ -348,9 +348,14 @@ compile_transaction_history (const struct TALER_MINTDB_TransactionList *tl)
|
||||
dr.purpose.size = htonl (sizeof (struct TALER_DepositRequestPS));
|
||||
dr.h_contract = deposit->h_contract;
|
||||
dr.h_wire = deposit->h_wire;
|
||||
dr.timestamp = GNUNET_TIME_absolute_hton (deposit->timestamp);
|
||||
dr.refund_deadline = GNUNET_TIME_absolute_hton (deposit->refund_deadline);
|
||||
dr.transaction_id = GNUNET_htonll (deposit->transaction_id);
|
||||
TALER_amount_hton (&dr.amount_with_fee,
|
||||
&deposit->amount_with_fee);
|
||||
TALER_amount_hton (&dr.deposit_fee,
|
||||
&deposit->deposit_fee);
|
||||
dr.merchant = deposit->merchant_pub;
|
||||
dr.coin_pub = deposit->coin.coin_pub;
|
||||
transaction = TALER_json_from_ecdsa_sig (&dr.purpose,
|
||||
&deposit->csig.ecdsa_signature);
|
||||
|
Loading…
Reference in New Issue
Block a user