bdk-ffi
bdk-ffi copied to clipboard
feat: Expose psbt output
Description
Expose output for psbt.
Useful API docs:
Notes to the reviewers
TapLeafwhich is an enum with variant in rust-bitcoin, has been flattened inLeafNodein our bitcoin.rs file. Seems UniFFI enums with complex types like Arc<Script> don't work well for FFI. An error thrown in Kotlin whereorg.bitcoindevkit.TapLeaf.Scriptis conflicting withorg.bitcoindevkit.Script.
So instead of having
pub enum TapLeaf {
Script(ScriptBuf, LeafVersion),
Hidden(TapNodeHash),
}
pub struct LeafNode {
/// The [`TapLeaf`]
leaf: TapLeaf,
/// The merkle proof (hashing partners) to get this node.
merkle_branch: TaprootMerkleBranch,
}
We use:
#[derive(Clone, Debug, uniffi::Enum)]
pub enum TapLeaf {
/// A known script
Script,
/// Hidden node
Hidden,
}
#[derive(Clone, Debug, uniffi::Record)]
pub struct LeafNode {
/// The leaf type (script or hidden)
pub leaf_type: TapLeaf,
/// The script if this is a Script leaf (None if Hidden)
pub script: Option<Arc<Script>>,
/// The version if this is a Script leaf (None if Hidden)
pub version: Option<u8>,
/// The hash if this is a Hidden leaf (None if Script)
pub hash: Option<String>,
/// The merkle proof (hashing partners) to get this node.
pub merkle_branch: Vec<String>,
}
- Also
has_hidden_nodesis not exposed directly in rust-bitcoin. Hence I derived that while I iterated through the leave nodes intap_treemapping.
Documentation
- [ ]
bdk_wallet - [x]
bitcoin - [ ]
uniffi - [ ] Other:
Checklists
All Submissions:
- [x] I've signed all my commits
- [x] I followed the contribution guidelines
- [x] I ran
cargo fmtandcargo clippybefore committing - [ ] I've added a changelog in the next release tracking issue (see example)
- [ ] I've linked the relevant upstream docs or specs above
New Features:
- [ ] I've added tests for the new feature
- [x] I've added docs for the new feature
Looking good bc2bdb01f0fed34979de9085aa44b69cc147ab5d