3.10 Remove use of Network::Bitcoin

All uses were safe due to addresses being converted to script_pubkeys which
don't embed their network. The only risk of there being an issue is if a
future address spec did embed the net ID into the script_pubkey and that was
moved to.

This resolves the audit note and does offer that tightening.
This commit is contained in:
Luke Parker
2023-07-20 00:00:20 -04:00
parent 6f9d02fdf8
commit f66fe3c1cb
4 changed files with 28 additions and 22 deletions

View File

@@ -17,10 +17,11 @@ use bitcoin_serai::{
hashes::Hash as HashTrait,
consensus::{Encodable, Decodable},
script::Instruction,
address::{NetworkChecked, Address as BAddress},
OutPoint, Transaction, Block, Network,
},
wallet::{
tweak_keys, address, ReceivedOutput, Scanner, TransactionError,
tweak_keys, address_payload, ReceivedOutput, Scanner, TransactionError,
SignableTransaction as BSignableTransaction, TransactionMachine,
},
rpc::{RpcError, Rpc},
@@ -33,7 +34,7 @@ use bitcoin_serai::bitcoin::{
sighash::{EcdsaSighashType, SighashCache},
script::{PushBytesBuf, Builder},
absolute::LockTime,
Sequence, Script, Witness, TxIn, TxOut, Address as BAddress,
Sequence, Script, Witness, TxIn, TxOut,
};
use serai_client::{
@@ -326,7 +327,7 @@ impl Coin for Bitcoin {
}
fn address(key: ProjectivePoint) -> Address {
Address(address(Network::Bitcoin, key).unwrap())
Address(BAddress::<NetworkChecked>::new(Network::Bitcoin, address_payload(key).unwrap()))
}
fn branch_address(key: ProjectivePoint) -> Self::Address {