aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2020-03-24 16:34:15 +0530
committerFlorian Dold <florian.dold@gmail.com>2020-03-24 16:34:15 +0530
commita8e342213955de80ebf48972abadbd12e0e7b02a (patch)
tree417df2e7e71ab75391f7870aa2097c1fbdeb9d76 /src
parent01e83df471802d3253953b00672af0bc879403fe (diff)
fix recoup response schema / add run-until-done
Diffstat (limited to 'src')
-rw-r--r--src/crypto/workers/cryptoApi.ts17
-rw-r--r--src/crypto/workers/cryptoImplementation.ts38
-rw-r--r--src/headless/taler-wallet-cli.ts10
-rw-r--r--src/operations/recoup.ts20
-rw-r--r--src/types/talerTypes.ts32
5 files changed, 10 insertions, 107 deletions
diff --git a/src/crypto/workers/cryptoApi.ts b/src/crypto/workers/cryptoApi.ts
index 31ab4dd7e..0b7c2e233 100644
--- a/src/crypto/workers/cryptoApi.ts
+++ b/src/crypto/workers/cryptoApi.ts
@@ -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(
depositInfo: DepositInfo,
): Promise<CoinDepositPermission> {
diff --git a/src/crypto/workers/cryptoImplementation.ts b/src/crypto/workers/cryptoImplementation.ts
index 4d03e70f5..55caecb43 100644
--- a/src/crypto/workers/cryptoImplementation.ts
+++ b/src/crypto/workers/cryptoImplementation.ts
@@ -518,44 +518,6 @@ export class CryptoImplementation {
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 {
let time_hash = 0;
for (let i = 0; i < repetitions; i++) {
diff --git a/src/headless/taler-wallet-cli.ts b/src/headless/taler-wallet-cli.ts
index 174953919..b88023808 100644
--- a/src/headless/taler-wallet-cli.ts
+++ b/src/headless/taler-wallet-cli.ts
@@ -242,6 +242,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
.subcommand("handleUri", "handle-uri", {
help: "Handle a taler:// URI.",
})
diff --git a/src/operations/recoup.ts b/src/operations/recoup.ts
index 163f77591..3c3d0f453 100644
--- a/src/operations/recoup.ts
+++ b/src/operations/recoup.ts
@@ -153,16 +153,6 @@ async function recoupWithdrawCoin(
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
await ws.db.runWithWriteTransaction(
@@ -237,16 +227,6 @@ async function recoupRefreshCoin(
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(
[Stores.coins, Stores.reserves],
async tx => {
diff --git a/src/types/talerTypes.ts b/src/types/talerTypes.ts
index e5be32abe..90751940d 100644
--- a/src/types/talerTypes.ts
+++ b/src/types/talerTypes.ts
@@ -194,34 +194,6 @@ export class RecoupConfirmation {
* provided if refreshed was true.
*/
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>()
.property("reserve_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"),
);