@@ -40,7 +40,7 @@ const UTXO_SCRIPT_PUBKEY: &str =
4040 "5120be27fa8b1f5278faf82cab8da23e8761f8f9bd5d5ebebbb37e0e12a70d92dd16" ;
4141const UTXO_PUBKEY : & str = "a6ac32163539c16b6b5dbbca01b725b8e8acaa5f821ba42c80e7940062140d19" ;
4242const UTXO_MASTER_FINGERPRINT : & str = "e61b318f" ;
43- const ABSOLUTE_FEES_IN_SATS : u64 = 1000 ;
43+ const ABSOLUTE_FEES_IN_SATS : Amount = Amount :: from_sat ( 1_000 ) ;
4444
4545// UTXO_1 will be used for spending example 1
4646const UTXO_1 : P2trUtxo = P2trUtxo {
@@ -49,7 +49,7 @@ const UTXO_1: P2trUtxo = P2trUtxo {
4949 script_pubkey : UTXO_SCRIPT_PUBKEY ,
5050 pubkey : UTXO_PUBKEY ,
5151 master_fingerprint : UTXO_MASTER_FINGERPRINT ,
52- amount_in_sats : 50 * COIN_VALUE , // 50 BTC
52+ amount_in_sats : Amount :: from_sat ( 50 * 100_000_000 ) , // 50 BTC
5353 derivation_path : BIP86_DERIVATION_PATH ,
5454} ;
5555
@@ -60,7 +60,7 @@ const UTXO_2: P2trUtxo = P2trUtxo {
6060 script_pubkey : UTXO_SCRIPT_PUBKEY ,
6161 pubkey : UTXO_PUBKEY ,
6262 master_fingerprint : UTXO_MASTER_FINGERPRINT ,
63- amount_in_sats : 50 * COIN_VALUE ,
63+ amount_in_sats : Amount :: from_sat ( 50 * 100_000_000 ) , // 50 BTC
6464 derivation_path : BIP86_DERIVATION_PATH ,
6565} ;
6666
@@ -71,7 +71,7 @@ const UTXO_3: P2trUtxo = P2trUtxo {
7171 script_pubkey : UTXO_SCRIPT_PUBKEY ,
7272 pubkey : UTXO_PUBKEY ,
7373 master_fingerprint : UTXO_MASTER_FINGERPRINT ,
74- amount_in_sats : 50 * COIN_VALUE ,
74+ amount_in_sats : Amount :: from_sat ( 50 * 100_000_000 ) , // 50 BTC
7575 derivation_path : BIP86_DERIVATION_PATH ,
7676} ;
7777
@@ -80,7 +80,6 @@ use std::str::FromStr;
8080
8181use bitcoin:: bip32:: { ChildNumber , DerivationPath , ExtendedPrivKey , ExtendedPubKey , Fingerprint } ;
8282use bitcoin:: consensus:: encode;
83- use bitcoin:: constants:: COIN_VALUE ;
8483use bitcoin:: key:: { TapTweak , XOnlyPublicKey } ;
8584use bitcoin:: opcodes:: all:: { OP_CHECKSIG , OP_CLTV , OP_DROP } ;
8685use bitcoin:: psbt:: { self , Input , Output , Psbt , PsbtSighashType } ;
@@ -105,7 +104,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
105104 let change_address =
106105 Address :: from_str ( "bcrt1pz449kexzydh2kaypatup5ultru3ej284t6eguhnkn6wkhswt0l7q3a7j76" ) ?
107106 . require_network ( Network :: Regtest ) ?;
108- let amount_to_send_in_sats = COIN_VALUE ;
107+ let amount_to_send_in_sats = Amount :: ONE_BTC ;
109108 let change_amount = UTXO_1
110109 . amount_in_sats
111110 . checked_sub ( amount_to_send_in_sats)
@@ -216,7 +215,7 @@ struct P2trUtxo<'a> {
216215 script_pubkey : & ' a str ,
217216 pubkey : & ' a str ,
218217 master_fingerprint : & ' a str ,
219- amount_in_sats : u64 ,
218+ amount_in_sats : Amount ,
220219 derivation_path : & ' a str ,
221220}
222221
@@ -259,9 +258,7 @@ fn generate_bip86_key_spend_tx(
259258 witness_utxo : {
260259 let script_pubkey = ScriptBuf :: from_hex ( input_utxo. script_pubkey )
261260 . expect ( "failed to parse input utxo scriptPubkey" ) ;
262- let amount = Amount :: from_sat ( from_amount) ;
263-
264- Some ( TxOut { value : amount. to_sat ( ) , script_pubkey } )
261+ Some ( TxOut { value : from_amount, script_pubkey } )
265262 } ,
266263 tap_key_origins : origins,
267264 ..Default :: default ( )
@@ -448,9 +445,7 @@ impl BenefactorWallet {
448445 let input = Input {
449446 witness_utxo : {
450447 let script_pubkey = script_pubkey;
451- let amount = Amount :: from_sat ( value) ;
452-
453- Some ( TxOut { value : amount. to_sat ( ) , script_pubkey } )
448+ Some ( TxOut { value, script_pubkey } )
454449 } ,
455450 tap_key_origins : origins,
456451 tap_merkle_root : taproot_spend_info. merkle_root ( ) ,
@@ -594,9 +589,9 @@ impl BenefactorWallet {
594589 let input = Input {
595590 witness_utxo : {
596591 let script_pubkey = output_script_pubkey;
597- let amount = Amount :: from_sat ( output_value) ;
592+ let amount = output_value;
598593
599- Some ( TxOut { value : amount. to_sat ( ) , script_pubkey } )
594+ Some ( TxOut { value : amount, script_pubkey } )
600595 } ,
601596 tap_key_origins : origins,
602597 tap_merkle_root : taproot_spend_info. merkle_root ( ) ,
0 commit comments