Skip to content

Batch scrape_wallet transactions to handle large wallets#7721

Draft
Copilot wants to merge 3 commits intodevelopmentfrom
copilot/fix-scraping-large-wallets
Draft

Batch scrape_wallet transactions to handle large wallets#7721
Copilot wants to merge 3 commits intodevelopmentfrom
copilot/fix-scraping-large-wallets

Conversation

Copy link
Contributor

Copilot AI commented Mar 16, 2026

scrape_wallet constructed a single transaction from all unspent outputs, which fails when a wallet has more inputs than the protocol limit (TRANSACTION_INPUTS_LIMIT = 4000).

Changes

Output Manager Service

  • scrape_wallet no longer takes a tx_id parameter — IDs are now generated internally per batch
  • Outputs are split into batches of TRANSACTION_INPUTS_LIMIT using .chunks(), each batch producing its own TransactionBuilder and encumberance
  • Returns Vec<(TxId, TransactionBuilder)> instead of a single builder
  • New TransactionBuildersToSend response variant added to OutputManagerResponse

Transaction Service

  • Private scrape_wallet loops over batches, generating fresh crypto keys (sender offset, shared secret, spending key) per transaction
  • Returns Vec<TxId>; request handler uses the existing TransactionsSent response variant

Callers

  • Console wallet automation: passes all returned TxIds to monitor_transactions
  • FFI (scrape_wallet): returns the first TxId for backward compatibility; docs updated to note that large wallets may produce multiple transactions and that 0 without an error indicates an empty wallet
// Before: one builder with all outputs (fails if >4000 UTXOs)
pub fn scrape_wallet(&mut self, tx_id: TxId, fee_per_gram: MicroMinotari)
    -> Result<TransactionBuilder<...>, OutputManagerError>

// After: one builder per batch of TRANSACTION_INPUTS_LIMIT outputs
pub fn scrape_wallet(&mut self, fee_per_gram: MicroMinotari)
    -> Result<Vec<(TxId, TransactionBuilder<...>)>, OutputManagerError>
Original prompt

This section details on the original issue you should resolve

<issue_title>Scrape wallets for large wallets will fail</issue_title>
<issue_description>Currently, a single transaction is constructed to scrape the contents of an entire wallet. This will fail for large wallets as there are a limit to the amount of inputs that can go into a single transaction.</issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI and others added 2 commits March 16, 2026 10:09
When a wallet has many UTXOs, a single transaction cannot hold all of
them as inputs (limit is TRANSACTION_INPUTS_LIMIT = 4000). This change
fixes scrape_wallet to batch the outputs into groups of
TRANSACTION_INPUTS_LIMIT and create one transaction per batch.

Changes:
- output_manager_service/service.rs: scrape_wallet now batches outputs
  by TRANSACTION_INPUTS_LIMIT, generating a TxId per batch, and returns
  Vec<(TxId, TransactionBuilder)>
- output_manager_service/handle.rs: removed tx_id from ScrapeWallet
  request, added TransactionBuildersToSend response variant, updated
  handle method to return Vec<(TxId, TransactionBuilder)>
- transaction_service/service.rs: scrape_wallet loops through batches
  creating a transaction per batch, returns Vec<TxId>
- transaction_service/handle.rs: scrape_wallet returns Vec<TxId>,
  uses TransactionsSent response variant
- automation/commands.rs: updated to monitor all TxIds from scrape_wallet
- wallet_ffi/lib.rs: returns first TxId for backward compatibility,
  updated doc to note multiple transactions may be created

Co-authored-by: SWvheerden <2579813+SWvheerden@users.noreply.github.com>
Co-authored-by: SWvheerden <2579813+SWvheerden@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix scraping for large wallets to handle multiple transactions Batch scrape_wallet transactions to handle large wallets Mar 16, 2026
Copilot AI requested a review from SWvheerden March 16, 2026 10:13
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.

Scrape wallets for large wallets will fail

2 participants