Merge branch 'protocolv8' of git+ssh://git.taler.net/exchange into protocolv8

This commit is contained in:
Christian Grothoff 2020-06-21 23:07:09 +02:00
commit ffc3f20daa
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
2 changed files with 81 additions and 31 deletions

View File

@ -1075,7 +1075,7 @@ TALER_TESTING_cmd_admin_add_incoming (
* @param payto_debit_account which account sends money. * @param payto_debit_account which account sends money.
* @param auth authentication data * @param auth authentication data
* @param ref reference to a command that can offer a reserve * @param ref reference to a command that can offer a reserve
* private key. * private key or public key.
* @return the command. * @return the command.
*/ */
struct TALER_TESTING_Command struct TALER_TESTING_Command

View File

@ -81,6 +81,11 @@ struct AdminAddIncomingState
*/ */
struct TALER_ReservePrivateKeyP reserve_priv; struct TALER_ReservePrivateKeyP reserve_priv;
/**
* Whether we know the private key or not.
*/
bool reserve_priv_known;
/** /**
* Reserve public key matching @e reserve_priv. * Reserve public key matching @e reserve_priv.
*/ */
@ -271,6 +276,7 @@ admin_add_incoming_run (void *cls,
struct TALER_TESTING_Interpreter *is) struct TALER_TESTING_Interpreter *is)
{ {
struct AdminAddIncomingState *fts = cls; struct AdminAddIncomingState *fts = cls;
bool have_public = false;
(void) cmd; (void) cmd;
/* Use reserve public key as subject */ /* Use reserve public key as subject */
@ -278,6 +284,7 @@ admin_add_incoming_run (void *cls,
{ {
const struct TALER_TESTING_Command *ref; const struct TALER_TESTING_Command *ref;
const struct TALER_ReservePrivateKeyP *reserve_priv; const struct TALER_ReservePrivateKeyP *reserve_priv;
const struct TALER_ReservePublicKeyP *reserve_pub;
ref = TALER_TESTING_interpreter_lookup_command ref = TALER_TESTING_interpreter_lookup_command
(is, fts->reserve_reference); (is, fts->reserve_reference);
@ -292,11 +299,23 @@ admin_add_incoming_run (void *cls,
0, 0,
&reserve_priv)) &reserve_priv))
{ {
GNUNET_break (0); if (GNUNET_OK != TALER_TESTING_get_trait_reserve_pub (ref,
TALER_TESTING_interpreter_fail (is); 0,
return; &reserve_pub))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (is);
return;
}
have_public = true;
fts->reserve_pub.eddsa_pub = reserve_pub->eddsa_pub;
fts->reserve_priv_known = false;
}
else
{
fts->reserve_priv.eddsa_priv = reserve_priv->eddsa_priv;
fts->reserve_priv_known = true;
} }
fts->reserve_priv.eddsa_priv = reserve_priv->eddsa_priv;
} }
else else
{ {
@ -349,6 +368,7 @@ admin_add_incoming_run (void *cls,
TALER_TESTING_interpreter_fail (is); TALER_TESTING_interpreter_fail (is);
return; return;
} }
fts->reserve_priv_known = true;
GNUNET_free (keys); GNUNET_free (keys);
GNUNET_free (section); GNUNET_free (section);
GNUNET_CONFIGURATION_destroy (cfg); GNUNET_CONFIGURATION_destroy (cfg);
@ -358,10 +378,12 @@ admin_add_incoming_run (void *cls,
/* No referenced reserve, no instance to take priv /* No referenced reserve, no instance to take priv
* from, no explicit subject given: create new key! */ * from, no explicit subject given: create new key! */
GNUNET_CRYPTO_eddsa_key_create (&fts->reserve_priv.eddsa_priv); GNUNET_CRYPTO_eddsa_key_create (&fts->reserve_priv.eddsa_priv);
fts->reserve_priv_known = true;
} }
} }
GNUNET_CRYPTO_eddsa_key_get_public (&fts->reserve_priv.eddsa_priv, if (! have_public)
&fts->reserve_pub.eddsa_pub); GNUNET_CRYPTO_eddsa_key_get_public (&fts->reserve_priv.eddsa_priv,
&fts->reserve_pub.eddsa_pub);
fts->reserve_history.type = TALER_EXCHANGE_RTT_CREDIT; fts->reserve_history.type = TALER_EXCHANGE_RTT_CREDIT;
fts->reserve_history.amount = fts->amount; fts->reserve_history.amount = fts->amount;
fts->reserve_history.details.in_details.sender_url fts->reserve_history.details.in_details.sender_url
@ -432,30 +454,58 @@ admin_add_incoming_traits (void *cls,
unsigned int index) unsigned int index)
{ {
struct AdminAddIncomingState *fts = cls; struct AdminAddIncomingState *fts = cls;
struct TALER_TESTING_Trait traits[] = { if (fts->reserve_priv_known)
TALER_TESTING_make_trait_bank_row (&fts->serial_id), {
TALER_TESTING_make_trait_payto (TALER_TESTING_PT_DEBIT, struct TALER_TESTING_Trait traits[] = {
fts->payto_debit_account), TALER_TESTING_make_trait_bank_row (&fts->serial_id),
/* Used as a marker, content does not matter */ TALER_TESTING_make_trait_payto (TALER_TESTING_PT_DEBIT,
TALER_TESTING_make_trait_payto (TALER_TESTING_PT_CREDIT, fts->payto_debit_account),
"payto://void/the-exchange"), /* Used as a marker, content does not matter */
TALER_TESTING_make_trait_url (TALER_TESTING_UT_EXCHANGE_BANK_ACCOUNT_URL, TALER_TESTING_make_trait_payto (TALER_TESTING_PT_CREDIT,
fts->exchange_credit_url), "payto://void/the-exchange"),
TALER_TESTING_make_trait_amount_obj (0, &fts->amount), TALER_TESTING_make_trait_url (TALER_TESTING_UT_EXCHANGE_BANK_ACCOUNT_URL,
TALER_TESTING_make_trait_absolute_time (0, &fts->timestamp), fts->exchange_credit_url),
TALER_TESTING_make_trait_reserve_priv (0, TALER_TESTING_make_trait_amount_obj (0, &fts->amount),
&fts->reserve_priv), TALER_TESTING_make_trait_absolute_time (0, &fts->timestamp),
TALER_TESTING_make_trait_reserve_pub (0, TALER_TESTING_make_trait_reserve_priv (0,
&fts->reserve_pub), &fts->reserve_priv),
TALER_TESTING_make_trait_reserve_history (0, TALER_TESTING_make_trait_reserve_pub (0,
&fts->reserve_history), &fts->reserve_pub),
TALER_TESTING_trait_end () TALER_TESTING_make_trait_reserve_history (0,
}; &fts->reserve_history),
TALER_TESTING_trait_end ()
};
return TALER_TESTING_get_trait (traits, return TALER_TESTING_get_trait (traits,
ret, ret,
trait, trait,
index); index);
}
else
{
struct TALER_TESTING_Trait traits[] = {
TALER_TESTING_make_trait_bank_row (&fts->serial_id),
TALER_TESTING_make_trait_payto (TALER_TESTING_PT_DEBIT,
fts->payto_debit_account),
/* Used as a marker, content does not matter */
TALER_TESTING_make_trait_payto (TALER_TESTING_PT_CREDIT,
"payto://void/the-exchange"),
TALER_TESTING_make_trait_url (TALER_TESTING_UT_EXCHANGE_BANK_ACCOUNT_URL,
fts->exchange_credit_url),
TALER_TESTING_make_trait_amount_obj (0, &fts->amount),
TALER_TESTING_make_trait_absolute_time (0, &fts->timestamp),
TALER_TESTING_make_trait_reserve_pub (0,
&fts->reserve_pub),
TALER_TESTING_make_trait_reserve_history (0,
&fts->reserve_history),
TALER_TESTING_trait_end ()
};
return TALER_TESTING_get_trait (traits,
ret,
trait,
index);
}
} }
@ -548,7 +598,7 @@ TALER_TESTING_cmd_admin_add_incoming (const char *label,
* @param payto_debit_account which account sends money * @param payto_debit_account which account sends money
* @param auth authentication data * @param auth authentication data
* @param ref reference to a command that can offer a reserve * @param ref reference to a command that can offer a reserve
* private key. * private key or public key.
* @return the command. * @return the command.
*/ */
struct TALER_TESTING_Command struct TALER_TESTING_Command