-
Notifications
You must be signed in to change notification settings - Fork 338
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
Check foreign utxos are not local before inclusion #1823
base: master
Are you sure you want to change the base?
Check foreign utxos are not local before inclusion #1823
Conversation
As part of BDK review club for #1798 we talked about #1819 and its fix candidate #1823 :
|
Next steps based on review club:
|
6811398
to
995df71
Compare
The new check is added to ensure all added foreign utxos are not owned by the wallet.
995df71
to
54a9667
Compare
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.
I have no strong opinion about whether we should make this breaking/not-breaking.
Generally, I think it's easier for maintainers if we are allowed to break everything and tell everyone to upgrade. For BDK, I think as long as we make the persistence crates backwards-compatible we are good.
54a9667
to
72acc19
Compare
None => { | ||
return Err(AddForeignUtxoError::MissingUtxo); | ||
} | ||
let script_pubkey = if let Some(ref txout) = psbt_input.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.
Style nit, but I'm inclined to write this as a match statement with the primary goal of locating the txout.
let txout = match (&psbt_input.witness_utxo, &psbt_input.non_witness_utxo) { ... };
builder.add_foreign_utxo(outpoint, psbt::Input::default(), foreign_utxo_satisfaction); | ||
// TODO(2.0.0): assert!(matches!(result, Err(AddForeignUtxoError::NotForeignUtxo))); | ||
assert!(builder.params.utxos.is_empty()); |
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.
I think you still need to provide the witness utxo if you want this to reach the is_mine
check.
I agree it's better to implement the appropriate fix than one that is potentially sub-optimal, so in that case I'd be in favor of adding the |
Description
Considering all foreign utxos must not be owned by wallet
The new check is added to ensure this invariant holds.
Before this change, foreign utxos could belong to the wallet, breaking the expected invariant, as exposed by this test at cc15e5d:
Fixes #1819
Changelog notice
No API changes.
Checklists
cargo fmt
andcargo clippy
before committing