File tree Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -220,8 +220,8 @@ pub(crate) struct ConstructedTransaction {
220220pub ( crate ) struct NegotiatedTxInput {
221221 serial_id : SerialId ,
222222 txin : TxIn ,
223- /// The weight of the input (in WU's)
224- weight : u64 ,
223+ // The weight of the input including an estimate of its witness weight.
224+ weight : Weight ,
225225}
226226
227227impl_writeable_tlv_based ! ( NegotiatedTxInput , {
@@ -314,7 +314,7 @@ impl ConstructedTransaction {
314314
315315 pub fn weight ( & self ) -> Weight {
316316 let inputs_weight = self . inputs . iter ( ) . fold ( Weight :: from_wu ( 0 ) , |weight, input| {
317- weight. checked_add ( Weight :: from_wu ( input. weight ) ) . unwrap_or ( Weight :: MAX )
317+ weight. checked_add ( input. weight ) . unwrap_or ( Weight :: MAX )
318318 } ) ;
319319 let outputs_weight = self . outputs . iter ( ) . fold ( Weight :: from_wu ( 0 ) , |weight, output| {
320320 weight. checked_add ( get_output_weight ( output. script_pubkey ( ) ) ) . unwrap_or ( Weight :: MAX )
@@ -1532,7 +1532,7 @@ impl InteractiveTxInput {
15321532 }
15331533
15341534 fn into_negotiated_input ( self ) -> NegotiatedTxInput {
1535- let weight = self . input . estimate_input_weight ( ) . to_wu ( ) ;
1535+ let weight = self . input . estimate_input_weight ( ) ;
15361536 NegotiatedTxInput { serial_id : self . serial_id , txin : self . input . into_tx_in ( ) , weight }
15371537 }
15381538}
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ use bitcoin::secp256k1::ecdsa;
4141use bitcoin:: secp256k1:: schnorr;
4242use bitcoin:: secp256k1:: { PublicKey , SecretKey } ;
4343use bitcoin:: transaction:: { OutPoint , Transaction , TxOut } ;
44- use bitcoin:: { consensus, TxIn , Witness } ;
44+ use bitcoin:: { consensus, TxIn , Weight , Witness } ;
4545
4646use dnssec_prover:: rr:: Name ;
4747
@@ -1381,6 +1381,19 @@ impl Readable for Amount {
13811381 }
13821382}
13831383
1384+ impl Writeable for Weight {
1385+ fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , io:: Error > {
1386+ self . to_wu ( ) . write ( w)
1387+ }
1388+ }
1389+
1390+ impl Readable for Weight {
1391+ fn read < R : Read > ( r : & mut R ) -> Result < Self , DecodeError > {
1392+ let wu: u64 = Readable :: read ( r) ?;
1393+ Ok ( Weight :: from_wu ( wu) )
1394+ }
1395+ }
1396+
13841397impl Writeable for Txid {
13851398 fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , io:: Error > {
13861399 w. write_all ( & self [ ..] )
You can’t perform that action at this time.
0 commit comments