1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//! Fee model trait for transaction fee computation.
//!
//! This module provides the [`FeeModel`] trait that defines how transaction
//! fees are computed. Different fee models can be implemented for various
//! fee calculation strategies.
//!
//! # Example
//!
//! ```rust,ignore
//! use bsv_rs::transaction::{FeeModel, SatoshisPerKilobyte, Transaction};
//!
//! let fee_model = SatoshisPerKilobyte::new(100); // 100 sat/KB
//! let tx = Transaction::new();
//! let fee = fee_model.compute_fee(&tx)?;
//! ```
use Transaction;
use crateResult;
/// Represents the interface for a transaction fee model.
///
/// This trait defines a standard method for computing a fee when given
/// a transaction. Implementations can use different strategies such as
/// fixed fees, satoshis per kilobyte, or dynamic fee calculation based
/// on network conditions.
///
/// # Example
///
/// ```rust,ignore
/// use bsv_rs::transaction::{FeeModel, Transaction};
///
/// struct FixedFee(u64);
///
/// impl FeeModel for FixedFee {
/// fn compute_fee(&self, _tx: &Transaction) -> Result<u64> {
/// Ok(self.0)
/// }
/// }
/// ```
/// A fixed fee model that always returns the same fee.
///
/// This is useful for testing or when a specific fee amount is required.
///
/// # Example
///
/// ```rust,ignore
/// use bsv_rs::transaction::{FixedFee, FeeModel, Transaction};
///
/// let fee_model = FixedFee::new(500);
/// let tx = Transaction::new();
/// assert_eq!(fee_model.compute_fee(&tx)?, 500);
/// ```
;