wallet-core: fix recoup issue
This commit is contained in:
parent
aab3f917c4
commit
87bc4a6fcd
@ -281,7 +281,8 @@ async function recoupRefreshCoin(
|
|||||||
revokedCoin.status = CoinStatus.Dormant;
|
revokedCoin.status = CoinStatus.Dormant;
|
||||||
recoupGroup.scheduleRefreshCoins.push({
|
recoupGroup.scheduleRefreshCoins.push({
|
||||||
coinPub: oldCoin.coinPub,
|
coinPub: oldCoin.coinPub,
|
||||||
amount: Amounts.sub(oldCoinDenom.value, revokedCoinDenom.value).amount,
|
//amount: Amounts.sub(oldCoinDenom.value, revokedCoinDenom.value).amount,
|
||||||
|
amount: revokedCoinDenom.value,
|
||||||
});
|
});
|
||||||
await tx.coins.put(revokedCoin);
|
await tx.coins.put(revokedCoin);
|
||||||
await tx.coins.put(oldCoin);
|
await tx.coins.put(oldCoin);
|
||||||
|
@ -426,6 +426,16 @@ async function refreshMelt(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (resp.status === HttpStatusCode.Conflict) {
|
||||||
|
// Just log for better diagnostics here, error status
|
||||||
|
// will be handled later.
|
||||||
|
logger.error(
|
||||||
|
`melt request for ${Amounts.stringify(
|
||||||
|
derived.meltValueWithFee,
|
||||||
|
)} failed in refresh group ${refreshGroupId} due to conflict`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const meltResponse = await readSuccessResponseJsonOrThrow(
|
const meltResponse = await readSuccessResponseJsonOrThrow(
|
||||||
resp,
|
resp,
|
||||||
codecForExchangeMeltResponse(),
|
codecForExchangeMeltResponse(),
|
||||||
|
@ -51,6 +51,7 @@ import {
|
|||||||
WalletContractData,
|
WalletContractData,
|
||||||
} from "../db.js";
|
} from "../db.js";
|
||||||
import { InternalWalletState } from "../internal-wallet-state.js";
|
import { InternalWalletState } from "../internal-wallet-state.js";
|
||||||
|
import { assertUnreachable } from "../util/assertUnreachable.js";
|
||||||
import { checkDbInvariant } from "../util/invariants.js";
|
import { checkDbInvariant } from "../util/invariants.js";
|
||||||
import { RetryTags } from "../util/retries.js";
|
import { RetryTags } from "../util/retries.js";
|
||||||
import {
|
import {
|
||||||
@ -803,33 +804,36 @@ export async function getTransactions(
|
|||||||
const opId = RetryTags.forWithdrawal(wsr);
|
const opId = RetryTags.forWithdrawal(wsr);
|
||||||
const ort = await tx.operationRetries.get(opId);
|
const ort = await tx.operationRetries.get(opId);
|
||||||
|
|
||||||
if (wsr.wgInfo.withdrawalType === WithdrawalRecordType.PeerPullCredit) {
|
switch (wsr.wgInfo.withdrawalType) {
|
||||||
transactions.push(buildTransactionForPullPaymentCredit(wsr, ort));
|
case WithdrawalRecordType.PeerPullCredit:
|
||||||
return;
|
transactions.push(buildTransactionForPullPaymentCredit(wsr, ort));
|
||||||
} else if (
|
return;
|
||||||
wsr.wgInfo.withdrawalType === WithdrawalRecordType.PeerPushCredit
|
case WithdrawalRecordType.PeerPushCredit:
|
||||||
) {
|
transactions.push(buildTransactionForPushPaymentCredit(wsr, ort));
|
||||||
transactions.push(buildTransactionForPushPaymentCredit(wsr, ort));
|
return;
|
||||||
return;
|
case WithdrawalRecordType.BankIntegrated:
|
||||||
} else if (
|
transactions.push(
|
||||||
wsr.wgInfo.withdrawalType === WithdrawalRecordType.BankIntegrated
|
buildTransactionForBankIntegratedWithdraw(wsr, ort),
|
||||||
) {
|
);
|
||||||
transactions.push(
|
return;
|
||||||
buildTransactionForBankIntegratedWithdraw(wsr, ort),
|
case WithdrawalRecordType.BankManual: {
|
||||||
);
|
const exchangeDetails = await getExchangeDetails(
|
||||||
} else {
|
tx,
|
||||||
const exchangeDetails = await getExchangeDetails(
|
wsr.exchangeBaseUrl,
|
||||||
tx,
|
);
|
||||||
wsr.exchangeBaseUrl,
|
if (!exchangeDetails) {
|
||||||
);
|
// FIXME: report somehow
|
||||||
if (!exchangeDetails) {
|
return;
|
||||||
// FIXME: report somehow
|
}
|
||||||
|
|
||||||
|
transactions.push(
|
||||||
|
buildTransactionForManualWithdraw(wsr, exchangeDetails, ort),
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
case WithdrawalRecordType.Recoup:
|
||||||
transactions.push(
|
// FIXME: Do we also report a transaction here?
|
||||||
buildTransactionForManualWithdraw(wsr, exchangeDetails, ort),
|
return;
|
||||||
);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ export namespace RetryTags {
|
|||||||
return `${PendingTaskType.TipPickup}:${tipRecord.walletTipId}`;
|
return `${PendingTaskType.TipPickup}:${tipRecord.walletTipId}`;
|
||||||
}
|
}
|
||||||
export function forRefresh(refreshGroupRecord: RefreshGroupRecord): string {
|
export function forRefresh(refreshGroupRecord: RefreshGroupRecord): string {
|
||||||
return `${PendingTaskType.TipPickup}:${refreshGroupRecord.refreshGroupId}`;
|
return `${PendingTaskType.Refresh}:${refreshGroupRecord.refreshGroupId}`;
|
||||||
}
|
}
|
||||||
export function forPay(purchaseRecord: PurchaseRecord): string {
|
export function forPay(purchaseRecord: PurchaseRecord): string {
|
||||||
return `${PendingTaskType.Purchase}:${purchaseRecord.proposalId}`;
|
return `${PendingTaskType.Purchase}:${purchaseRecord.proposalId}`;
|
||||||
|
Loading…
Reference in New Issue
Block a user