diff options
author | Florian Dold <florian@dold.me> | 2022-03-07 12:09:38 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2022-03-07 12:09:38 +0100 |
commit | 0290c5fd379a4b4262d8835d4131b7c4e8a2f2f2 (patch) | |
tree | 233cbe5e18925339daedfaffb2882d390b3479a5 /packages/taler-wallet-core/src | |
parent | 2cfefa93920eba7bc4bfa3ca788a7bcf74c149f5 (diff) | |
download | wallet-core-0290c5fd379a4b4262d8835d4131b7c4e8a2f2f2.tar.xz |
address protocol changes in the exchange
The exchange now has a wad fee and truncates the payto hash in signatures
Diffstat (limited to 'packages/taler-wallet-core/src')
5 files changed, 22 insertions, 8 deletions
diff --git a/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts b/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts index bd18e8d2e..f9cc63ecc 100644 --- a/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts +++ b/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts @@ -48,6 +48,7 @@ import { hashCoinEv, hashCoinEvInner, hashDenomPub, + hashTruncate32, keyExchangeEcdheEddsa, Logger, MakeSyncSignatureRequest, @@ -329,6 +330,7 @@ export class CryptoImplementation { .put(timestampRoundedToBuffer(wf.endStamp)) .put(amountToBuffer(wf.wireFee)) .put(amountToBuffer(wf.closingFee)) + .put(amountToBuffer(wf.wadFee)) .build(); const sig = decodeCrock(wf.sig); const pub = decodeCrock(masterPub); @@ -376,7 +378,7 @@ export class CryptoImplementation { sig: string, masterPub: string, ): boolean { - const paytoHash = hash(stringToBytes(paytoUri + "\0")); + const paytoHash = hashTruncate32(stringToBytes(paytoUri + "\0")); const p = buildSigPS(TalerSignaturePurpose.MASTER_WIRE_DETAILS) .put(paytoHash) .build(); diff --git a/packages/taler-wallet-core/src/db.ts b/packages/taler-wallet-core/src/db.ts index 410311530..23239069e 100644 --- a/packages/taler-wallet-core/src/db.ts +++ b/packages/taler-wallet-core/src/db.ts @@ -1027,6 +1027,11 @@ export interface WireFee { closingFee: AmountJson; /** + * Fees for inter-exchange transfers from P2P payments. + */ + wadFee: AmountJson; + + /** * Start date of the fee. */ startStamp: Timestamp; diff --git a/packages/taler-wallet-core/src/operations/backup/export.ts b/packages/taler-wallet-core/src/operations/backup/export.ts index 75724dca7..05ef66883 100644 --- a/packages/taler-wallet-core/src/operations/backup/export.ts +++ b/packages/taler-wallet-core/src/operations/backup/export.ts @@ -113,9 +113,8 @@ export async function exportBackup( } = {}; await tx.withdrawalGroups.iter().forEachAsync(async (wg) => { - const withdrawalGroups = (withdrawalGroupsByReserve[ - wg.reservePub - ] ??= []); + const withdrawalGroups = (withdrawalGroupsByReserve[wg.reservePub] ??= + []); withdrawalGroups.push({ raw_withdrawal_amount: Amounts.stringify(wg.rawWithdrawalAmount), selected_denoms: wg.denomsSel.selectedDenoms.map((x) => ({ @@ -288,6 +287,7 @@ export async function exportBackup( wireFees.push({ wire_type: x, closing_fee: Amounts.stringify(f.closingFee), + wad_fee: Amounts.stringify(f.wadFee), end_stamp: f.endStamp, sig: f.sig, start_stamp: f.startStamp, diff --git a/packages/taler-wallet-core/src/operations/backup/import.ts b/packages/taler-wallet-core/src/operations/backup/import.ts index 21b10a945..6dafa8c89 100644 --- a/packages/taler-wallet-core/src/operations/backup/import.ts +++ b/packages/taler-wallet-core/src/operations/backup/import.ts @@ -305,6 +305,7 @@ export async function importBackup( sig: fee.sig, startStamp: fee.start_stamp, wireFee: Amounts.parseOrThrow(fee.wire_fee), + wadFee: Amounts.parseOrThrow(fee.wad_fee), }); } await tx.exchangeDetails.put({ diff --git a/packages/taler-wallet-core/src/operations/exchanges.ts b/packages/taler-wallet-core/src/operations/exchanges.ts index c50afc215..9d4a56fff 100644 --- a/packages/taler-wallet-core/src/operations/exchanges.ts +++ b/packages/taler-wallet-core/src/operations/exchanges.ts @@ -266,6 +266,7 @@ async function validateWireInfo( sig: x.sig, startStamp, wireFee: Amounts.parseOrThrow(x.wire_fee), + wadFee: Amounts.parseOrThrow(x.wad_fee), }; let isValid = false; if (ws.insecureTrustExchange) { @@ -451,7 +452,8 @@ export async function downloadTosFromAcceptedFormat( ws: InternalWalletState, baseUrl: string, timeout: Duration, - acceptedFormat?: string[]): Promise<ExchangeTosDownloadResult> { + acceptedFormat?: string[], +): Promise<ExchangeTosDownloadResult> { let tosFound: ExchangeTosDownloadResult | undefined; //Remove this when exchange supports multiple content-type in accept header if (acceptedFormat) @@ -467,7 +469,7 @@ export async function downloadTosFromAcceptedFormat( break; } } - if (tosFound !== undefined) return tosFound + if (tosFound !== undefined) return tosFound; // If none of the specified format was found try text/plain return await downloadExchangeWithTermsOfService( baseUrl, @@ -550,8 +552,12 @@ async function updateExchangeFromUrlImpl( logger.info("finished validating exchange /wire info"); - - const tosDownload = await downloadTosFromAcceptedFormat(ws, baseUrl, timeout, acceptedFormat) + const tosDownload = await downloadTosFromAcceptedFormat( + ws, + baseUrl, + timeout, + acceptedFormat, + ); let recoupGroupId: string | undefined; |