Skip to content

Consolidate/wcn 887#246

Merged
pranishnepal merged 1 commit into
masterfrom
consolidate/WCN-887
Jun 18, 2026
Merged

Consolidate/wcn 887#246
pranishnepal merged 1 commit into
masterfrom
consolidate/WCN-887

Conversation

@pranishnepal

Copy link
Copy Markdown
Contributor

What

Implements asynchronous consolidate unspent, which will be used when integrated with the Bridge Service

Testing

  • Unit & Integ Tests

@linear-code

linear-code Bot commented Jun 17, 2026

Copy link
Copy Markdown

WCN-887

@pranishnepal

Copy link
Copy Markdown
Contributor Author

will rebase with #245 once that's merged

@pranishnepal pranishnepal marked this pull request as ready for review June 17, 2026 18:28
@pranishnepal pranishnepal requested review from a team as code owners June 17, 2026 18:28
@pranishnepal pranishnepal marked this pull request as draft June 17, 2026 18:40
@pranishnepal pranishnepal force-pushed the consolidate/WCN-887 branch 3 times, most recently from 9889a13 to 82d8f6c Compare June 17, 2026 20:11
it('picks up an awaiting_bitgo accelerate job, submits cpfp params to WP, and PATCHes complete', async () => {
assert(services.bridge, 'bridge service should be defined');
services.bridge.setPendingJobs([makeAwaitingBitgoAccelerateJob()]);
services.bridge.setPendingJobs([makeAwaitingBitgoMultisigSignJob('accelerate')]);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

unified these small composer functions to a single func

@pranishnepal

Copy link
Copy Markdown
Contributor Author

To reviewer(s): what this PR does is similar to what was done in #245

@pranishnepal pranishnepal marked this pull request as ready for review June 17, 2026 20:20
walletId: params.walletId,
wpSubmitKind: 'consolidateUnspents',
wpSubmitParams: params.consolidationParams,
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

consolidationParams includes reqId: requestTracer (a RequestTracer object) which serializes as {} in the bridge job body. Worth stripping it before storing in wpSubmitParams.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I see, guessing bridge has it's own tracker? Removed here and from handleAccelerate as well, and updates tests!

function normalizeSingleConsolidateResponse<T>(response: T | T[]): T {
if (Array.isArray(response)) {
if (response.length !== 1) {
throw new BadRequestError(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the original sync path silently returned [] for zero consolidations; this now throws a 400. intentional behavior change for the sync path too?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, looked like a bug to me so i switched after looking at the SDK response and this API's docs, which also don't support []. My thought process was: if i'm intending to consolidate and received an empty list, i wouldn't know what to do with that. What do you think?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmmm. In that case maybe you can tune the error message that something went wrong.
Expected single consolidation result, but received ${response.length} results this will not tell the users much. And in which case can the results be even > 1 ?.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure, updated the error messaging for the case i edited (empty list), for >1, messaging stays the same

@pranavjain97

Copy link
Copy Markdown
Contributor

lgtm otherwise

This commit refactors the consolidate unspents flow to be asynchronous,
similar to the existing sendMany and accelerate flows.

The main changes include:
- Adding a new WpSubmitKind 'consolidateUnspents' and its handler
- Updating the asyncJobWorker to handle the new kind
- Refactoring the handleConsolidateUnspents handler to build and send tx

Ticket: WCN-887
@pranishnepal pranishnepal force-pushed the consolidate/WCN-887 branch from 54cd7f2 to 08cce81 Compare June 18, 2026 17:50
@pranishnepal pranishnepal merged commit f763f1d into master Jun 18, 2026
22 checks passed
@pranishnepal pranishnepal deleted the consolidate/WCN-887 branch June 18, 2026 18:02
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