def get_fees( inputs, outputs ): """ Given a transaction's outputs, look up its fees: * there should be two outputs: the OP_RETURN and change address Return (dust fees, operation fees) on success Return (None, None) on invalid output listing """ if len(outputs) != 2: return (None, None) # 0: op_return if not virtualchain.tx_output_has_data( outputs[0] ): return (None, None) if outputs[0]["value"] != 0: return (None, None) # 1: change address if virtualchain.script_hex_to_address( outputs[1]["script"] ) is None: return (None, None) # should match make_outputs(). # the +1 comes from one new output dust_fee = (len(inputs) + 1) * DEFAULT_DUST_FEE + DEFAULT_OP_RETURN_FEE op_fee = 0 return (dust_fee, op_fee)
def get_fees(inputs, outputs): """ Get (dust fee, op fee) for namespace reveal (op fee is 0) """ dust_fee = 0 op_fee = 0 if len(outputs) != 3: log.debug("len(outputs) == %s" % len(outputs)) return (None, None) # 0: op_return if not virtualchain.tx_output_has_data(outputs[0]): log.debug("output[0] is not an OP_RETURN") return (None, None) # 1: reveal address if virtualchain.script_hex_to_address(outputs[1]["script"]) is None: log.debug("output[1] is not a valid script") return (None, None) # 2: change address if virtualchain.script_hex_to_address(outputs[2]["script"]) is None: log.debug("output[2] is not a valid script") return (None, None) # should match make_outputs() dust_fee = (len(inputs) + 2) * DEFAULT_DUST_FEE + DEFAULT_OP_RETURN_FEE return (dust_fee, op_fee)
def get_fees(inputs, outputs): """ Given a transaction's outputs, look up its fees: * the first output should be an OP_RETURN with the transfer info * the second output should be the new owner's address, with a DEFAULT_DUST_FEE * the third output should be the change address Return (dust fees, operation fees) on success Return (None, None) on invalid output listing """ if len(outputs) != 3: return (None, None) # 0: op_return if not virtualchain.tx_output_has_data(outputs[0]): return (None, None) if outputs[0]["value"] != 0: return (None, None) # 1: transfer address if virtualchain.script_hex_to_address(outputs[1]["script"]) is None: return (None, None) # 2: change address if virtualchain.script_hex_to_address(outputs[2]["script"]) is None: return (None, None) # should match make_outputs() # the +2 comes from 2 new outputs dust_fee = (len(inputs) + 2) * DEFAULT_DUST_FEE + DEFAULT_OP_RETURN_FEE op_fee = DEFAULT_DUST_FEE return (dust_fee, op_fee)
def get_fees( inputs, outputs ): """ Get (dust fee, op fee) for namespace reveal (op fee is 0) """ dust_fee = 0 op_fee = 0 if len(outputs) != 3: log.debug("len(outputs) == %s" % len(outputs)) return (None, None) # 0: op_return if not virtualchain.tx_output_has_data( outputs[0] ): log.debug("output[0] is not an OP_RETURN") return (None, None) # 1: reveal address if virtualchain.script_hex_to_address( outputs[1]["script"] ) is None: log.debug("output[1] is not a valid script") return (None, None) # 2: change address if virtualchain.script_hex_to_address( outputs[2]["script"] ) is None: log.debug("output[2] is not a valid script") return (None, None) # should match make_outputs() dust_fee = (len(inputs) + 2) * DEFAULT_DUST_FEE + DEFAULT_OP_RETURN_FEE return (dust_fee, op_fee)
def get_fees( inputs, outputs ): """ Given a transaction's outputs, look up its fees: * the first output should be an OP_RETURN with the transfer info * the second output should be the new owner's address, with a DEFAULT_DUST_FEE * the third output should be the change address Return (dust fees, operation fees) on success Return (None, None) on invalid output listing """ if len(outputs) != 3: return (None, None) # 0: op_return if not virtualchain.tx_output_has_data( outputs[0] ): return (None, None) if outputs[0]["value"] != 0: return (None, None) # 1: transfer address if virtualchain.script_hex_to_address( outputs[1]["script"] ) is None: return (None, None) # 2: change address if virtualchain.script_hex_to_address( outputs[2]["script"] ) is None: return (None, None) # should match make_outputs() # the +2 comes from 2 new outputs dust_fee = (len(inputs) + 2) * DEFAULT_DUST_FEE + DEFAULT_OP_RETURN_FEE op_fee = DEFAULT_DUST_FEE return (dust_fee, op_fee)
def get_fees(inputs, outputs): """ Given a transaction's outputs, look up its fees: * the first output must be an OP_RETURN, and it must have a fee of 0. * the second output must be the reveal address, and it must have a dust fee * the third must be the change address * the fourth, if given, must be a burned fee sent to the burn address Return (dust fees, operation fees) on success Return (None, None) on invalid output listing """ dust_fee = 0 op_fee = 0 if len(outputs) != 3 and len(outputs) != 4: log.debug("len(outputs) == %s" % len(outputs)) return (None, None) # 0: op_return if not virtualchain.tx_output_has_data(outputs[0]): log.debug("output[0] is not an OP_RETURN") return (None, None) # 1: reveal address if virtualchain.script_hex_to_address(outputs[1]["script"]) is None: log.debug("output[1] is not a standard script") return (None, None) # 2: change address if virtualchain.script_hex_to_address(outputs[2]["script"]) is None: log.debug("output[2] is not a a standard script") return (None, None) # 3: burn address, if given if len(outputs) == 4: addr_hash = virtualchain.script_hex_to_address(outputs[3]["script"]) if addr_hash is None: log.debug("output[3] is not a standard script") return (None, None) if addr_hash != BLOCKSTACK_BURN_ADDRESS: log.debug("output[3] is not the burn address %s (got %s)" % (BLOCKSTACK_BURN_ADDRESS, addr_hash)) return (None, None) # should match make_outputs(). # the +3 comes from 1 owner UTXO + 2 new outputs dust_fee = (len(inputs) + 3) * DEFAULT_DUST_FEE + DEFAULT_OP_RETURN_FEE op_fee = outputs[3]["value"] else: # should match make_outputs(). # the +2 comes from 1 owner UTXO + 1 new output dust_fee = (len(inputs) + 2) * DEFAULT_DUST_FEE + DEFAULT_OP_RETURN_FEE return (dust_fee, op_fee)
def get_fees( inputs, outputs ): """ Given a transaction's outputs, look up its fees: * the first output must be an OP_RETURN, and it must have a fee of 0. * the second output must be the reveal address, and it must have a dust fee * the third must be the change address * the fourth, if given, must be a burned fee sent to the burn address Return (dust fees, operation fees) on success Return (None, None) on invalid output listing """ dust_fee = 0 op_fee = 0 if len(outputs) != 3 and len(outputs) != 4: log.debug("len(outputs) == %s" % len(outputs)) return (None, None) # 0: op_return if not virtualchain.tx_output_has_data( outputs[0] ): log.debug("output[0] is not an OP_RETURN") return (None, None) # 1: reveal address if virtualchain.script_hex_to_address( outputs[1]["script"] ) is None: log.debug("output[1] is not a standard script") return (None, None) # 2: change address if virtualchain.script_hex_to_address( outputs[2]["script"] ) is None: log.debug("output[2] is not a a standard script") return (None, None) # 3: burn address, if given if len(outputs) == 4: addr_hash = virtualchain.script_hex_to_address( outputs[3]["script"] ) if addr_hash is None: log.debug("output[3] is not a standard script") return (None, None) if addr_hash != BLOCKSTACK_BURN_ADDRESS: log.debug("output[3] is not the burn address %s (got %s)" % (BLOCKSTACK_BURN_ADDRESS, addr_hash)) return (None, None) # should match make_outputs(). # the +3 comes from 1 owner UTXO + 2 new outputs dust_fee = (len(inputs) + 3) * DEFAULT_DUST_FEE + DEFAULT_OP_RETURN_FEE op_fee = outputs[3]["value"] else: # should match make_outputs(). # the +2 comes from 1 owner UTXO + 1 new output dust_fee = (len(inputs) + 2) * DEFAULT_DUST_FEE + DEFAULT_OP_RETURN_FEE return (dust_fee, op_fee)
def get_fees(inputs, outputs): """ Given a transaction's outputs, look up its fees: * the first output must be an OP_RETURN, and it must have a fee of 0. # the second must be the change address * the third must be a burn fee to the burn address. Return (dust fees, operation fees) on success Return (None, None) on invalid output listing """ if len(outputs) != 3: log.debug("Expected 3 outputs; got %s" % len(outputs)) return (None, None) # 0: op_return if not virtualchain.tx_output_has_data(outputs[0]): log.debug("outputs[0] is not an OP_RETURN") return (None, None) if outputs[0]["value"] != 0: log.debug("outputs[0] has value %s'" % outputs[0]["value"]) return (None, None) # 1: change address if virtualchain.script_hex_to_address(outputs[1]["script"]) is None: log.error("outputs[1] has no decipherable change address") return (None, None) # 2: burn address addr_hash = virtualchain.script_hex_to_address(outputs[2]["script"]) if addr_hash is None: log.error("outputs[2] has no decipherable burn address") return (None, None) if addr_hash != BLOCKSTACK_BURN_ADDRESS: log.error("outputs[2] is not the burn address (%s)" % BLOCKSTACK_BURN_ADDRESS) return (None, None) # should match make_outputs() # the +2 comes from 2 new outputs dust_fee = (len(inputs) + 2) * DEFAULT_DUST_FEE + DEFAULT_OP_RETURN_FEE op_fee = outputs[2]["value"] return (dust_fee, op_fee)
def get_fees( inputs, outputs ): """ Given a transaction's outputs, look up its fees: * the first output must be an OP_RETURN, and it must have a fee of 0. # the second must be the change address * the third must be a burn fee to the burn address. Return (dust fees, operation fees) on success Return (None, None) on invalid output listing """ if len(outputs) != 3: log.debug("Expected 3 outputs; got %s" % len(outputs)) return (None, None) # 0: op_return if not virtualchain.tx_output_has_data( outputs[0] ): log.debug("outputs[0] is not an OP_RETURN") return (None, None) if outputs[0]["value"] != 0: log.debug("outputs[0] has value %s'" % outputs[0]["value"]) return (None, None) # 1: change address if virtualchain.script_hex_to_address( outputs[1]["script"] ) is None: log.error("outputs[1] has no decipherable change address") return (None, None) # 2: burn address addr_hash = virtualchain.script_hex_to_address( outputs[2]["script"] ) if addr_hash is None: log.error("outputs[2] has no decipherable burn address") return (None, None) if addr_hash != BLOCKSTACK_BURN_ADDRESS: log.error("outputs[2] is not the burn address (%s)" % BLOCKSTACK_BURN_ADDRESS) return (None, None) # should match make_outputs() # the +2 comes from 2 new outputs dust_fee = (len(inputs) + 2) * DEFAULT_DUST_FEE + DEFAULT_OP_RETURN_FEE op_fee = outputs[2]["value"] return (dust_fee, op_fee)
def get_fees(inputs, outputs): """ Get (dust fee, op fee) for namespace preorder. op fee is the namespace cost (burnt) dust fee is the total cost that our outputs must sum to """ if len(outputs) != 3: log.debug("Expected 3 outputs; got %s" % len(outputs)) return (None, None) # 0: op_return if not virtualchain.tx_output_has_data(outputs[0]): log.debug("outputs[0] is not an OP_RETURN") return (None, None) if outputs[0]["value"] != 0: log.debug("outputs[0] has value %s'" % outputs[0]["value"]) return (None, None) # 1: change address if virtualchain.script_hex_to_address(outputs[1]["script"]) is None: log.error("outputs[1] has no decipherable change address") return (None, None) # 2: burn address addr_hash = virtualchain.script_hex_to_address(outputs[2]["script"]) if addr_hash is None: log.error("outputs[2] has no decipherable burn address") return (None, None) if addr_hash != BLOCKSTACK_BURN_ADDRESS: log.error("outputs[2] is not the burn address (%s)" % BLOCKSTACK_BURN_ADDRESS) return (None, None) # should match make_outputs() dust_fee = (len(inputs) + 2) * DEFAULT_DUST_FEE + DEFAULT_OP_RETURN_FEE op_fee = outputs[2]["value"] return (dust_fee, op_fee)
def get_fees( inputs, outputs ): """ Get (dust fee, op fee) for namespace preorder. op fee is the namespace cost (burnt) dust fee is the total cost that our outputs must sum to """ if len(outputs) != 3: log.debug("Expected 3 outputs; got %s" % len(outputs)) return (None, None) # 0: op_return if not virtualchain.tx_output_has_data( outputs[0] ): log.debug("outputs[0] is not an OP_RETURN") return (None, None) if outputs[0]["value"] != 0: log.debug("outputs[0] has value %s'" % outputs[0]["value"]) return (None, None) # 1: change address if virtualchain.script_hex_to_address( outputs[1]["script"] ) is None: log.error("outputs[1] has no decipherable change address") return (None, None) # 2: burn address addr_hash = virtualchain.script_hex_to_address( outputs[2]["script"] ) if addr_hash is None: log.error("outputs[2] has no decipherable burn address") return (None, None) if addr_hash != BLOCKSTACK_BURN_ADDRESS: log.error("outputs[2] is not the burn address (%s)" % BLOCKSTACK_BURN_ADDRESS) return (None, None) # should match make_outputs() dust_fee = (len(inputs) + 2) * DEFAULT_DUST_FEE + DEFAULT_OP_RETURN_FEE op_fee = outputs[2]["value"] return (dust_fee, op_fee)