Repository navigation
Conversation
Upgrade to something resembling the upcoming `rust-bitcoin` 0.30.0 release. FTR this upgrade was pretty painful, some pain points were: - I found PushBytes hard to work with. - API methods missing or hard to use (or I'm being braindead), specifically: - `PushBytes::to_vec()` - `script::Builder::push_script()` (to handle `PushBytes`) - New paths/re-exports don't match with current usage i.e., here in miniscript we tend to include `bitcoin::` on types, this upgrade removed a few types from the crate root so now we have long fully qualified paths instead e.g., `bitcoin::crypto::ecdsa::Signature` instead of `bitcoin::EcdsaSig`. - The "don't implement `Ord` thing" from `absolute::LockTime` means we need some way to order absolute lock times, here we use a wrapper type.
|
FYI the |
|
Aren't terminal fragments based on "Miniscript fragments" from https://bitcoin.sipa.be/miniscript/? |
Ok I finally worked out how to use impl AsRef<PushBytes> for SerializedSignature {
#[inline]
fn as_ref(&self) -> &PushBytes {
&<&PushBytes>::from(&self.data)[..self.len()]
}
}This implies that one can do /// Pushes a DER-encoded ECDSA signature with a signature hash type as a new element on the
/// witness, requires an allocation.
pub fn push_bitcoin_signature(&mut self, signature: &ecdsa::SerializedSignature, hash_type: EcdsaSighashType) {
// Note that a maximal length ECDSA signature is 72 bytes, plus the sighash type makes 73
let mut sig = [0; 73];
sig[..signature.len()].copy_from_slice(signature);
sig[signature.len()] = hash_type as u8;
self.push(&sig[..signature.len() + 1]);
}Implying that we need to manually include the sighash type. cc @Kixunil |
|
And am I still being brain dead or is this how we are expecting downstream to use let redeem_script = wpkh.script_pubkey();
script::Builder::new()
.push_slice(&<&PushBytes>::try_from(redeem_script.as_bytes()).expect("script is within limit"))
.into_script() |
|
Good idea, I should try to upgrade my projects to see if anything breaks.
I was also thinking we should disallow pushing legacy signatures into |
Yes, and height-based and time-based |
|
Am I understanding you correctly, are you saying |
|
@tcharding no, I'm saying that |
Yeah I want to do bdk and/or electrs as well to see if we break them.
Wow, I did not realise yesterday that
I'll fix it up. EDIT: I retract that statement, its an API change and a minor can of worms because of the "restrict to non-legacy sigs" thing. Leaving till after release.
Cool, something to keep in mind when we add script tagging eh, feels like script tagging is going to be quite involved. |
Ooooh, thanks. I'll have a play when I get a second. |
|
Using your changes from this branch to a make a release PR here |
|
Unneeded now, closing. |
This is not a merge candidate
To get a feel for using the code we are about to release I hacked up an upgrade to something resembling the upcoming
rust-bitcoin0.30.0 release.FTR I found this upgrade painful, some pain points were:
API methods missing or hard to use (or I'm being braindead), specifically:
PushBytes::to_vec()script::Builder::push_script()(to handlePushBytes)New paths/re-exports don't match with current usage i.e., here in miniscript we tend to include
bitcoin::on types, this upgrade removed a few types from the crate root so now we have long fully qualified paths instead e.g.,bitcoin::crypto::ecdsa::Signatureinstead ofbitcoin::EcdsaSig.The "don't implement
Ordthing" fromabsolute::LockTimemeans we need some way to order absolute lock times, here we use a wrapper type.