Fix/chain position ffi serialization#959
Closed
kumulynja wants to merge 6 commits intobitcoindevkit:masterfrom
Closed
Fix/chain position ffi serialization#959kumulynja wants to merge 6 commits intobitcoindevkit:masterfrom
kumulynja wants to merge 6 commits intobitcoindevkit:masterfrom
Conversation
Fixed FFI serialization bug where ChainPosition was writing garbage bytes (0x00da7f10) instead of valid enum discriminants (1 or 2). The issue was in the From<BdkCanonicalTx> implementation which called .into() on a borrowed ChainPosition<&BdkConfirmationBlockTime>. This caused a lifetime mismatch with the From trait expecting an owned value, resulting in undefined behavior during FFI serialization. Now explicitly pattern match on the borrowed chain_position and construct the ChainPosition enum correctly, fixing the "invalid enum index" error when calling Wallet.transactions(). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
7a51454 to
4f777ca
Compare
Contributor
Author
|
I added test cases to |
Contributor
Author
|
I made some wrong conclusions, BdkConfirmationBlockTime is not borrowed, and the problem I encountered seems to be solved by the following: bitcoindevkit/bdk-dart#47. So closing the issue. |
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.
Description
While using
bdk-dartI encountered the following error after having broadcasted a transaction and wanting to list the transactions which resulted in app crashes:ChainPosition was writing garbage bytes (0x00da7f10 in this specific case) instead of valid enum discriminants (1 or 2).
Tracked it down with Claude Code to the following cause in
bdk-ffi:Solution implemented in this PR:
Tested successfully with
bdk-dartand the crashing wallet.Notes to the reviewers
Checklists
All Submissions:
cargo fmtandcargo clippybefore committingBugfixes: