don't die on auto-refund, fix pending operations
This commit is contained in:
parent
e01f94e345
commit
52da599ddb
@ -310,6 +310,12 @@ export class ContractTerms {
|
|||||||
@Checkable.String()
|
@Checkable.String()
|
||||||
H_wire: string;
|
H_wire: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hash of the merchant's wire details.
|
||||||
|
*/
|
||||||
|
@Checkable.Optional(Checkable.String())
|
||||||
|
auto_refund: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wire method the merchant wants to use.
|
* Wire method the merchant wants to use.
|
||||||
*/
|
*/
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import {
|
import {
|
||||||
PendingOperationInfo,
|
|
||||||
PendingOperationsResponse,
|
PendingOperationsResponse,
|
||||||
getTimestampNow,
|
getTimestampNow,
|
||||||
Timestamp,
|
Timestamp,
|
||||||
@ -158,20 +157,6 @@ async function gatherReservePending(
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case ReserveRecordStatus.WAIT_CONFIRM_BANK:
|
case ReserveRecordStatus.WAIT_CONFIRM_BANK:
|
||||||
if (onlyDue) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
resp.pendingOperations.push({
|
|
||||||
type: "reserve",
|
|
||||||
givesLifeness: false,
|
|
||||||
stage: reserve.reserveStatus,
|
|
||||||
timestampCreated: reserve.created,
|
|
||||||
reserveType,
|
|
||||||
reservePub: reserve.reservePub,
|
|
||||||
bankWithdrawConfirmUrl: reserve.bankWithdrawConfirmUrl,
|
|
||||||
retryInfo: reserve.retryInfo,
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case ReserveRecordStatus.WITHDRAWING:
|
case ReserveRecordStatus.WITHDRAWING:
|
||||||
case ReserveRecordStatus.QUERYING_STATUS:
|
case ReserveRecordStatus.QUERYING_STATUS:
|
||||||
case ReserveRecordStatus.REGISTERING_BANK:
|
case ReserveRecordStatus.REGISTERING_BANK:
|
||||||
@ -327,9 +312,11 @@ async function gatherProposalPending(
|
|||||||
resp.pendingOperations.push({
|
resp.pendingOperations.push({
|
||||||
type: "proposal-download",
|
type: "proposal-download",
|
||||||
givesLifeness: true,
|
givesLifeness: true,
|
||||||
merchantBaseUrl: proposal.download!!.contractTerms.merchant_base_url,
|
merchantBaseUrl: proposal.download?.contractTerms.merchant_base_url || "",
|
||||||
proposalId: proposal.proposalId,
|
proposalId: proposal.proposalId,
|
||||||
proposalTimestamp: proposal.timestamp,
|
proposalTimestamp: proposal.timestamp,
|
||||||
|
lastError: proposal.lastError,
|
||||||
|
retryInfo: proposal.retryInfo,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -326,6 +326,7 @@ async function processReserveBankStatusImpl(
|
|||||||
r.bankWithdrawConfirmUrl = status.confirm_transfer_url;
|
r.bankWithdrawConfirmUrl = status.confirm_transfer_url;
|
||||||
return r;
|
return r;
|
||||||
});
|
});
|
||||||
|
await incrementReserveRetry(ws, reservePub, undefined);
|
||||||
}
|
}
|
||||||
ws.notify( { type: NotificationType.Wildcard });
|
ws.notify( { type: NotificationType.Wildcard });
|
||||||
}
|
}
|
||||||
|
@ -295,20 +295,17 @@ export class Wallet {
|
|||||||
numGivingLiveness++;
|
numGivingLiveness++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let timeout;
|
let dt;
|
||||||
if (
|
if (
|
||||||
allPending.pendingOperations.length === 0 ||
|
allPending.pendingOperations.length === 0 ||
|
||||||
allPending.nextRetryDelay.d_ms === Number.MAX_SAFE_INTEGER
|
allPending.nextRetryDelay.d_ms === Number.MAX_SAFE_INTEGER
|
||||||
) {
|
) {
|
||||||
// Wait forever
|
// Wait for 5 seconds
|
||||||
timeout = new Promise(() => {});
|
dt = 5000;
|
||||||
console.log("waiting forever");
|
|
||||||
} else {
|
} else {
|
||||||
console.log("waiting for timeout", pending.nextRetryDelay);
|
dt = Math.min(5000, allPending.nextRetryDelay.d_ms);
|
||||||
timeout = this.timerGroup.resolveAfter(
|
|
||||||
allPending.nextRetryDelay.d_ms,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
const timeout = this.timerGroup.resolveAfter(dt);
|
||||||
this.ws.notify({
|
this.ws.notify({
|
||||||
type: NotificationType.WaitingForRetry,
|
type: NotificationType.WaitingForRetry,
|
||||||
numGivingLiveness,
|
numGivingLiveness,
|
||||||
@ -319,7 +316,7 @@ export class Wallet {
|
|||||||
} else {
|
} else {
|
||||||
logger.trace("running pending operations that are due");
|
logger.trace("running pending operations that are due");
|
||||||
// FIXME: maybe be a bit smarter about executing these
|
// FIXME: maybe be a bit smarter about executing these
|
||||||
// opeations in parallel?
|
// operations in parallel?
|
||||||
for (const p of pending.pendingOperations) {
|
for (const p of pending.pendingOperations) {
|
||||||
try {
|
try {
|
||||||
console.log("running", p);
|
console.log("running", p);
|
||||||
@ -327,6 +324,7 @@ export class Wallet {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
|
this.ws.notify({ type: NotificationType.Wildcard });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -481,7 +479,11 @@ export class Wallet {
|
|||||||
baseUrl: string,
|
baseUrl: string,
|
||||||
force: boolean = false,
|
force: boolean = false,
|
||||||
): Promise<ExchangeRecord> {
|
): Promise<ExchangeRecord> {
|
||||||
return updateExchangeFromUrl(this.ws, baseUrl, force);
|
try {
|
||||||
|
return updateExchangeFromUrl(this.ws, baseUrl, force);
|
||||||
|
} finally {
|
||||||
|
this.latch.trigger();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -492,7 +494,11 @@ export class Wallet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async refresh(oldCoinPub: string, force: boolean = false): Promise<void> {
|
async refresh(oldCoinPub: string, force: boolean = false): Promise<void> {
|
||||||
return refresh(this.ws, oldCoinPub, force);
|
try {
|
||||||
|
return refresh(this.ws, oldCoinPub, force);
|
||||||
|
} catch (e) {
|
||||||
|
this.latch.trigger();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async findExchange(
|
async findExchange(
|
||||||
@ -638,7 +644,11 @@ export class Wallet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async acceptTip(talerTipUri: string): Promise<void> {
|
async acceptTip(talerTipUri: string): Promise<void> {
|
||||||
return acceptTip(this.ws, talerTipUri);
|
try {
|
||||||
|
return acceptTip(this.ws, talerTipUri);
|
||||||
|
} catch (e) {
|
||||||
|
this.latch.trigger();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async getTipStatus(talerTipUri: string): Promise<TipStatus> {
|
async getTipStatus(talerTipUri: string): Promise<TipStatus> {
|
||||||
@ -646,7 +656,11 @@ export class Wallet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async abortFailedPayment(contractTermsHash: string): Promise<void> {
|
async abortFailedPayment(contractTermsHash: string): Promise<void> {
|
||||||
return abortFailedPayment(this.ws, contractTermsHash);
|
try {
|
||||||
|
return abortFailedPayment(this.ws, contractTermsHash);
|
||||||
|
} finally {
|
||||||
|
this.latch.trigger();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async handleNotifyReserve() {
|
public async handleNotifyReserve() {
|
||||||
@ -680,14 +694,22 @@ export class Wallet {
|
|||||||
async getWithdrawalInfo(
|
async getWithdrawalInfo(
|
||||||
talerWithdrawUri: string,
|
talerWithdrawUri: string,
|
||||||
): Promise<DownloadedWithdrawInfo> {
|
): Promise<DownloadedWithdrawInfo> {
|
||||||
return getWithdrawalInfo(this.ws, talerWithdrawUri);
|
try {
|
||||||
|
return getWithdrawalInfo(this.ws, talerWithdrawUri);
|
||||||
|
} finally {
|
||||||
|
this.latch.trigger();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async acceptWithdrawal(
|
async acceptWithdrawal(
|
||||||
talerWithdrawUri: string,
|
talerWithdrawUri: string,
|
||||||
selectedExchange: string,
|
selectedExchange: string,
|
||||||
): Promise<AcceptWithdrawalResponse> {
|
): Promise<AcceptWithdrawalResponse> {
|
||||||
return acceptWithdrawal(this.ws, talerWithdrawUri, selectedExchange);
|
try {
|
||||||
|
return acceptWithdrawal(this.ws, talerWithdrawUri, selectedExchange);
|
||||||
|
} finally {
|
||||||
|
this.latch.trigger();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async getPurchaseDetails(hc: string): Promise<PurchaseDetails> {
|
async getPurchaseDetails(hc: string): Promise<PurchaseDetails> {
|
||||||
|
@ -236,12 +236,6 @@ export interface HistoryEvent {
|
|||||||
*/
|
*/
|
||||||
timestamp: Timestamp;
|
timestamp: Timestamp;
|
||||||
|
|
||||||
/**
|
|
||||||
* Subject of the entry. Used to group multiple history records together.
|
|
||||||
* Only the latest history record with the same subjectId will be shown.
|
|
||||||
*/
|
|
||||||
subjectId?: string;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Details used when rendering the history record.
|
* Details used when rendering the history record.
|
||||||
*/
|
*/
|
||||||
@ -747,6 +741,8 @@ export interface PendingProposalDownloadOperation {
|
|||||||
merchantBaseUrl: string;
|
merchantBaseUrl: string;
|
||||||
proposalTimestamp: Timestamp;
|
proposalTimestamp: Timestamp;
|
||||||
proposalId: string;
|
proposalId: string;
|
||||||
|
lastError?: OperationError;
|
||||||
|
retryInfo: RetryInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user