mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-09 04:39:24 +00:00
Use ScriptBuf over Address where possible
This commit is contained in:
@@ -454,19 +454,17 @@ async fn mint_and_burn_test() {
|
||||
|
||||
// Create a random Bitcoin/Monero address
|
||||
let bitcoin_addr = {
|
||||
use bitcoin_serai::bitcoin::{network::Network, key::PublicKey, address::Address};
|
||||
// Uses Network::Bitcoin since it doesn't actually matter, Serai strips it out
|
||||
// TODO: Move Serai to ScriptBuf from Address
|
||||
Address::p2pkh(
|
||||
loop {
|
||||
use bitcoin_serai::bitcoin::{key::PublicKey, ScriptBuf};
|
||||
ScriptBuf::new_p2pkh(
|
||||
&(loop {
|
||||
let mut bytes = [0; 33];
|
||||
OsRng.fill_bytes(&mut bytes);
|
||||
bytes[0] %= 4;
|
||||
if let Ok(key) = PublicKey::from_slice(&bytes) {
|
||||
break key;
|
||||
}
|
||||
},
|
||||
Network::Bitcoin,
|
||||
})
|
||||
.pubkey_hash(),
|
||||
)
|
||||
};
|
||||
|
||||
@@ -559,7 +557,7 @@ async fn mint_and_burn_test() {
|
||||
let received_output = block.txdata[1]
|
||||
.output
|
||||
.iter()
|
||||
.find(|output| output.script_pubkey == bitcoin_addr.script_pubkey())
|
||||
.find(|output| output.script_pubkey == bitcoin_addr)
|
||||
.unwrap();
|
||||
|
||||
let tx_fee = 1_100_000_00 -
|
||||
|
||||
@@ -261,7 +261,6 @@ impl Wallet {
|
||||
OutPoint, Sequence, Witness, TxIn, Amount, TxOut,
|
||||
absolute::LockTime,
|
||||
transaction::{Version, Transaction},
|
||||
Network, Address,
|
||||
};
|
||||
|
||||
const AMOUNT: u64 = 100000000;
|
||||
@@ -281,13 +280,11 @@ impl Wallet {
|
||||
},
|
||||
TxOut {
|
||||
value: Amount::from_sat(AMOUNT),
|
||||
script_pubkey: Address::p2tr_tweaked(
|
||||
script_pubkey: ScriptBuf::new_p2tr_tweaked(
|
||||
TweakedPublicKey::dangerous_assume_tweaked(
|
||||
XOnlyPublicKey::from_slice(&to[1 ..]).unwrap(),
|
||||
),
|
||||
Network::Bitcoin,
|
||||
)
|
||||
.script_pubkey(),
|
||||
),
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -521,13 +518,8 @@ impl Wallet {
|
||||
|
||||
match self {
|
||||
Wallet::Bitcoin { public_key, .. } => {
|
||||
use bitcoin_serai::bitcoin::{Network, Address};
|
||||
ExternalAddress::new(
|
||||
networks::bitcoin::Address::new(Address::p2pkh(public_key, Network::Regtest))
|
||||
.unwrap()
|
||||
.into(),
|
||||
)
|
||||
.unwrap()
|
||||
use bitcoin_serai::bitcoin::ScriptBuf;
|
||||
ExternalAddress::new(ScriptBuf::new_p2pkh(&public_key.pubkey_hash()).into()).unwrap()
|
||||
}
|
||||
Wallet::Ethereum { key, .. } => ExternalAddress::new(
|
||||
ethereum_serai::crypto::address(&(ciphersuite::Secp256k1::generator() * key)).into(),
|
||||
|
||||
Reference in New Issue
Block a user