Class: BSV::Transaction::FeeModels::SatoshisPerKilobyte
- Inherits:
-
BSV::Transaction::FeeModel
- Object
- BSV::Transaction::FeeModel
- BSV::Transaction::FeeModels::SatoshisPerKilobyte
- Defined in:
- lib/bsv/transaction/fee_models/satoshis_per_kilobyte.rb
Overview
Fee model that charges a configurable number of satoshis per kilobyte.
Uses the transaction’s estimated size (from templates for unsigned inputs, actual size for signed inputs) to compute the fee.
Instance Attribute Summary collapse
-
#value ⇒ Integer
readonly
Satoshis per kilobyte rate.
Instance Method Summary collapse
-
#compute_fee(transaction) ⇒ Integer
Compute the fee for a transaction based on its estimated size.
-
#initialize(value: 100) ⇒ SatoshisPerKilobyte
constructor
A new instance of SatoshisPerKilobyte.
Constructor Details
#initialize(value: 100) ⇒ SatoshisPerKilobyte
Returns a new instance of SatoshisPerKilobyte.
19 20 21 22 |
# File 'lib/bsv/transaction/fee_models/satoshis_per_kilobyte.rb', line 19 def initialize(value: 100) super() @value = value end |
Instance Attribute Details
#value ⇒ Integer (readonly)
Returns satoshis per kilobyte rate.
16 17 18 |
# File 'lib/bsv/transaction/fee_models/satoshis_per_kilobyte.rb', line 16 def value @value end |
Instance Method Details
#compute_fee(transaction) ⇒ Integer
Compute the fee for a transaction based on its estimated size.
28 29 30 31 |
# File 'lib/bsv/transaction/fee_models/satoshis_per_kilobyte.rb', line 28 def compute_fee(transaction) size = transaction.estimated_size (size / 1000.0 * @value).ceil end |