-
Notifications
You must be signed in to change notification settings - Fork 45
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
Make add_recipient()
take any ScriptPubKey
#192
Make add_recipient()
take any ScriptPubKey
#192
Conversation
a9e24dc
to
8d1fa01
Compare
The new error is coming from the ffi layer: error[E0308]: mismatched types
--> /Users/user/bdk-ffi/target/debug/build/bdk-ffi-e89d1caffbe2e3c9/out/bdk.uniffi.rs:1491:24
|
1491 | Ok(val) => val,
| ^^^ expected struct `Script`, found struct `std::string::String` I can see how it relates to the upgrade: the TxBuilder used to take a String for the address and now takes a script. But at the same time I think I've fixed all Rust code to migrate... not sure where this string is getting delivered from. |
089040f
to
79dbc17
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.
From a first look the approach seems reasonable to me. In fact I hand no issue building? I assume above comment regarding a build error has already been addressed?
Oh shoot! Yes Steve and I fixed the problems mentioned above and I forgot to say it here to avoid confusion. Sorry man! |
9278f14
to
7ac7a83
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.
Generally LGTM, just a few nits.
src/lib.rs
Outdated
@@ -32,13 +35,15 @@ use std::fmt; | |||
use std::ops::Deref; | |||
use std::str::FromStr; | |||
use std::sync::{Arc, Mutex, MutexGuard}; | |||
// use bitcoin::hashes::serde::Serialize; |
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.
nit: Can be removed.
// use bitcoin::hashes::serde::Serialize; |
@tnull I agree that the Here are what the methods look like in the TxBuilder: fn add_recipient(&self, script: Arc<Script>, amount: u64) -> Arc<Self> {
let mut recipients: Vec<(BdkScript, u64)> = self.recipients.clone();
recipients.append(&mut vec![(script.0.clone(), amount)]);
Arc::new(TxBuilder {
recipients,
..self.clone()
})
}
fn set_recipients(&self, recipients: Vec<ScriptAmount>) -> Arc<Self> {
let recipients = recipients
.iter()
.map(|script_amount| (script_amount.script.0.clone(), script_amount.amount))
.collect();
Arc::new(TxBuilder {
recipients,
..self.clone()
})
} |
If ready to review/merge you should remove the part of the description about it totally not working. Also update changelog with: New features:
|
Done and done. @notmandatory do you have an opinion as to whether to use the tuple struct or the normal struct? I'm ok with both, but we should be consistent if we use the tuple struct and also apply it elsewhere we have a wrapper with only one field. I wonder if it makes the code less explicit just because you end up using numbers instead the wrapper/field, but it's not a big deal either way. |
Right, I personally prefer the shorter for of the definition and |
As per a discussion in the dev call we'll be merging this PR without using the Tuple Structs and leave the migration to the Tuple Structs to a separate PR (since there are a few different places where these refactorings should be applied). |
7ac7a83
to
7aafc64
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.
ACK 7aafc64
But prior to merging please remove the dbg!
.
7aafc64
to
5a5946e
Compare
5a5946e
to
3fefd3c
Compare
Fixes #159.
Changelog notice
To do: