Skip to content

Dash2 - #993

Open
shocknet-justin wants to merge 29 commits into
masterfrom
dash2
Open

Dash2#993
shocknet-justin wants to merge 29 commits into
masterfrom
dash2

Conversation

@shocknet-justin

@shocknet-justin shocknet-justin commented Jul 13, 2026

Copy link
Copy Markdown
Member

Note

Medium Risk
New admin-only APIs expose balances and full user operation history; assets/liabilities logic was refactored with pagination and batch lookups, which affects financial reconciliation views.

Overview
Adds admin dashboard capabilities: paginated user directory (GetUsersAdminInfo) with balance, lock state, linked app users, and app ownership, plus admin-scoped user operations (GetUserOperationsFromAdmin) that require user_id and can read history for banned users while enforcing page-size caps.

Introduces GetAssetsAndLiabilitiesV2 with per-LND and per-liquidity-provider filters and cursor/index pagination (has_more, next_cursor / next_index_offset) instead of dumping full operation lists. The original admin assets/liabilities call is kept by adapting V1 requests to V2 and flattening paged results back to arrays. LND listing now passes offset/limit into invoices, payments, and transactions; liquidity provider ops use explicit incoming/outgoing cursors.

Tracked asset operations can include optional user_id when mapped to a user payment/invoice/chain op. Nostr transport returns an error for unknown rpcName instead of only logging. Storage gains FindAndCount and batch In() lookups to avoid N+1 queries when building asset pages.

Reviewed by Cursor Bugbot for commit 86e8785. Bugbot is set up for automated code reviews on this repo. Configure here.

Comment thread src/services/main/adminManager.ts
Comment thread src/services/main/adminManager.ts
.map(p => ({
pubkey: p.provider_pubkey,
limit_payments: limitPayments,
limit_invoices: limitInvoices,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

V1 default payment limit shrunk

Medium Severity

BuildV2ReqFromV1 defaults limit_payments to DEFAULT_LND_PAGE_SIZE (20), but the removed V1 handler used 50 when the field was omitted. Legacy GetAssetsAndLiabilities({}) calls now return fewer LND payment rows with no API version change.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 8a19cc8. Configure here.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is fine, with pagination the user can just load more data now

Comment thread src/services/main/adminManager.ts
Comment thread src/services/main/adminManager.ts Outdated
balance: user.balance_sats,
locked: user.locked,
app_users: appUsersByUserId.get(user.user_id) ?? [],
owner_of_app_id: apps[user.user_id]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple apps overwrite owner id

Low Severity

GetUsersAdminInfo builds owner_of_app_id with applications.forEach(a => apps[a.owner.user_id] = a.app_id), so a user who owns more than one application only keeps the last app id in the map, and others get the wrong or missing owner link in admin user info.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 047e309. Configure here.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not an issue, since all application owners are unique, the same user cannot own two apps

@shocknet-justin

Copy link
Copy Markdown
Member Author

@BugBot review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

There are 4 total unresolved issues (including 2 from previous reviews).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 86e8785. Configure here.

const [payments, invoices, txPages, balance] = await Promise.all([
this.FetchLndPaymentPage(paymentsLimit, paymentsOffset),
this.FetchLndInvoicePage(invoicesLimit, invoicesOffset),
this.FetchLndTransactionPages(info.blockHeight, txLimit, txOffset),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tx pagination unstable block height

Medium Severity

LND transaction pages for admin assets use the current chain tip as startHeight on every request while the client only persists tx_index_offset. When the tip advances between “load more” calls, the underlying getTransactions window shifts, so the same offset can skip or repeat on-chain activity in incoming_tx / outgoing_tx.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 86e8785. Configure here.

new Promise<false>(res => setTimeout(() => res(false), 10 * 1000))
])
if (res === false) {
throw new Error("timeout getting operations")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LP timeout breaks assets

Medium Severity

A new 10s Promise.race around liquidity-provider GetUserOperations throws on timeout. That error propagates through GetProviderAssetsAndLiabilities and aborts all of GetAssetsAndLiabilitiesV2 (including the V1 shim), so slow or hung LP calls can block LND balances and user totals that do not depend on the LP.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 86e8785. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants