Module: Glueby::Contract::FeeEstimator
- Defined in:
- lib/glueby/contract/fee_estimator.rb,
lib/glueby/contract/fee_estimator/auto.rb,
lib/glueby/contract/fee_estimator/fixed.rb
Defined Under Namespace
Class Method Summary collapse
-
.dummy_tx(tx, dummy_input_count: 1) ⇒ Tapyrus::Tx
Add dummy inputs and outputs to tx.
Instance Method Summary collapse
-
#fee(tx) ⇒ Object
Fee by tapyrus(not TPC).
Class Method Details
.dummy_tx(tx, dummy_input_count: 1) ⇒ Tapyrus::Tx
Add dummy inputs and outputs to tx. Fee Estimation needs the actual tx size when it will be broadcasted to the blockchain network.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/glueby/contract/fee_estimator.rb', line 20 def dummy_tx(tx, dummy_input_count: 1) dummy = Tapyrus::Tx.parse_from_payload(tx.to_payload) # dummy input for tpc dummy_input_count.times do out_point = Tapyrus::OutPoint.new('00' * 32, 0) dummy.inputs << Tapyrus::TxIn.new(out_point: out_point) end # Add script_sig to all intpus dummy.inputs.each do |input| input.script_sig = Tapyrus::Script.parse_from_payload(('00' * 100).htb) end # dummy output to return change change_script = Tapyrus::Script.to_p2pkh('0000000000000000000000000000000000000000') dummy.outputs << Tapyrus::TxOut.new(value: 0, script_pubkey: change_script) dummy end |
Instance Method Details
#fee(tx) ⇒ Object
Returns fee by tapyrus(not TPC).
9 10 11 12 |
# File 'lib/glueby/contract/fee_estimator.rb', line 9 def fee(tx) return 0 if Glueby.configuration.fee_provider_bears? estimate_fee(tx) end |