aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2022-09-16 16:24:47 +0200
committerFlorian Dold <florian@dold.me>2022-09-16 16:34:00 +0200
commit374d3498d8233688fe009db025b4ae0add46bb19 (patch)
tree2bd08bffa4b4819008d154bbbaac0a7b63a14f53 /packages/taler-wallet-core/src/operations
parentb91caf977fad8da11e523ca3a39064dd86e04c64 (diff)
downloadwallet-core-374d3498d8233688fe009db025b4ae0add46bb19.tar.xz
-cleanup
Diffstat (limited to 'packages/taler-wallet-core/src/operations')
-rw-r--r--packages/taler-wallet-core/src/operations/pay.ts34
-rw-r--r--packages/taler-wallet-core/src/operations/peer-to-peer.ts26
2 files changed, 19 insertions, 41 deletions
diff --git a/packages/taler-wallet-core/src/operations/pay.ts b/packages/taler-wallet-core/src/operations/pay.ts
index ab59fff87..6b366f50d 100644
--- a/packages/taler-wallet-core/src/operations/pay.ts
+++ b/packages/taler-wallet-core/src/operations/pay.ts
@@ -24,7 +24,7 @@
/**
* Imports.
*/
-import { BridgeIDBKeyRange, GlobalIDB } from "@gnu-taler/idb-bridge";
+import { GlobalIDB } from "@gnu-taler/idb-bridge";
import {
AbsoluteTime,
AgeRestriction,
@@ -47,7 +47,6 @@ import {
j2s,
Logger,
NotificationType,
- parsePaytoUri,
parsePayUri,
PayCoinSelection,
PreparePayResult,
@@ -75,7 +74,6 @@ import {
ProposalStatus,
PurchaseRecord,
WalletContractData,
- WalletStoresV1,
} from "../db.js";
import {
makeErrorDetail,
@@ -88,11 +86,8 @@ import {
} from "../internal-wallet-state.js";
import { assertUnreachable } from "../util/assertUnreachable.js";
import {
- AvailableCoinInfo,
- CoinCandidateSelection,
CoinSelectionTally,
PreviousPayCoins,
- selectForcedPayCoins,
tallyFees,
} from "../util/coinSelection.js";
import {
@@ -104,11 +99,10 @@ import {
throwUnexpectedRequestError,
} from "../util/http.js";
import { checkDbInvariant, checkLogicInvariant } from "../util/invariants.js";
-import { GetReadWriteAccess } from "../util/query.js";
import { RetryInfo, RetryTags, scheduleRetry } from "../util/retries.js";
import { spendCoins } from "../wallet.js";
import { getExchangeDetails } from "./exchanges.js";
-import { createRefreshGroup, getTotalRefreshCost } from "./refresh.js";
+import { getTotalRefreshCost } from "./refresh.js";
import { makeEventId } from "./transactions.js";
/**
@@ -170,24 +164,6 @@ export async function getTotalPaymentCost(
});
}
-function isSpendableCoin(coin: CoinRecord, denom: DenominationRecord): boolean {
- if (denom.isRevoked) {
- return false;
- }
- if (!denom.isOffered) {
- return false;
- }
- if (coin.status !== CoinStatus.Fresh) {
- return false;
- }
- if (
- AbsoluteTime.isExpired(AbsoluteTime.fromTimestamp(denom.stampExpireDeposit))
- ) {
- return false;
- }
- return true;
-}
-
export interface CoinSelectionRequest {
amount: AmountJson;
@@ -898,7 +874,7 @@ export type AvailableDenom = DenominationInfo & {
numAvailable: number;
};
-async function selectCandidates(
+export async function selectCandidates(
ws: InternalWalletState,
req: SelectPayCoinRequestNg,
): Promise<[AvailableDenom[], Record<string, AmountJson>]> {
@@ -937,7 +913,7 @@ async function selectCandidates(
continue;
}
let ageLower = 0;
- let ageUpper = Number.MAX_SAFE_INTEGER;
+ let ageUpper = AgeRestriction.AGE_UNRESTRICTED;
if (req.requiredMinimumAge) {
ageLower = req.requiredMinimumAge;
}
@@ -1522,7 +1498,7 @@ export async function runPayForConfirmPay(
return {
type: ConfirmPayResultType.Done,
contractTerms: purchase.download.contractTermsRaw,
- transactionId: makeEventId(TransactionType.Payment, proposalId)
+ transactionId: makeEventId(TransactionType.Payment, proposalId),
};
}
case OperationAttemptResultType.Error:
diff --git a/packages/taler-wallet-core/src/operations/peer-to-peer.ts b/packages/taler-wallet-core/src/operations/peer-to-peer.ts
index ffbc1fc97..48d422e0b 100644
--- a/packages/taler-wallet-core/src/operations/peer-to-peer.ts
+++ b/packages/taler-wallet-core/src/operations/peer-to-peer.ts
@@ -24,7 +24,8 @@ import {
AcceptPeerPushPaymentRequest,
AcceptPeerPushPaymentResponse,
AgeCommitmentProof,
- AmountJson, Amounts,
+ AmountJson,
+ Amounts,
AmountString,
buildCodecForObject,
CheckPeerPullPaymentRequest,
@@ -34,7 +35,8 @@ import {
Codec,
codecForAmountString,
codecForAny,
- codecForExchangeGetContractResponse, constructPayPullUri,
+ codecForExchangeGetContractResponse,
+ constructPayPullUri,
constructPayPushUri,
ContractTermsUtil,
decodeCrock,
@@ -58,14 +60,14 @@ import {
TalerProtocolTimestamp,
TransactionType,
UnblindedSignature,
- WalletAccountMergeFlags
+ WalletAccountMergeFlags,
} from "@gnu-taler/taler-util";
import {
CoinStatus,
MergeReserveInfo,
ReserveRecordStatus,
WalletStoresV1,
- WithdrawalRecordType
+ WithdrawalRecordType,
} from "../db.js";
import { InternalWalletState } from "../internal-wallet-state.js";
import { readSuccessResponseJsonOrThrow } from "../util/http.js";
@@ -339,7 +341,7 @@ export async function initiatePeerToPeerPush(
exchangeBaseUrl: coinSelRes.exchangeBaseUrl,
contractPriv: econtractResp.contractPriv,
}),
- transactionId: makeEventId(TransactionType.PeerPushDebit, pursePair.pub)
+ transactionId: makeEventId(TransactionType.PeerPushDebit, pursePair.pub),
};
}
@@ -552,9 +554,9 @@ export async function acceptPeerPushPayment(
return {
transactionId: makeEventId(
TransactionType.PeerPushCredit,
- wg.withdrawalGroupId
- )
- }
+ wg.withdrawalGroupId,
+ ),
+ };
}
/**
@@ -645,8 +647,8 @@ export async function acceptPeerPullPayment(
transactionId: makeEventId(
TransactionType.PeerPullDebit,
req.peerPullPaymentIncomingId,
- )
- }
+ ),
+ };
}
export async function checkPeerPullPayment(
@@ -840,7 +842,7 @@ export async function initiatePeerRequestForPay(
}),
transactionId: makeEventId(
TransactionType.PeerPullCredit,
- wg.withdrawalGroupId
- )
+ wg.withdrawalGroupId,
+ ),
};
}