@@ -50,7 +50,8 @@ pub struct Vin {
5050#[ derive( Deserialize , Clone , Debug , PartialEq , Eq ) ]
5151pub struct Vout {
5252 /// The value of the output, in satoshis.
53- pub value : u64 ,
53+ #[ serde( with = "bitcoin::amount::serde::as_sat" ) ]
54+ pub value : Amount ,
5455 /// The ScriptPubKey that the output is locked to, as a [`ScriptBuf`].
5556 pub scriptpubkey : ScriptBuf ,
5657}
@@ -129,7 +130,8 @@ pub struct Tx {
129130 /// The confirmation status of the [`Transaction`].
130131 pub status : TxStatus ,
131132 /// The fee amount paid by the [`Transaction`], in satoshis.
132- pub fee : u64 ,
133+ #[ serde( with = "bitcoin::amount::serde::as_sat" ) ]
134+ pub fee : Amount ,
133135}
134136
135137/// Information about a bitcoin [`Block`].
@@ -211,11 +213,13 @@ pub struct AddressTxsSummary {
211213 /// The number of funded [`TxOut`]s.
212214 pub funded_txo_count : u32 ,
213215 /// The sum of the funded [`TxOut`]s, in satoshis.
214- pub funded_txo_sum : u64 ,
216+ #[ serde( with = "bitcoin::amount::serde::as_sat" ) ]
217+ pub funded_txo_sum : Amount ,
215218 /// The number of spent [`TxOut`]s.
216219 pub spent_txo_count : u32 ,
217220 /// The sum of the spent [`TxOut`]s, in satoshis.
218- pub spent_txo_sum : u64 ,
221+ #[ serde( with = "bitcoin::amount::serde::as_sat" ) ]
222+ pub spent_txo_sum : Amount ,
219223 /// The total number of [`Transaction`]s.
220224 pub tx_count : u32 ,
221225}
@@ -256,6 +260,7 @@ pub struct Utxo {
256260 /// The confirmation status of the [`TxOut`].
257261 pub status : UtxoStatus ,
258262 /// The value of the [`TxOut`] as an [`Amount`].
263+ #[ serde( with = "bitcoin::amount::serde::as_sat" ) ]
259264 pub value : Amount ,
260265}
261266
@@ -267,7 +272,8 @@ pub struct MempoolStats {
267272 /// The total size of mempool [`Transaction`]s, in virtual bytes.
268273 pub vsize : usize ,
269274 /// The total fee paid by mempool [`Transaction`]s, in satoshis.
270- pub total_fee : u64 ,
275+ #[ serde( with = "bitcoin::amount::serde::as_sat" ) ]
276+ pub total_fee : Amount ,
271277 /// The mempool's fee rate distribution histogram.
272278 ///
273279 /// An array of `(feerate, vsize)` tuples, where each entry's `vsize` is the total vsize
@@ -282,11 +288,13 @@ pub struct MempoolRecentTx {
282288 /// The [`Transaction`]'s ID, as a [`Txid`].
283289 pub txid : Txid ,
284290 /// The [`Amount`] of fees paid by the transaction, in satoshis.
285- pub fee : u64 ,
291+ #[ serde( with = "bitcoin::amount::serde::as_sat" ) ]
292+ pub fee : Amount ,
286293 /// The [`Transaction`]'s size, in virtual bytes.
287294 pub vsize : usize ,
288295 /// Combined [`Amount`] of the [`Transaction`], in satoshis.
289- pub value : u64 ,
296+ #[ serde( with = "bitcoin::amount::serde::as_sat" ) ]
297+ pub value : Amount ,
290298}
291299
292300/// The result for a broadcasted package of [`Transaction`]s.
@@ -370,7 +378,7 @@ impl Tx {
370378 . iter ( )
371379 . cloned ( )
372380 . map ( |vout| TxOut {
373- value : Amount :: from_sat ( vout. value ) ,
381+ value : vout. value ,
374382 script_pubkey : vout. scriptpubkey ,
375383 } )
376384 . collect ( ) ,
@@ -398,7 +406,7 @@ impl Tx {
398406 . map ( |vin| {
399407 vin. prevout . map ( |po| TxOut {
400408 script_pubkey : po. scriptpubkey ,
401- value : Amount :: from_sat ( po. value ) ,
409+ value : po. value ,
402410 } )
403411 } )
404412 . collect ( )
@@ -408,11 +416,6 @@ impl Tx {
408416 pub fn weight ( & self ) -> Weight {
409417 Weight :: from_wu ( self . weight )
410418 }
411-
412- /// Get the fee paid by a [`Tx`].
413- pub fn fee ( & self ) -> Amount {
414- Amount :: from_sat ( self . fee )
415- }
416419}
417420
418421fn deserialize_witness < ' de , D > ( d : D ) -> Result < Vec < Vec < u8 > > , D :: Error >
0 commit comments