Skip to content

WIP: Imp send handler#79

Draft
gandlafbtc wants to merge 3 commits intocashubtc:masterfrom
gandlafbtc:imp-send-handler
Draft

WIP: Imp send handler#79
gandlafbtc wants to merge 3 commits intocashubtc:masterfrom
gandlafbtc:imp-send-handler

Conversation

@gandlafbtc
Copy link

@gandlafbtc gandlafbtc commented Jan 30, 2026

@changeset-bot
Copy link

changeset-bot bot commented Jan 30, 2026

⚠️ No Changeset found

Latest commit: aa70784

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@Egge21M
Copy link
Collaborator

Egge21M commented Feb 3, 2026

Is this ready for review or are there any blockers that I can help with?

@gandlafbtc
Copy link
Author

I haven't had the time yet to verify if I didn't produce any slop. But maybe you can give it a quick look if the direction is what you were looking for, and afterwards I will give it a de-slopping.

@Egge21M
Copy link
Collaborator

Egge21M commented Feb 11, 2026

@codex please trigger a manual review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: aa707840f1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

op.method = 'default';
}
if (!op.methodData) {
op.methodData = {};

Choose a reason for hiding this comment

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

P1 Badge Write methodDataJson in IndexedDB migration

The v10 IndexedDB upgrade populates op.methodData, but the repository now reads row.methodDataJson and immediately JSON.parses it when hydrating send operations. For databases upgraded from older versions, legacy rows keep methodDataJson unset, so reading those operations can throw at runtime (JSON.parse(undefined)), which can break startup recovery and any send-operation queries until rows are rewritten.

Useful? React with 👍 / 👎.

// Use P2PK type for send outputs, custom for keep outputs
// Note: P2PK type doesn't accept custom data - the wallet generates P2PK-locked outputs
const outputConfig: OutputConfig = {
send: { type: 'p2pk', options: { pubkey } },

Choose a reason for hiding this comment

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

P1 Badge Persist actual P2PK send secrets for state tracking

This execute path tells the wallet to generate P2PK send outputs instead of using the serialized outputData.send prepared earlier, but pending/finalization logic still derives send secrets from that stored output data. In P2PK sends, those secrets diverge from the actual minted proofs, so pending checks and rollback/recovery can target non-existent proofs and leave claimed operations stuck in pending.

Useful? React with 👍 / 👎.

Copy link
Collaborator

@Egge21M Egge21M left a comment

Choose a reason for hiding this comment

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

Awesome! Thank you for taking this on. I love the direction and generally this is already really good! I noticed a few things here and there, please take a look at those. And I can do another full review once the PR is ready-for-review

🥜

}

// Try exact match first (no swap needed)
const exactProofs = wallet.selectProofsToSend(availableProofs, amount, false);
Copy link
Collaborator

Choose a reason for hiding this comment

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

ProofService exposes a method for coin selection called: ProofService.selectProofsToSend

(p: CoreProof) => sendSecrets.includes(p.secret) && p.state === 'inflight',
);

if (sendProofs.length > 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Pre exisiting bug / edge case: A pending operation indicates that the proofs were sent, but not claimed yet. If the watcher did not update us correctly, this might be a false assumption (e.g. proofs are already claimed by the receiver, but we don't know it yet).

We should probably include a spent-check here

private readonly mintService: MintService;
private readonly walletService: WalletService;
private readonly eventBus: EventBus<CoreEvents>;
private readonly handlerProvider?: SendHandlerProvider;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why make it optional?

@Egge21M Egge21M linked an issue Feb 12, 2026 that may be closed by this pull request
@Egge21M
Copy link
Collaborator

Egge21M commented Feb 19, 2026

@gandlafbtc are you still working on this?

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

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

Improvement: Refactor SendOperationService to use a Handler

2 participants

Comments