-
Notifications
You must be signed in to change notification settings - Fork 389
test,refactor(wallet): Move bump fee + foreign utxo tests #1907
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
test,refactor(wallet): Move bump fee + foreign utxo tests #1907
Conversation
These files added to wallet/tests directory - add_foreign_utxo.rs - build_fee_bump.rs
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.
Good job working on this PR @ValuedMammal
let mut psbt = builder.finish().unwrap(); | ||
wallet1.insert_txout(utxo.outpoint, utxo.txout); | ||
let fee = check_fee!(wallet1, psbt); | ||
let sent_received = |
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 suppose it will be easier to read if this tuple is named (sent_amount, received_amount)
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 agree
.only_witness_utxo() | ||
.add_foreign_utxo(utxo.outpoint, psbt_input, foreign_utxo_satisfaction) | ||
.unwrap(); | ||
let mut psbt = builder.finish().unwrap(); |
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 am curious about how the change output
was handled. I can't see a test case or the method responsible for that.
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 no change address is given, then the wallet looks for the next unused address from the change keychain
bdk/crates/wallet/src/wallet/mod.rs
Lines 1434 to 1438 in 5817ed0
// get drain script | |
let mut drain_index = Option::<(KeychainKind, u32)>::None; | |
let drain_script = match params.drain_to { | |
Some(ref drain_recipient) => drain_recipient.clone(), | |
None => { |
And the result of coin selection determines whether the change output is finally added.
bdk/crates/wallet/src/wallet/mod.rs
Lines 1511 to 1517 in 5817ed0
// if there's change, create and add a change output | |
if let Excess::Change { amount, .. } = excess { | |
// create drain output | |
let drain_output = TxOut { | |
value: *amount, | |
script_pubkey: drain_script, | |
}; |
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 working on this. I have learned a lot from this PR.
tACK 9ca1529
nit: I have left some comments. Thanks
@tvpeter thanks for reviewing. I agree with your suggestions, but since this is a refactor/ code move, it would be better in my opinion to not introduce logical changes and instead push those to a follow up PR. |
Reopened bitcoindevkit/bdk_wallet#199 |
These files are added to wallet/tests directory
fixes bitcoindevkit/bdk_wallet#21
Changelog notice
Checklists
All Submissions:
cargo fmt
andcargo clippy
before committing