def test_estimate_tx_size(ins, outs, txtype, valid): #TODO: this function should throw on invalid number of ins or outs if valid: assert btc.estimate_tx_size(ins, outs, txtype)== 10 + 147*ins + 34*outs else: with pytest.raises(NotImplementedError) as e_info: btc.estimate_tx_size(ins, outs, txtype)
def test_estimate_tx_size(ins, outs, txtype, valid): #TODO: this function should throw on invalid number of ins or outs if valid: assert btc.estimate_tx_size(ins, outs, txtype) == 10 + 147 * ins + 34 * outs else: with pytest.raises(NotImplementedError) as e_info: btc.estimate_tx_size(ins, outs, txtype)
def estimate_tx_fee(ins, outs, txtype='p2pkh'): '''Returns an estimate of the number of satoshis required for a transaction with the given number of inputs and outputs, based on information from the blockchain interface. ''' tx_estimated_bytes = btc.estimate_tx_size(ins, outs, txtype) log.debug("Estimated transaction size: "+str(tx_estimated_bytes)) fee_per_kb = jm_single().bc_interface.estimate_fee_per_kb( jm_single().config.getint("POLICY","tx_fees")) log.debug("got estimated tx bytes: "+str(tx_estimated_bytes)) return int((tx_estimated_bytes * fee_per_kb)/Decimal(1000.0))
def estimate_tx_fee(ins, outs, txtype='p2pkh'): '''Returns an estimate of the number of satoshis required for a transaction with the given number of inputs and outputs, based on information from the blockchain interface. ''' tx_estimated_bytes = btc.estimate_tx_size(ins, outs, txtype) log.debug("Estimated transaction size: "+str(tx_estimated_bytes)) fee_per_kb = jm_single().bc_interface.estimate_fee_per_kb( jm_single().config.getint("POLICY", "tx_fees")) absurd_fee = jm_single().config.getint("POLICY", "absurd_fee_per_kb") if fee_per_kb > absurd_fee: #This error is considered critical; for safety reasons, shut down. raise ValueError("Estimated fee per kB greater than absurd value: " + \ str(absurd_fee) + ", quitting.") log.debug("got estimated tx bytes: "+str(tx_estimated_bytes)) return int((tx_estimated_bytes * fee_per_kb)/Decimal(1000.0))