logging, cosmetic fixes
This commit is contained in:
parent
6293de7bfa
commit
19eb72e277
@ -31,7 +31,7 @@ import {
|
|||||||
ExchangeUpdateReason,
|
ExchangeUpdateReason,
|
||||||
MetaStores,
|
MetaStores,
|
||||||
} from "../types/dbTypes";
|
} from "../types/dbTypes";
|
||||||
import { canonicalizeBaseUrl } from "../util/helpers";
|
import { canonicalizeBaseUrl, j2s } from "../util/helpers";
|
||||||
import * as Amounts from "../util/amounts";
|
import * as Amounts from "../util/amounts";
|
||||||
import { parsePaytoUri } from "../util/payto";
|
import { parsePaytoUri } from "../util/payto";
|
||||||
import {
|
import {
|
||||||
@ -145,6 +145,7 @@ async function updateExchangeWithKeys(
|
|||||||
);
|
);
|
||||||
|
|
||||||
logger.info("received /keys response");
|
logger.info("received /keys response");
|
||||||
|
logger.trace(j2s(exchangeKeysJson));
|
||||||
|
|
||||||
if (exchangeKeysJson.denoms.length === 0) {
|
if (exchangeKeysJson.denoms.length === 0) {
|
||||||
const opErr = makeErrorDetails(
|
const opErr = makeErrorDetails(
|
||||||
|
@ -50,7 +50,7 @@ import {
|
|||||||
denomSelectionInfoToState,
|
denomSelectionInfoToState,
|
||||||
updateWithdrawalDenoms,
|
updateWithdrawalDenoms,
|
||||||
selectWithdrawalDenominations,
|
selectWithdrawalDenominations,
|
||||||
getPossibleWithdrawalDenoms,
|
getCandidateWithdrawalDenoms,
|
||||||
} from "./withdraw";
|
} from "./withdraw";
|
||||||
import {
|
import {
|
||||||
guardOperationException,
|
guardOperationException,
|
||||||
@ -135,7 +135,7 @@ export async function createReserve(
|
|||||||
const initialWithdrawalGroupId = encodeCrock(getRandomBytes(32));
|
const initialWithdrawalGroupId = encodeCrock(getRandomBytes(32));
|
||||||
|
|
||||||
await updateWithdrawalDenoms(ws, canonExchange);
|
await updateWithdrawalDenoms(ws, canonExchange);
|
||||||
const denoms = await getPossibleWithdrawalDenoms(ws, canonExchange);
|
const denoms = await getCandidateWithdrawalDenoms(ws, canonExchange);
|
||||||
const denomSelInfo = selectWithdrawalDenominations(req.amount, denoms);
|
const denomSelInfo = selectWithdrawalDenominations(req.amount, denoms);
|
||||||
const initialDenomSel = denomSelectionInfoToState(denomSelInfo);
|
const initialDenomSel = denomSelectionInfoToState(denomSelInfo);
|
||||||
|
|
||||||
@ -528,7 +528,7 @@ async function updateReserve(
|
|||||||
const currency = balance.currency;
|
const currency = balance.currency;
|
||||||
|
|
||||||
await updateWithdrawalDenoms(ws, reserve.exchangeBaseUrl);
|
await updateWithdrawalDenoms(ws, reserve.exchangeBaseUrl);
|
||||||
const denoms = await getPossibleWithdrawalDenoms(ws, reserve.exchangeBaseUrl);
|
const denoms = await getCandidateWithdrawalDenoms(ws, reserve.exchangeBaseUrl);
|
||||||
|
|
||||||
const newWithdrawalGroup = await ws.db.runWithWriteTransaction(
|
const newWithdrawalGroup = await ws.db.runWithWriteTransaction(
|
||||||
[Stores.coins, Stores.planchets, Stores.withdrawalGroups, Stores.reserves],
|
[Stores.coins, Stores.planchets, Stores.withdrawalGroups, Stores.reserves],
|
||||||
|
@ -34,7 +34,7 @@ import {
|
|||||||
getExchangeWithdrawalInfo,
|
getExchangeWithdrawalInfo,
|
||||||
denomSelectionInfoToState,
|
denomSelectionInfoToState,
|
||||||
updateWithdrawalDenoms,
|
updateWithdrawalDenoms,
|
||||||
getPossibleWithdrawalDenoms,
|
getCandidateWithdrawalDenoms,
|
||||||
selectWithdrawalDenominations,
|
selectWithdrawalDenominations,
|
||||||
} from "./withdraw";
|
} from "./withdraw";
|
||||||
import { updateExchangeFromUrl } from "./exchanges";
|
import { updateExchangeFromUrl } from "./exchanges";
|
||||||
@ -95,7 +95,7 @@ export async function prepareTip(
|
|||||||
|
|
||||||
const walletTipId = encodeCrock(getRandomBytes(32));
|
const walletTipId = encodeCrock(getRandomBytes(32));
|
||||||
await updateWithdrawalDenoms(ws, tipPickupStatus.exchange_url);
|
await updateWithdrawalDenoms(ws, tipPickupStatus.exchange_url);
|
||||||
const denoms = await getPossibleWithdrawalDenoms(
|
const denoms = await getCandidateWithdrawalDenoms(
|
||||||
ws,
|
ws,
|
||||||
tipPickupStatus.exchange_url,
|
tipPickupStatus.exchange_url,
|
||||||
);
|
);
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { selectWithdrawalDenominations } from "./withdraw";
|
import { selectWithdrawalDenominations } from "./withdraw";
|
||||||
import { Amounts } from "../util/amounts";
|
import { Amounts } from "../util/amounts";
|
||||||
|
import { DenominationRecord, DenominationStatus } from "../types/dbTypes";
|
||||||
|
|
||||||
test("withdrawal selection bug repro", (t) => {
|
test("withdrawal selection bug repro", (t) => {
|
||||||
const amount = {
|
const amount = {
|
||||||
@ -25,7 +26,7 @@ test("withdrawal selection bug repro", (t) => {
|
|||||||
value: 23,
|
value: 23,
|
||||||
};
|
};
|
||||||
|
|
||||||
const denoms = [
|
const denoms: DenominationRecord[] = [
|
||||||
{
|
{
|
||||||
denomPub:
|
denomPub:
|
||||||
"040000XT67C8KBD6B75TTQ3SK8FWXMNQW4372T3BDDGPAMB9RFCA03638W8T3F71WFEFK9NP32VKYVNFXPYRWQ1N1HDKV5J0DFEKHBPJCYSWCBJDRNWD7G8BN8PT97FA9AMV75MYEK4X54D1HGJ207JSVJBGFCATSPNTEYNHEQF1F220W00TBZR1HNPDQFD56FG0DJQ9KGHM8EC33H6AY9YN9CNX5R3Z4TZ4Q23W47SBHB13H6W74FQJG1F50X38VRSC4SR8RWBAFB7S4K8D2H4NMRFSQT892A3T0BTBW7HM5C0H2CK6FRKG31F7W9WP1S29013K5CXYE55CT8TH6N8J9B780R42Y5S3ZB6J6E9H76XBPSGH4TGYSR2VZRB98J417KCQMZKX1BB67E7W5KVE37TC9SJ904002",
|
"040000XT67C8KBD6B75TTQ3SK8FWXMNQW4372T3BDDGPAMB9RFCA03638W8T3F71WFEFK9NP32VKYVNFXPYRWQ1N1HDKV5J0DFEKHBPJCYSWCBJDRNWD7G8BN8PT97FA9AMV75MYEK4X54D1HGJ207JSVJBGFCATSPNTEYNHEQF1F220W00TBZR1HNPDQFD56FG0DJQ9KGHM8EC33H6AY9YN9CNX5R3Z4TZ4Q23W47SBHB13H6W74FQJG1F50X38VRSC4SR8RWBAFB7S4K8D2H4NMRFSQT892A3T0BTBW7HM5C0H2CK6FRKG31F7W9WP1S29013K5CXYE55CT8TH6N8J9B780R42Y5S3ZB6J6E9H76XBPSGH4TGYSR2VZRB98J417KCQMZKX1BB67E7W5KVE37TC9SJ904002",
|
||||||
@ -68,7 +69,7 @@ test("withdrawal selection bug repro", (t) => {
|
|||||||
stampStart: {
|
stampStart: {
|
||||||
t_ms: 1585229388000,
|
t_ms: 1585229388000,
|
||||||
},
|
},
|
||||||
status: 0,
|
status: DenominationStatus.Unverified,
|
||||||
value: {
|
value: {
|
||||||
currency: "KUDOS",
|
currency: "KUDOS",
|
||||||
fraction: 0,
|
fraction: 0,
|
||||||
@ -117,7 +118,7 @@ test("withdrawal selection bug repro", (t) => {
|
|||||||
stampStart: {
|
stampStart: {
|
||||||
t_ms: 1585229388000,
|
t_ms: 1585229388000,
|
||||||
},
|
},
|
||||||
status: 0,
|
status: DenominationStatus.Unverified,
|
||||||
value: {
|
value: {
|
||||||
currency: "KUDOS",
|
currency: "KUDOS",
|
||||||
fraction: 0,
|
fraction: 0,
|
||||||
@ -166,7 +167,7 @@ test("withdrawal selection bug repro", (t) => {
|
|||||||
stampStart: {
|
stampStart: {
|
||||||
t_ms: 1585229388000,
|
t_ms: 1585229388000,
|
||||||
},
|
},
|
||||||
status: 0,
|
status: DenominationStatus.Unverified,
|
||||||
value: {
|
value: {
|
||||||
currency: "KUDOS",
|
currency: "KUDOS",
|
||||||
fraction: 0,
|
fraction: 0,
|
||||||
@ -215,7 +216,7 @@ test("withdrawal selection bug repro", (t) => {
|
|||||||
stampStart: {
|
stampStart: {
|
||||||
t_ms: 1585229388000,
|
t_ms: 1585229388000,
|
||||||
},
|
},
|
||||||
status: 0,
|
status: DenominationStatus.Unverified,
|
||||||
value: {
|
value: {
|
||||||
currency: "KUDOS",
|
currency: "KUDOS",
|
||||||
fraction: 0,
|
fraction: 0,
|
||||||
@ -264,7 +265,7 @@ test("withdrawal selection bug repro", (t) => {
|
|||||||
stampStart: {
|
stampStart: {
|
||||||
t_ms: 1585229388000,
|
t_ms: 1585229388000,
|
||||||
},
|
},
|
||||||
status: 0,
|
status: DenominationStatus.Unverified,
|
||||||
value: {
|
value: {
|
||||||
currency: "KUDOS",
|
currency: "KUDOS",
|
||||||
fraction: 10000000,
|
fraction: 10000000,
|
||||||
@ -313,7 +314,7 @@ test("withdrawal selection bug repro", (t) => {
|
|||||||
stampStart: {
|
stampStart: {
|
||||||
t_ms: 1585229388000,
|
t_ms: 1585229388000,
|
||||||
},
|
},
|
||||||
status: 0,
|
status: DenominationStatus.Unverified,
|
||||||
value: {
|
value: {
|
||||||
currency: "KUDOS",
|
currency: "KUDOS",
|
||||||
fraction: 0,
|
fraction: 0,
|
||||||
|
@ -67,6 +67,7 @@ import { TalerErrorCode } from "../TalerErrorCode";
|
|||||||
import { encodeCrock } from "../crypto/talerCrypto";
|
import { encodeCrock } from "../crypto/talerCrypto";
|
||||||
import { updateRetryInfoTimeout, initRetryInfo } from "../util/retries";
|
import { updateRetryInfoTimeout, initRetryInfo } from "../util/retries";
|
||||||
import { compare } from "../util/libtoolVersion";
|
import { compare } from "../util/libtoolVersion";
|
||||||
|
import { j2s } from "../util/helpers";
|
||||||
|
|
||||||
const logger = new Logger("withdraw.ts");
|
const logger = new Logger("withdraw.ts");
|
||||||
|
|
||||||
@ -207,7 +208,7 @@ export async function getBankWithdrawalInfo(
|
|||||||
/**
|
/**
|
||||||
* Return denominations that can potentially used for a withdrawal.
|
* Return denominations that can potentially used for a withdrawal.
|
||||||
*/
|
*/
|
||||||
export async function getPossibleWithdrawalDenoms(
|
export async function getCandidateWithdrawalDenoms(
|
||||||
ws: InternalWalletState,
|
ws: InternalWalletState,
|
||||||
exchangeBaseUrl: string,
|
exchangeBaseUrl: string,
|
||||||
): Promise<DenominationRecord[]> {
|
): Promise<DenominationRecord[]> {
|
||||||
@ -544,7 +545,7 @@ export async function updateWithdrawalDenoms(
|
|||||||
logger.error("exchange details not available");
|
logger.error("exchange details not available");
|
||||||
throw Error(`exchange ${exchangeBaseUrl} details not available`);
|
throw Error(`exchange ${exchangeBaseUrl} details not available`);
|
||||||
}
|
}
|
||||||
const denominations = await getPossibleWithdrawalDenoms(ws, exchangeBaseUrl);
|
const denominations = await getCandidateWithdrawalDenoms(ws, exchangeBaseUrl);
|
||||||
for (const denom of denominations) {
|
for (const denom of denominations) {
|
||||||
if (denom.status === DenominationStatus.Unverified) {
|
if (denom.status === DenominationStatus.Unverified) {
|
||||||
const valid = await ws.cryptoApi.isValidDenom(
|
const valid = await ws.cryptoApi.isValidDenom(
|
||||||
@ -559,6 +560,29 @@ export async function updateWithdrawalDenoms(
|
|||||||
await ws.db.put(Stores.denominations, denom);
|
await ws.db.put(Stores.denominations, denom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// FIXME: This debug info should either be made conditional on some flag
|
||||||
|
// or put into some wallet-core API.
|
||||||
|
logger.trace("updated withdrawable denominations");
|
||||||
|
const nextDenominations = await getCandidateWithdrawalDenoms(
|
||||||
|
ws,
|
||||||
|
exchangeBaseUrl,
|
||||||
|
);
|
||||||
|
const now = getTimestampNow();
|
||||||
|
for (const denom of nextDenominations) {
|
||||||
|
const started = timestampCmp(now, denom.stampStart) >= 0;
|
||||||
|
const lastPossibleWithdraw = timestampSubtractDuraction(
|
||||||
|
denom.stampExpireWithdraw,
|
||||||
|
{ d_ms: 50 * 1000 },
|
||||||
|
);
|
||||||
|
const remaining = getDurationRemaining(lastPossibleWithdraw, now);
|
||||||
|
logger.trace(
|
||||||
|
`Denom ${denom.denomPubHash} ${denom.status} revoked ${
|
||||||
|
denom.isRevoked
|
||||||
|
} offered ${denom.isOffered} remaining ${
|
||||||
|
(remaining.d_ms as number) / 1000
|
||||||
|
}sec started ${started}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function incrementWithdrawalRetry(
|
async function incrementWithdrawalRetry(
|
||||||
@ -725,7 +749,7 @@ export async function getExchangeWithdrawalInfo(
|
|||||||
}
|
}
|
||||||
|
|
||||||
await updateWithdrawalDenoms(ws, baseUrl);
|
await updateWithdrawalDenoms(ws, baseUrl);
|
||||||
const denoms = await getPossibleWithdrawalDenoms(ws, baseUrl);
|
const denoms = await getCandidateWithdrawalDenoms(ws, baseUrl);
|
||||||
const selectedDenoms = selectWithdrawalDenominations(amount, denoms);
|
const selectedDenoms = selectWithdrawalDenominations(amount, denoms);
|
||||||
const exchangeWireAccounts: string[] = [];
|
const exchangeWireAccounts: string[] = [];
|
||||||
for (const account of exchangeWireInfo.accounts) {
|
for (const account of exchangeWireInfo.accounts) {
|
||||||
|
@ -261,15 +261,15 @@ export enum DenominationStatus {
|
|||||||
/**
|
/**
|
||||||
* Verification was delayed.
|
* Verification was delayed.
|
||||||
*/
|
*/
|
||||||
Unverified,
|
Unverified = "unverified",
|
||||||
/**
|
/**
|
||||||
* Verified as valid.
|
* Verified as valid.
|
||||||
*/
|
*/
|
||||||
VerifiedGood,
|
VerifiedGood = "verified-good",
|
||||||
/**
|
/**
|
||||||
* Verified as invalid.
|
* Verified as invalid.
|
||||||
*/
|
*/
|
||||||
VerifiedBad,
|
VerifiedBad = "verified-bad",
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user