fix recoup response schema / add run-until-done

This commit is contained in:
Florian Dold 2020-03-24 16:34:15 +05:30
parent 01e83df471
commit a8e3422139
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
5 changed files with 10 additions and 107 deletions

View File

@ -388,23 +388,6 @@ export class CryptoApi {
); );
} }
/**
* Validate the signature in a recoup confirmation.
*/
isValidRecoupConfirmation(
recoupCoinPub: EddsaPublicKeyString,
recoupConfirmation: RecoupConfirmation,
exchangeSigningKeys: ExchangeSignKeyJson[],
): Promise<boolean> {
return this.doRpc<boolean>(
"isValidRecoupConfirmation",
1,
recoupCoinPub,
recoupConfirmation,
exchangeSigningKeys,
);
}
signDepositPermission( signDepositPermission(
depositInfo: DepositInfo, depositInfo: DepositInfo,
): Promise<CoinDepositPermission> { ): Promise<CoinDepositPermission> {

View File

@ -518,44 +518,6 @@ export class CryptoImplementation {
return encodeCrock(sig); return encodeCrock(sig);
} }
/**
* Validate the signature in a recoup confirmation.
*/
isValidRecoupConfirmation(
recoupCoinPub: EddsaPublicKeyString,
recoupConfirmation: RecoupConfirmation,
exchangeSigningKeys: ExchangeSignKeyJson[],
): boolean {
const pubEnc = recoupConfirmation.exchange_pub;
if (!checkSignKeyOkay(pubEnc, exchangeSigningKeys)) {
return false;
}
const sig = decodeCrock(recoupConfirmation.exchange_sig);
const pub = decodeCrock(pubEnc);
if (recoupConfirmation.old_coin_pub) {
// We're dealing with a refresh recoup
const p = buildSigPS(
SignaturePurpose.EXCHANGE_CONFIRM_RECOUP_REFRESH,
).put(timestampToBuffer(recoupConfirmation.timestamp))
.put(amountToBuffer(Amounts.parseOrThrow(recoupConfirmation.amount)))
.put(decodeCrock(recoupCoinPub))
.put(decodeCrock(recoupConfirmation.old_coin_pub)).build();
return eddsaVerify(p, sig, pub)
} else if (recoupConfirmation.reserve_pub) {
const p = buildSigPS(
SignaturePurpose.EXCHANGE_CONFIRM_RECOUP_REFRESH,
).put(timestampToBuffer(recoupConfirmation.timestamp))
.put(amountToBuffer(Amounts.parseOrThrow(recoupConfirmation.amount)))
.put(decodeCrock(recoupCoinPub))
.put(decodeCrock(recoupConfirmation.reserve_pub)).build();
return eddsaVerify(p, sig, pub)
} else {
throw Error("invalid recoup confirmation");
}
}
benchmark(repetitions: number): BenchmarkResult { benchmark(repetitions: number): BenchmarkResult {
let time_hash = 0; let time_hash = 0;
for (let i = 0; i < repetitions; i++) { for (let i = 0; i < repetitions; i++) {

View File

@ -241,6 +241,16 @@ walletCli
}); });
}); });
walletCli
.subcommand("finishPendingOpt", "run-until-done", {
help: "Run until no more work is left.",
})
.action(async (args) => {
await withWallet(args, async (wallet) => {
await wallet.runUntilDoneAndStop();
});
});
walletCli walletCli
.subcommand("handleUri", "handle-uri", { .subcommand("handleUri", "handle-uri", {
help: "Handle a taler:// URI.", help: "Handle a taler:// URI.",

View File

@ -153,16 +153,6 @@ async function recoupWithdrawCoin(
return; return;
} }
const isValid = ws.cryptoApi.isValidRecoupConfirmation(
coin.coinPub,
recoupConfirmation,
exchangeDetails.signingKeys,
);
if (!isValid) {
throw Error("invalid recoup confirmation signature");
}
// FIXME: verify that our expectations about the amount match // FIXME: verify that our expectations about the amount match
await ws.db.runWithWriteTransaction( await ws.db.runWithWriteTransaction(
@ -237,16 +227,6 @@ async function recoupRefreshCoin(
return; return;
} }
const isValid = ws.cryptoApi.isValidRecoupConfirmation(
coin.coinPub,
recoupConfirmation,
exchangeDetails.signingKeys,
);
if (!isValid) {
throw Error("invalid recoup confirmation signature");
}
const refreshGroupId = await ws.db.runWithWriteTransaction( const refreshGroupId = await ws.db.runWithWriteTransaction(
[Stores.coins, Stores.reserves], [Stores.coins, Stores.reserves],
async tx => { async tx => {

View File

@ -194,34 +194,6 @@ export class RecoupConfirmation {
* provided if refreshed was true. * provided if refreshed was true.
*/ */
old_coin_pub?: string; old_coin_pub?: string;
/**
* How much will the exchange pay back (needed by wallet in
* case coin was partially spent and wallet got restored from backup)
*/
amount: string;
/**
* Time by which the exchange received the /payback request.
*/
timestamp: Timestamp;
/**
* the EdDSA signature of TALER_PaybackConfirmationPS using a current
* signing key of the exchange affirming the successful
* payback request, and that the exchange promises to transfer the funds
* by the date specified (this allows the exchange delaying the transfer
* a bit to aggregate additional payback requests into a larger one).
*/
exchange_sig: string;
/**
* Public EdDSA key of the exchange that was used to generate the signature.
* Should match one of the exchange's signing keys from /keys. It is given
* explicitly as the client might otherwise be confused by clock skew as to
* which signing key was used.
*/
exchange_pub: string;
} }
/** /**
@ -1010,10 +982,6 @@ export const codecForRecoupConfirmation = () =>
makeCodecForObject<RecoupConfirmation>() makeCodecForObject<RecoupConfirmation>()
.property("reserve_pub", makeCodecOptional(codecForString)) .property("reserve_pub", makeCodecOptional(codecForString))
.property("old_coin_pub", makeCodecOptional(codecForString)) .property("old_coin_pub", makeCodecOptional(codecForString))
.property("amount", codecForString)
.property("timestamp", codecForTimestamp)
.property("exchange_sig", codecForString)
.property("exchange_pub", codecForString)
.build("RecoupConfirmation"), .build("RecoupConfirmation"),
); );