Skip to content

Commit 413c3c7

Browse files
committed
Add Transaction::fee getter
1 parent 6a5c4c3 commit 413c3c7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/transaction.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,12 @@ impl Transaction {
612612
self.consensus_encode(&mut enc).unwrap();
613613
bitcoin::Wtxid::from_engine(enc)
614614
}
615+
616+
/// Get the total transaction fee.
617+
pub fn fee(&self) -> u64 {
618+
// All values should be explicit, so we don't have to assert that here.
619+
self.output.iter().filter(|o| o.is_fee()).filter_map(|o| o.value.explicit()).sum()
620+
}
615621
}
616622

617623
//TODO(stevenroose) remove this, it's incorrect

0 commit comments

Comments
 (0)