Repository navigation
Audit gRPC-created requests, wallet transfers and user roles - #666
Merged
Merged
Conversation
Jossec101
added a commit
that referenced
this pull request
Nov 12, 2026
…668) * feat: SubscribeWalletEvents streams a wallet's withdrawal events over gRPC - New bidirectional RPC: the first client message subscribes to a wallet; the server answers WALLET_EVENT_SUBSCRIBED, then one WalletEvent per withdrawal change (created, signature added, signing, broadcast, confirmed, bumped, cancelled, rejected, failed, replacement reverted), with RBF links. - In-process WalletEventHub (live only, bounded per subscriber; a slow subscriber is dropped with RESOURCE_EXHAUSTED, shutdown ends calls with UNAVAILABLE). - The withdrawal repositories publish after each successful save, diffing status/TxId against the stored row only when someone subscribes to the wallet. - GRPCAuthInterceptor now authenticates streaming calls too (previously unary only) and exposes the token. - Kestrel HTTP/2 keepalive pings so idle streams survive proxies. * refactor: let the withdrawal event publisher decide when to read a request's state before an update - WalletWithdrawalRequestRepository.Update no longer checks for subscribers: it always calls ReadBeforeUpdate before the write and PublishUpdated after a successful one. - The publisher reads the stored status/TxId only when someone subscribes to the wallet and the request was saved; it returns null on a failed read and never throws. - IsWatched is now private to the publisher. * fix: keep only the API token's id and name on an authenticated gRPC call - GRPCAuthInterceptor stores an AuthenticatedApiToken(Id, Name) instead of the APIToken row, so the token value never travels down the call. - Same record, file and key as #666 (HttpContext.Items "NodeGuard.ApiToken"; UserState is HttpContext.Items under ASP.NET Core), so AuditService identifies the token on streaming calls once #666 merges. - GetApiToken keeps its name and now returns AuthenticatedApiToken.
Jossec101
reviewed
Nov 12, 2026
Contributor
Author
|
@Jossec101 btw, your review found problems that were introduced before this PR. I fixed them anyway because they were easy wins |
Jossec101
previously approved these changes
Nov 12, 2026
…dit hot wallet transfers and RBF replacements only once their PSBT exists
RodriFS
force-pushed
the
outflow-monitor-audit-gaps
branch
from
November 12, 2026 14:59
bc7170f to
56ce535
Compare
Contributor
Author
|
sorry @Jossec101, i had to rebase because of merge conflicts |
RodriFS
enabled auto-merge (squash)
November 12, 2026 15:00
Jossec101
approved these changes
Nov 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Each request that sends funds must have an audit entry that shows who created it. Today, gRPC requests have no audit entries, and transfer audits point to the wallet, not to the request. This PR adds those audit entries, identifies the API token or the user and their roles, and keeps each entry consistent with the request state.
Changes
gRPC caller identity
HttpContext.Items. It never stores the token value.AuditServicereads it on each audit. The username becomesAPI token {id} ({name}), and the details getApiTokenIdandApiTokenName.gRPC request audits (
RequestWithdrawal,BumpWithdrawal,CancelWithdrawal,OpenChannel)RBF cancellations
AuditActionType.RbfCancelreplacesCancelfor RBF cancellations, in the API and in the UI.Cancelnow only means a cancelled request.Wallet transfers
SourceWalletId.User roles
UserRoles, so a later check can use the roles at the time of the action.null. Details that are not a JSON object go underDetails. Keys from the caller are never replaced.Tradeoffs and scope
Cancel, and old transfers stay on the wallet.UserRolescomes from the login claims. It can be out of date until the security stamp is validated again.Validation
dotnet buildpasses.dotnet test: 824 passed, 17 skipped, 0 failed.Review order
Helpers/AuthenticatedApiToken.csandGRPCAuthInterceptor: how the caller identity enters the request.AuditService: how each audit gets the token or the user roles, and the rules for the details.AuditLog.cs: the newRbfCancelaction.NodeGuardService: start withFailRequestAndAuditAsync. Then readRequestWithdrawal,ReplaceWithdrawalAsync, andOpenChannelfor the order of audit, scheduling, and failure.Withdrawals.razor,AuditTrail.razor, andTransferFundsModal.razor: the UI uses the same actions and object ids.