Skip to content

Conversation

@PastaPastaPasta
Copy link
Member

This commit adds production-ready transaction building functionality to the key-wallet-ffi layer, enabling C/Swift clients to create and sign transactions.

New FFI Functions:

  1. wallet_build_and_sign_transaction() - Comprehensive transaction builder that:

    • Selects UTXOs using Branch and Bound coin selection algorithm
    • Calculates fees based on fee_per_kb rate
    • Generates change addresses from internal address pool
    • Derives private keys from root extended key for signing
    • Returns fully signed, serialized transaction bytes
  2. transaction_get_txid_from_bytes() - Utility function that:

    • Deserializes raw transaction bytes
    • Returns hex-encoded TXID as C string

Implementation Details:

  • Integrates with ManagedWalletInfo for UTXO tracking and address management
  • Uses TransactionBuilder pattern with proper fee calculation
  • Maps addresses to derivation paths for key derivation
  • Comprehensive error handling with FFIError propagation
  • Proper memory management following FFI safety patterns
  • Updated wallet_build_transaction() to direct users to new combined function

🤖 Generated with Claude Code

This commit adds production-ready transaction building functionality to the
key-wallet-ffi layer, enabling C/Swift clients to create and sign transactions.

New FFI Functions:
1. wallet_build_and_sign_transaction() - Comprehensive transaction builder that:
   - Selects UTXOs using Branch and Bound coin selection algorithm
   - Calculates fees based on fee_per_kb rate
   - Generates change addresses from internal address pool
   - Derives private keys from root extended key for signing
   - Returns fully signed, serialized transaction bytes

2. transaction_get_txid_from_bytes() - Utility function that:
   - Deserializes raw transaction bytes
   - Returns hex-encoded TXID as C string

Implementation Details:
- Integrates with ManagedWalletInfo for UTXO tracking and address management
- Uses TransactionBuilder pattern with proper fee calculation
- Maps addresses to derivation paths for key derivation
- Comprehensive error handling with FFIError propagation
- Proper memory management following FFI safety patterns
- Updated wallet_build_transaction() to direct users to new combined function

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 6, 2025

Warning

Rate limit exceeded

@PastaPastaPasta has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 5 minutes and 29 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 35e47fd and 65b66e8.

📒 Files selected for processing (3)
  • key-wallet-ffi/FFI_API.md (7 hunks)
  • key-wallet-ffi/include/key_wallet_ffi.h (3 hunks)
  • key-wallet-ffi/src/transaction.rs (6 hunks)
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/wallet-ffi-transaction-builder

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

github-actions bot commented Nov 6, 2025

⚠️ FFI Documentation Update Required

The FFI API documentation is out of date. Please regenerate it by running:

For key-wallet-ffi:

cd key-wallet-ffi
make update-docs

For dash-spv-ffi:

cd dash-spv-ffi
make update-docs

Then commit the changes:

git add */FFI_API.md
git commit -m "docs: update FFI API documentation"

This ensures the documentation stays in sync with the actual FFI functions.

…action

This commit simplifies the memory allocation process for the transaction bytes in the wallet_build_and_sign_transaction function by removing an unnecessary match statement. The updated code directly allocates and converts the boxed slice into a raw pointer, improving readability and maintainability.
@PastaPastaPasta
Copy link
Member Author

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 6, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@PastaPastaPasta PastaPastaPasta merged commit 618213d into v0.41-dev Nov 6, 2025
32 checks passed
@PastaPastaPasta PastaPastaPasta deleted the feat/wallet-ffi-transaction-builder branch November 6, 2025 21:39
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