-
Notifications
You must be signed in to change notification settings - Fork 65
feat: expose only_witness_utxo and add_foreign_utxo on TxBuilder #928
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat: expose only_witness_utxo and add_foreign_utxo on TxBuilder #928
Conversation
reez
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding, this is looking like the right shape to me, I left a couple comments to address, otherwise this is looking good
| psbt_input: Input, | ||
| satisfaction_weight: u64, | ||
| ) -> Result<Arc<Self>, AddForeignUtxoError> { | ||
| let bdk_outpoint: BdkOutPoint = outpoint.into(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we guard here if psbt_input lacks both witness_utxo and non_witness_utxo
if psbt_input.witness_utxo.is_none() && psbt_input.non_witness_utxo.is_none() {
return Err(AddForeignUtxoError::MissingUtxo);
}
would match upstream behavior at the method boundary instead of deferring failure to finish()
"This method returns errors… The psbt_input does not contain a witness_utxo or non_witness_utxo."
| }) | ||
| } | ||
|
|
||
| /// Add a foreign UTXO i.e. a UTXO not owned by this wallet. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docs here don’t look identical to upstream add_foreign_utxo any reason for that?
| }) | ||
| } | ||
|
|
||
| /// Only fill witness_utxo. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docs here don’t look identical to upstream only_witness_utxo any reason for that?
| } | ||
|
|
||
| #[test] | ||
| fn test_add_foreign_utxo_missing_witness_data() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we add the guard in add_foreign_utxo (per my code comment in tx_builder.rs) we should update the test for that too
Description
This PR adds the
only_witness_utxoandadd_foreign_utxoonTxBuildersince they are available inbdk, but missing inbdk-ffi. They are useful for bdk bindings to be used together with for example bark (Ark implementation from Second Tech) so a unilateral exit can be done with Cpfp transactions.Notes to the reviewers
Since the
add_foreign_utxofunction is still experimental, I added the same comments mentioning this and the caution that has to be taken. I think it is good to expose it already though for experimentation like with bark as mentioned before.Both functions seem to be working in an example in Dart to unilaterally exit from bark through a fork of both bdk-ffi and bdk-dart.
Documentation
bdk-ffiChecklists
All Submissions:
cargo fmtandcargo clippybefore committingNew Features: