Skip to content

Commit aaea466

Browse files
replace p2pkh with more efficient p2wpkh
1 parent d29be2f commit aaea466

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

crates/bcr-ebill-api/src/external/bitcoin.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,18 +177,18 @@ impl BitcoinClientApi for BitcoinClient {
177177
}
178178

179179
fn get_address_to_pay(&self, bill_public_key: &str, holder_public_key: &str) -> Result<String> {
180-
let public_key_bill = bitcoin::PublicKey::from_str(bill_public_key)
180+
let public_key_bill = bitcoin::CompressedPublicKey::from_str(bill_public_key)
181181
.map_err(|e| Error::PublicKey(e.to_string()))?;
182-
let public_key_bill_holder = bitcoin::PublicKey::from_str(holder_public_key)
182+
let public_key_bill_holder = bitcoin::CompressedPublicKey::from_str(holder_public_key)
183183
.map_err(|e| Error::PublicKey(e.to_string()))?;
184184

185185
let public_key_bill = public_key_bill
186-
.inner
187-
.combine(&public_key_bill_holder.inner)
186+
.0
187+
.combine(&public_key_bill_holder.0)
188188
.map_err(Error::from)?;
189-
let pub_key_bill = bitcoin::PublicKey::new(public_key_bill);
189+
let pub_key_bill = bitcoin::CompressedPublicKey(public_key_bill);
190190

191-
Ok(bitcoin::Address::p2pkh(pub_key_bill, get_config().bitcoin_network()).to_string())
191+
Ok(bitcoin::Address::p2wpkh(&pub_key_bill, get_config().bitcoin_network()).to_string())
192192
}
193193

194194
fn generate_link_to_pay(&self, address: &str, sum: u64, message: &str) -> String {
@@ -217,7 +217,7 @@ impl BitcoinClientApi for BitcoinClient {
217217
desc_pubkey.clone(),
218218
desc_seckey,
219219
)));
220-
let desc = miniscript::Descriptor::new_pkh(desc_pubkey).unwrap();
220+
let desc = miniscript::Descriptor::new_wpkh(desc_pubkey).unwrap();
221221
Ok(desc.to_string_with_secret(&kmap))
222222
}
223223

0 commit comments

Comments
 (0)