Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/Data/Models/AuditLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@ public enum AuditActionType
WithdrawalInterceptorConnected,
WithdrawalInterceptorDisconnected,
WithdrawalAllowedByIntegrator,
WithdrawalBlockedByIntegrator
WithdrawalBlockedByIntegrator,

// RBF cancellation: a replacement request that sends the funds back to the wallet
RbfCancel
}

/// <summary>
Expand Down
1 change: 1 addition & 0 deletions src/Pages/AuditTrail.razor
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@
AuditActionType.Approve => Color.Success,
AuditActionType.Reject => Color.Warning,
AuditActionType.Cancel => Color.Secondary,
AuditActionType.RbfCancel => Color.Secondary,
AuditActionType.Login => Color.Primary,
AuditActionType.Logout => Color.Secondary,
AuditActionType.TwoFactorLogin => Color.Primary,
Expand Down
25 changes: 14 additions & 11 deletions src/Pages/Withdrawals.razor
Original file line number Diff line number Diff line change
Expand Up @@ -943,29 +943,32 @@
}
}

/// <summary>The audit action of the bump modal's current operation: an RBF cancellation or a fee bump.</summary>
private AuditActionType BumpAuditAction => _bumpIsCancellation ? AuditActionType.RbfCancel : AuditActionType.BumpFee;

private async Task ShowBumpfeeModal(WalletWithdrawalRequest walletWithdrawalRequest, bool cancellation = false)
{
_bumpIsCancellation = cancellation;
if (walletWithdrawalRequest == null)
{
ToastService.ShowError("Invalid request");
await LogWithdrawalAuditAsync(AuditActionType.BumpFee, AuditEventType.Failure, null, "Invalid bump fee request.");
await LogWithdrawalAuditAsync(BumpAuditAction, AuditEventType.Failure, null, "Invalid RBF replacement request.");
return;
}

var request = await WalletWithdrawalRequestRepository.GetById(walletWithdrawalRequest.Id);
if (request == null)
{
ToastService.ShowError("Request not found");
await LogWithdrawalAuditAsync(AuditActionType.BumpFee, AuditEventType.Failure, walletWithdrawalRequest, "Withdrawal request not found for bumping.");
await LogWithdrawalAuditAsync(BumpAuditAction, AuditEventType.Failure, walletWithdrawalRequest, "Withdrawal request to replace not found.");
return;
}

// We check in case that someone tries to bump a request that is not in the right state
if (request.Status != WalletWithdrawalRequestStatus.OnChainConfirmationPending)
{
ToastService.ShowError("Bumpfee can only be used for transactions that are pending on-chain confirmation.");
await LogWithdrawalAuditAsync(AuditActionType.BumpFee, AuditEventType.Failure, request, "Bump requested for withdrawal not pending on-chain confirmation.");
await LogWithdrawalAuditAsync(BumpAuditAction, AuditEventType.Failure, request, "RBF replacement requested for withdrawal not pending on-chain confirmation.");
return;
}

Expand All @@ -980,7 +983,7 @@
catch (Exception)
{
ToastService.ShowError("Error getting confirmations");
await LogWithdrawalAuditAsync(AuditActionType.BumpFee, AuditEventType.Failure, request, "Failed to retrieve transaction confirmations for bumping.");
await LogWithdrawalAuditAsync(BumpAuditAction, AuditEventType.Failure, request, "Failed to retrieve transaction confirmations for the RBF replacement.");
return;
}
}
Expand All @@ -989,15 +992,15 @@
{
ToastService.ShowError("Bumpfee can only be used for transactions with no confirmations. " +
"This transaction has already been mined.");
await LogWithdrawalAuditAsync(AuditActionType.BumpFee, AuditEventType.Failure, request, "Bump requested for transaction that already has confirmations.");
await LogWithdrawalAuditAsync(BumpAuditAction, AuditEventType.Failure, request, "RBF replacement requested for transaction that already has confirmations.");
return;
}

// A cancellation replaces every output, so the shape of the original does not matter to it.
if (!cancellation && request.Changeless && request.WalletWithdrawalRequestDestinations!.Count > 1)
{
ToastService.ShowError("Fee bumping is not supported for changeless transactions. Please create a new withdrawal with higher fees instead.");
await LogWithdrawalAuditAsync(AuditActionType.BumpFee, AuditEventType.Failure, request, "Bump requested for changeless transaction with multiple outputs.");
await LogWithdrawalAuditAsync(BumpAuditAction, AuditEventType.Failure, request, "Bump requested for changeless transaction with multiple outputs.");
return;
}

Expand All @@ -1010,8 +1013,8 @@
catch (Exception ex)
{
ToastService.ShowError("Error while creating bumpfee modal");
var message = string.IsNullOrWhiteSpace(ex.Message) ? "Error while creating bump fee modal." : ex.Message;
await LogWithdrawalAuditAsync(AuditActionType.BumpFee, AuditEventType.Failure, request, message);
var message = string.IsNullOrWhiteSpace(ex.Message) ? "Error while creating the RBF replacement modal." : ex.Message;
await LogWithdrawalAuditAsync(BumpAuditAction, AuditEventType.Failure, request, message);
}
}

Expand Down Expand Up @@ -1106,14 +1109,14 @@
if (newRequest == null || _bumpfeeRef == null)
{
ToastService.ShowError("Something went wrong");
await LogWithdrawalAuditAsync(AuditActionType.BumpFee, AuditEventType.Failure, newRequest, "Invalid bump fee request parameters.");
await LogWithdrawalAuditAsync(BumpAuditAction, AuditEventType.Failure, newRequest, "Invalid RBF replacement request parameters.");
return;
}

// The replacement was validated, created and its UTXOs locked by WithdrawalRequestService (see BumpfeeModal).
_selectedRequest = newRequest;
await _bumpfeeRef.HideModal();
await LogWithdrawalAuditAsync(newRequest.IsRbfCancellation ? AuditActionType.Cancel : AuditActionType.BumpFee,
await LogWithdrawalAuditAsync(newRequest.IsRbfCancellation ? AuditActionType.RbfCancel : AuditActionType.BumpFee,
AuditEventType.Success, newRequest,
newRequest.IsRbfCancellation ? "RBF cancellation request created." : "Bump withdrawal request created.");
await GetData();
Expand All @@ -1134,7 +1137,7 @@
{
Logger.LogError(e, "Error while bumping withdrawal request {RequestId}", newRequest?.Id);
ToastService.ShowError("Something went wrong");
await LogWithdrawalAuditAsync(AuditActionType.BumpFee, AuditEventType.Failure, newRequest, "Unexpected error while bumping withdrawal.");
await LogWithdrawalAuditAsync(BumpAuditAction, AuditEventType.Failure, newRequest, "Unexpected error while replacing withdrawal.");
if (_bumpfeeRef != null) await _bumpfeeRef.HideModal();
}
}
Expand Down
Loading
Loading