def make_outputs( data, inputs, recipient_address, sender_address, update_hash_b58, format='bin'): """ Builds the outputs for a name import: * [0] is the OP_RETURN * [1] is the new owner (recipient) * [2] is the update hash * [3] is the change sent to the original owner """ dust_value = DEFAULT_DUST_FEE outputs = [ # main output {"script_hex": make_op_return_script(data, format=format), "value": 0}, # recipient output {"script_hex": make_pay_to_address_script(recipient_address), "value": dust_value}, # update hash output {"script_hex": make_pay_to_address_script(update_hash_b58), "value": dust_value}, # change output {"script_hex": make_pay_to_address_script(sender_address), "value": calculate_change_amount(inputs, 0, 0)} ] dust_fee = tx_dust_fee_from_inputs_and_outputs( inputs, outputs ) outputs[-1]['value'] = calculate_change_amount( inputs, 2*dust_value, dust_fee ) return outputs
def make_outputs(data, inputs, change_addr, op_fee, format='bin'): """ Make outputs for a namespace preorder: [0] OP_RETURN with the name [1] change address with the NAME_PREORDER sender's address [2] pay-to-address with the *burn address* with the fee """ op_fee = max(op_fee, DEFAULT_DUST_FEE) outputs = [ # main output { "script_hex": make_op_return_script(data, format=format), "value": 0 }, # change address { "script_hex": make_pay_to_address_script(change_addr), "value": calculate_change_amount(inputs, 0, 0) }, # burn address { "script_hex": make_pay_to_address_script(BLOCKSTORE_BURN_ADDRESS), "value": op_fee } ] dust_fee = tx_dust_fee_from_inputs_and_outputs(inputs, outputs) outputs[1]['value'] = calculate_change_amount(inputs, op_fee, dust_fee) return outputs
def make_outputs( data, inputs, reveal_addr, change_addr, format='bin', testset=False ): """ Make outputs for a register: [0] OP_RETURN with the name [1] pay-to-address with the *reveal_addr*, not the sender's address. [2] change address with the NAMESPACE_PREORDER sender's address """ outputs = [ # main output {"script_hex": make_op_return_script(data, format=format), "value": 0}, # register address {"script_hex": make_pay_to_address_script(reveal_addr), "value": DEFAULT_DUST_FEE}, # change address {"script_hex": make_pay_to_address_script(change_addr), "value": calculate_change_amount(inputs, 0, 0)}, ] dust_fee = tx_dust_fee_from_inputs_and_outputs( inputs, outputs ) outputs[-1]['value'] = calculate_change_amount( inputs, DEFAULT_DUST_FEE, dust_fee ) return outputs
def make_outputs( data, inputs, change_addr, op_fee, format='bin' ): """ Make outputs for a namespace preorder: [0] OP_RETURN with the name [1] change address with the NAME_PREORDER sender's address [2] pay-to-address with the *burn address* with the fee """ op_fee = max( op_fee, DEFAULT_DUST_FEE ) outputs = [ # main output {"script_hex": make_op_return_script(data, format=format), "value": 0}, # change address {"script_hex": make_pay_to_address_script(change_addr), "value": calculate_change_amount(inputs, 0, 0)}, # burn address {"script_hex": make_pay_to_address_script(BLOCKSTORE_BURN_ADDRESS), "value": op_fee} ] dust_fee = tx_dust_fee_from_inputs_and_outputs( inputs, outputs ) outputs[1]['value'] = calculate_change_amount( inputs, op_fee, dust_fee ) return outputs
def make_outputs( data, inputs, sender_addr, op_fee, format='bin' ): """ Make outputs for a name preorder: [0] OP_RETURN with the name [1] address with the NAME_PREORDER sender's address [2] pay-to-address with the *burn address* with the fee NOTE: the fee must cover *all* the names """ outputs = [ # main output {"script_hex": make_op_return_script(data, format=format), "value": 0}, # change address (can be subsidy key) {"script_hex": make_pay_to_address_script(sender_addr), "value": calculate_change_amount(inputs, 0, 0)}, # burn address {"script_hex": make_pay_to_address_script(BLOCKSTORE_BURN_ADDRESS), "value": op_fee} ] dust_fee = tx_dust_fee_from_inputs_and_outputs( inputs, outputs ) outputs[1]['value'] = calculate_change_amount( inputs, op_fee, dust_fee ) return outputs
def make_outputs(data, inputs, reveal_addr, change_addr, tx_fee): """ Make outputs for a register: [0] OP_RETURN with the name [1] pay-to-address with the *reveal_addr*, not the sender's address. [2] change address with the NAMESPACE_PREORDER sender's address Raise ValueError if there are not enough inputs to make the transaction """ total_to_send = DEFAULT_OP_RETURN_FEE + DEFAULT_DUST_FEE return [ # main output { "script_hex": make_op_return_script(str(data), format='hex'), "value": 0 }, # register address { "script_hex": virtualchain.make_payment_script(reveal_addr), "value": DEFAULT_DUST_FEE }, # change address { "script_hex": virtualchain.make_payment_script(change_addr), "value": calculate_change_amount(inputs, total_to_send, DEFAULT_DUST_FEE * (len(inputs) + 3)) + tx_fee }, ]
def make_outputs(data, inputs, new_name_owner_address, change_address, format='bin'): """ Builds the outputs for a name transfer operation. """ total_to_send = DEFAULT_OP_RETURN_FEE + DEFAULT_DUST_FEE return [ # main output { "script_hex": make_op_return_script(data, format=format), "value": DEFAULT_OP_RETURN_FEE }, # new name owner output { "script_hex": make_pay_to_address_script(new_name_owner_address), "value": DEFAULT_DUST_FEE }, # change output { "script_hex": make_pay_to_address_script(change_address), "value": calculate_change_amount(inputs, total_to_send, (len(inputs) + 3) * DEFAULT_DUST_FEE) } ]
def make_outputs( data, inputs, recipient_address, sender_address, update_hash_b58, tx_fee): """ Builds the outputs for a name import: * [0] is the OP_RETURN * [1] is the new owner (recipient) * [2] is the update hash * [3] is the change sent to the original owner Raise ValueError if there are not enough inputs to make the transaction """ dust_fee = DEFAULT_OP_RETURN_FEE + (len(inputs) + 3) * DEFAULT_DUST_FEE + tx_fee op_fee = 2 * DEFAULT_DUST_FEE dust_value = DEFAULT_DUST_FEE return [ # main output {"script_hex": make_op_return_script(str(data), format='hex'), "value": 0}, # recipient output {"script_hex": make_pay_to_address_script(recipient_address), "value": dust_value}, # update hash output {"script_hex": make_pay_to_address_script(update_hash_b58), "value": dust_value}, # change output {"script_hex": make_pay_to_address_script(sender_address), "value": calculate_change_amount(inputs, op_fee, dust_fee)} ]
def make_outputs( data, inputs, recipient_address, sender_address, update_hash_b58, tx_fee): """ Builds the outputs for a name import: * [0] is the OP_RETURN * [1] is the new owner (recipient) * [2] is the update hash * [3] is the change sent to the original owner Raise ValueError if there are not enough inputs to make the transaction """ dust_fee = DEFAULT_OP_RETURN_FEE + (len(inputs) + 3) * DEFAULT_DUST_FEE + tx_fee op_fee = 2 * DEFAULT_DUST_FEE dust_value = DEFAULT_DUST_FEE return [ # main output {"script_hex": make_op_return_script(str(data), format='hex'), "value": 0}, # recipient output {"script_hex": virtualchain.make_payment_script(recipient_address), "value": dust_value}, # update hash output {"script_hex": virtualchain.make_payment_script(update_hash_b58), "value": dust_value}, # change output {"script_hex": virtualchain.make_payment_script(sender_address), "value": calculate_change_amount(inputs, op_fee, dust_fee)} ]
def make_outputs(data, inputs, change_addr, fee, format='bin'): """ Make outputs for a namespace preorder: [0] OP_RETURN with the name [1] change address with the NAME_PREORDER sender's address [2] pay-to-address with the *burn address* with the fee """ total_to_send = DEFAULT_OP_RETURN_FEE + DEFAULT_DUST_FEE + max( fee, DEFAULT_DUST_FEE) return [ # main output { "script_hex": make_op_return_script(data, format=format), "value": DEFAULT_OP_RETURN_FEE }, # change address { "script_hex": make_pay_to_address_script(change_addr), "value": calculate_change_amount(inputs, total_to_send, (len(inputs) + 3) * DEFAULT_DUST_FEE) }, # burn address { "script_hex": make_pay_to_address_script(BLOCKSTORE_BURN_ADDRESS), "value": max(fee, DEFAULT_DUST_FEE) } ]
def make_outputs( data, inputs, change_addr, fee, pay_fee=True, format='bin' ): """ Make outputs for a namespace preorder: [0] OP_RETURN with the name [1] change address with the NAME_PREORDER sender's address [2] pay-to-address with the *burn address* with the fee """ dust_fee = DEFAULT_OP_RETURN_FEE + (len(inputs) + 2) * DEFAULT_DUST_FEE op_fee = max(fee, DEFAULT_DUST_FEE) dust_value = DEFAULT_DUST_FEE bill = op_fee if not pay_fee: # subsidized dust_fee = 0 op_fee = 0 dust_value = 0 bill = 0 return [ # main output {"script_hex": make_op_return_script(data, format=format), "value": 0}, # change address {"script_hex": make_pay_to_address_script(change_addr), "value": calculate_change_amount(inputs, bill, dust_fee)}, # burn address {"script_hex": make_pay_to_address_script(BLOCKSTORE_BURN_ADDRESS), "value": op_fee} ]
def make_outputs(data, inputs, change_address, tx_fee, pay_fee=True): """ Make outputs for a revoke. Raise ValueError if there are not enough inputs to make the transaction """ dust_fee = None op_fee = None dust_value = None if pay_fee: dust_fee = (len(inputs) + 1) * DEFAULT_DUST_FEE + DEFAULT_OP_RETURN_FEE + tx_fee op_fee = DEFAULT_DUST_FEE dust_value = DEFAULT_DUST_FEE else: # will be subsidized dust_fee = 0 op_fee = 0 dust_value = 0 return [ # main output { "script_hex": make_op_return_script(str(data), format='hex'), "value": 0 }, # change output { "script_hex": virtualchain.make_payment_script(change_address), "value": calculate_change_amount(inputs, op_fee, dust_fee) } ]
def make_outputs( data, inputs, register_addr, change_addr, renewal_fee=None, format='bin' ): """ Make outputs for a register: [0] OP_RETURN with the name [1] pay-to-address with the *register_addr*, not the sender's address. [2] change address with the NAME_PREORDER sender's address """ total_to_send = DEFAULT_OP_RETURN_FEE + DEFAULT_DUST_FEE if renewal_fee is not None: total_to_send += max(renewal_fee, DEFAULT_DUST_FEE) outputs = [ # main output {"script_hex": make_op_return_script(data, format=format), "value": DEFAULT_OP_RETURN_FEE}, # register address {"script_hex": make_pay_to_address_script(register_addr), "value": DEFAULT_DUST_FEE}, # change address {"script_hex": make_pay_to_address_script(change_addr), "value": calculate_change_amount(inputs, total_to_send, (len(inputs) + 3) * DEFAULT_DUST_FEE)}, ] if renewal_fee is not None: outputs.append( # burn address (when renewing) {"script_hex": make_pay_to_address_script(BLOCKSTORE_BURN_ADDRESS), "value": max(renewal_fee, DEFAULT_DUST_FEE)} ) return outputs
def make_outputs( data, inputs, change_address, tx_fee, pay_fee=True ): """ Make outputs for an update. Raise ValueError if there are not enough inputs to make the transaction """ dust_fee = None op_fee = None dust_value = None if pay_fee: dust_fee = (len(inputs) + 1) * DEFAULT_DUST_FEE + DEFAULT_OP_RETURN_FEE + tx_fee op_fee = DEFAULT_DUST_FEE dust_value = DEFAULT_DUST_FEE else: # will be subsidized dust_fee = 0 op_fee = 0 dust_value = 0 return [ # main output {"script_hex": make_op_return_script(str(data), format='hex'), "value": 0}, # change output {"script_hex": make_pay_to_address_script(change_address), "value": calculate_change_amount(inputs, op_fee, dust_fee)} ]
def make_outputs( data, inputs, recipient_address, sender_address, update_hash_b58, format='bin'): """ Builds the outputs for a name import: * [0] is the OP_RETURN * [1] is the new owner (recipient) * [2] is the update hash * [3] is the change sent to the original owner """ dust_fee = DEFAULT_OP_RETURN_FEE + (len(inputs) + 3) * DEFAULT_DUST_FEE op_fee = 2 * DEFAULT_DUST_FEE dust_value = DEFAULT_DUST_FEE return [ # main output {"script_hex": make_op_return_script(data, format=format), "value": 0}, # recipient output {"script_hex": make_pay_to_address_script(recipient_address), "value": dust_value}, # update hash output {"script_hex": make_pay_to_address_script(update_hash_b58), "value": dust_value}, # change output {"script_hex": make_pay_to_address_script(sender_address), "value": calculate_change_amount(inputs, op_fee, dust_fee)} ]
def make_outputs( data, inputs, new_name_owner_address, change_address, pay_fee=True, format='bin' ): """ Builds the outputs for a name transfer operation. """ dust_fee = None op_fee = None dust_value = DEFAULT_DUST_FEE if pay_fee: dust_fee = (len(inputs) + 2) * DEFAULT_DUST_FEE + DEFAULT_OP_RETURN_FEE op_fee = DEFAULT_DUST_FEE else: dust_fee = 0 op_fee = 0 return [ # main output {"script_hex": make_op_return_script(data, format=format), "value": 0}, # new name owner output {"script_hex": make_pay_to_address_script(new_name_owner_address), "value": dust_value}, # change output {"script_hex": make_pay_to_address_script(change_address), "value": calculate_change_amount(inputs, op_fee, dust_fee)} ]
def make_outputs(data, inputs, sender_addr, fee, format='bin'): """ Make outputs for a name preorder: [0] OP_RETURN with the name [1] address with the NAME_PREORDER sender's address [2] pay-to-address with the *burn address* with the fee """ op_fee = max(fee, DEFAULT_DUST_FEE) dust_fee = (len(inputs) + 2) * DEFAULT_DUST_FEE + DEFAULT_OP_RETURN_FEE dust_value = DEFAULT_DUST_FEE bill = op_fee return [ # main output { "script_hex": make_op_return_script(data, format=format), "value": 0 }, # change address (can be subsidy key) { "script_hex": make_pay_to_address_script(sender_addr), "value": calculate_change_amount(inputs, bill, dust_fee) }, # burn address { "script_hex": make_pay_to_address_script(BLOCKSTORE_BURN_ADDRESS), "value": op_fee } ]
def make_outputs( data, inputs, sender_addr, fee, format='bin' ): """ Make outputs for a name preorder: [0] OP_RETURN with the name [1] address with the NAME_PREORDER sender's address [2] pay-to-address with the *burn address* with the fee """ op_fee = max(fee, DEFAULT_DUST_FEE) dust_fee = (len(inputs) + 2) * DEFAULT_DUST_FEE + DEFAULT_OP_RETURN_FEE dust_value = DEFAULT_DUST_FEE bill = op_fee return [ # main output {"script_hex": make_op_return_script(data, format=format), "value": 0}, # change address (can be subsidy key) {"script_hex": make_pay_to_address_script(sender_addr), "value": calculate_change_amount(inputs, bill, dust_fee)}, # burn address {"script_hex": make_pay_to_address_script(BLOCKSTORE_BURN_ADDRESS), "value": op_fee} ]
def make_outputs( data, inputs, new_name_owner_address, change_address, tx_fee=0, pay_fee=True): """ Builds the outputs for a name transfer operation. Raise ValueError if there are not enough inputs to make the transaction """ dust_fee = None op_fee = None dust_value = DEFAULT_DUST_FEE if pay_fee: dust_fee = (len(inputs) + 2) * DEFAULT_DUST_FEE + DEFAULT_OP_RETURN_FEE + tx_fee op_fee = DEFAULT_DUST_FEE else: dust_fee = 0 op_fee = 0 return [ # main output {"script_hex": make_op_return_script(str(data), format='hex'), "value": 0}, # new name owner output {"script_hex": make_pay_to_address_script(new_name_owner_address), "value": dust_value}, # change output {"script_hex": make_pay_to_address_script(change_address), "value": calculate_change_amount(inputs, op_fee, dust_fee)} ]
def make_outputs( data, inputs, change_addr, fee, tx_fee, pay_fee=True ): """ Make outputs for a namespace preorder: [0] OP_RETURN with the name [1] change address with the NAME_PREORDER sender's address [2] pay-to-address with the *burn address* with the fee Raise ValueError if there are not enough inputs to make the transaction """ dust_fee = DEFAULT_OP_RETURN_FEE + (len(inputs) + 2) * DEFAULT_DUST_FEE + tx_fee op_fee = max(fee, DEFAULT_DUST_FEE) dust_value = DEFAULT_DUST_FEE bill = op_fee if not pay_fee: # subsidized dust_fee = 0 op_fee = 0 dust_value = 0 bill = 0 return [ # main output {"script_hex": make_op_return_script(str(data), format='hex'), "value": 0}, # change address {"script_hex": make_pay_to_address_script(change_addr), "value": calculate_change_amount(inputs, bill, dust_fee)}, # burn address {"script_hex": make_pay_to_address_script(BLOCKSTACK_BURN_ADDRESS), "value": op_fee} ]
def make_outputs( data, change_inputs, register_addr, change_addr, renewal_fee=None, pay_fee=True, format='bin' ): """ Make outputs for a register: [0] OP_RETURN with the name [1] pay-to-address with the *register_addr*, not the sender's address. [2] change address with the NAME_PREORDER sender's address [3] (OPTIONAL) renewal fee, sent to the burn address """ bill = 0 if pay_fee: if renewal_fee is not None: bill = max( renewal_fee, DEFAULT_DUST_FEE ) + DEFAULT_DUST_FEE else: bill = DEFAULT_DUST_FEE outputs = [ # main output {"script_hex": make_op_return_script(data, format=format), "value": 0}, # register address {"script_hex": make_pay_to_address_script(register_addr), "value": DEFAULT_DUST_FEE}, # change address (can be the subsidy address) {"script_hex": make_pay_to_address_script(change_addr), "value": calculate_change_amount(change_inputs, 0, 0)}, ] if renewal_fee is not None: outputs.append( # burn address (when renewing) {"script_hex": make_pay_to_address_script(BLOCKSTORE_BURN_ADDRESS), "value": renewal_fee} ) if pay_fee: dust_fee = tx_dust_fee_from_inputs_and_outputs( change_inputs, outputs ) outputs[2]['value'] = calculate_change_amount( change_inputs, bill, dust_fee ) return outputs
def make_outputs(data, inputs, register_addr, change_addr, renewal_fee=None, format='bin'): """ Make outputs for a register: [0] OP_RETURN with the name [1] pay-to-address with the *register_addr*, not the sender's address. [2] change address with the NAME_PREORDER sender's address """ total_to_send = DEFAULT_OP_RETURN_FEE + DEFAULT_DUST_FEE if renewal_fee is not None: total_to_send += max(renewal_fee, DEFAULT_DUST_FEE) outputs = [ # main output { "script_hex": make_op_return_script(data, format=format), "value": DEFAULT_OP_RETURN_FEE }, # register address { "script_hex": make_pay_to_address_script(register_addr), "value": DEFAULT_DUST_FEE }, # change address { "script_hex": make_pay_to_address_script(change_addr), "value": calculate_change_amount(inputs, total_to_send, (len(inputs) + 3) * DEFAULT_DUST_FEE) }, ] if renewal_fee is not None: outputs.append( # burn address (when renewing) { "script_hex": make_pay_to_address_script(BLOCKSTORE_BURN_ADDRESS), "value": max(renewal_fee, DEFAULT_DUST_FEE) }) return outputs
def make_outputs(data, inputs, new_name_owner_address, change_address, pay_fee=True, format='bin'): """ Builds the outputs for a name transfer operation. """ dust_fee = None op_fee = None dust_value = DEFAULT_DUST_FEE outputs = [ # main output { "script_hex": make_op_return_script(data, format=format), "value": 0 }, # new name owner output { "script_hex": make_pay_to_address_script(new_name_owner_address), "value": dust_value }, # change output { "script_hex": make_pay_to_address_script(change_address), "value": calculate_change_amount(inputs, 0, 0) } ] if pay_fee: dust_fee = tx_dust_fee_from_inputs_and_outputs(inputs, outputs) outputs[-1]['value'] = calculate_change_amount(inputs, dust_value, dust_fee) return outputs
def make_outputs(data, inputs, reveal_addr, change_addr, format='bin', testset=False): """ Make outputs for a register: [0] OP_RETURN with the name [1] pay-to-address with the *reveal_addr*, not the sender's address. [2] change address with the NAMESPACE_PREORDER sender's address """ outputs = [ # main output { "script_hex": make_op_return_script(data, format=format), "value": 0 }, # register address { "script_hex": make_pay_to_address_script(reveal_addr), "value": DEFAULT_DUST_FEE }, # change address { "script_hex": make_pay_to_address_script(change_addr), "value": calculate_change_amount(inputs, 0, 0) }, ] dust_fee = tx_dust_fee_from_inputs_and_outputs(inputs, outputs) outputs[-1]['value'] = calculate_change_amount(inputs, DEFAULT_DUST_FEE, dust_fee) return outputs
def tx_make_subsidization_output( payer_utxo_inputs, payer_address, op_fee, dust_fee ): """ Given the set of utxo inputs for both the client and payer, as well as the client's desired tx outputs, generate the inputs and outputs that will cause the payer to pay the operation's fees and dust fees. The client should send its own address as an input, with the same amount of BTC as the output. Return the payer output to include in the transaction on success, which should pay for the operation's fee and dust. """ return { "script_hex": make_pay_to_address_script( payer_address ), "value": calculate_change_amount( payer_utxo_inputs, op_fee, dust_fee ) }
def make_outputs( data, inputs, new_name_owner_address, change_address, format='bin' ): """ Builds the outputs for a name transfer operation. """ total_to_send = DEFAULT_OP_RETURN_FEE + DEFAULT_DUST_FEE return [ # main output {"script_hex": make_op_return_script(data, format=format), "value": DEFAULT_OP_RETURN_FEE}, # new name owner output {"script_hex": make_pay_to_address_script(new_name_owner_address), "value": DEFAULT_DUST_FEE}, # change output {"script_hex": make_pay_to_address_script(change_address), "value": calculate_change_amount(inputs, total_to_send, (len(inputs) + 3) * DEFAULT_DUST_FEE)} ]
def make_outputs(data, inputs, recipient_address, sender_address, update_hash_b58, format='bin'): """ Builds the outputs for a name import: * [0] is the OP_RETURN * [1] is the new owner (recipient) * [2] is the update hash * [3] is the change sent to the original owner """ total_to_send = DEFAULT_OP_RETURN_FEE + DEFAULT_DUST_FEE * 3 return [ # main output { "script_hex": make_op_return_script(data, format=format), "value": DEFAULT_OP_RETURN_FEE }, # recipient output { "script_hex": make_pay_to_address_script(recipient_address), "value": DEFAULT_DUST_FEE }, # update hash output { "script_hex": make_pay_to_address_script(update_hash_b58), "value": DEFAULT_DUST_FEE }, # change output { "script_hex": make_pay_to_address_script(sender_address), "value": calculate_change_amount(inputs, total_to_send, (len(inputs) + 4) * DEFAULT_DUST_FEE) } ]
def make_outputs(data, inputs, sender_addr, fee, tx_fee, pay_fee=True): """ Make outputs for a name preorder: [0] OP_RETURN with the name [1] address with the NAME_PREORDER sender's address [2] pay-to-address with the *burn address* with the fee Raise ValueError if there are not enough inputs to make the transaction """ op_fee = max(fee, DEFAULT_DUST_FEE) dust_fee = (len(inputs) + 2) * DEFAULT_DUST_FEE + DEFAULT_OP_RETURN_FEE + tx_fee dust_value = DEFAULT_DUST_FEE bill = 0 if pay_fee: bill = op_fee else: op_fee = 0 bill = 0 dust_fee = 0 return [ # main output { "script_hex": make_op_return_script(str(data), format='hex'), "value": 0 }, # change address (can be subsidy key) { "script_hex": virtualchain.make_payment_script(sender_addr), "value": calculate_change_amount(inputs, bill, dust_fee) }, # burn address { "script_hex": virtualchain.make_payment_script(BLOCKSTACK_BURN_ADDRESS), "value": op_fee } ]
def make_outputs( data, inputs, change_address, tx_fee ): """ Make outputs for an announcement. Raise ValueError if there are not enough inputs to make the transaction """ dust_fee = (len(inputs) + 1) * DEFAULT_DUST_FEE + DEFAULT_OP_RETURN_FEE + tx_fee op_fee = DEFAULT_DUST_FEE dust_value = DEFAULT_DUST_FEE return [ # main output {"script_hex": make_op_return_script(str(data), format='hex'), "value": 0}, # change output {"script_hex": make_pay_to_address_script(change_address), "value": calculate_change_amount(inputs, op_fee, dust_fee)} ]
def make_outputs( data, inputs, change_address, tx_fee ): """ Make outputs for an announcement. Raise ValueError if there are not enough inputs to make the transaction """ dust_fee = (len(inputs) + 1) * DEFAULT_DUST_FEE + DEFAULT_OP_RETURN_FEE + tx_fee op_fee = DEFAULT_DUST_FEE dust_value = DEFAULT_DUST_FEE return [ # main output {"script_hex": make_op_return_script(str(data), format='hex'), "value": 0}, # change output {"script_hex": virtualchain.make_payment_script(change_address), "value": calculate_change_amount(inputs, op_fee, dust_fee)} ]
def make_outputs(data, inputs, new_name_owner_address, change_address, pay_fee=True, format='bin'): """ Builds the outputs for a name transfer operation. """ dust_fee = None op_fee = None dust_value = None if pay_fee: dust_fee = (len(inputs) + 2) * DEFAULT_DUST_FEE + DEFAULT_OP_RETURN_FEE op_fee = DEFAULT_DUST_FEE dust_value = DEFAULT_DUST_FEE bill = op_fee else: dust_fee = 0 op_fee = 0 dust_value = 0 return [ # main output { "script_hex": make_op_return_script(data, format=format), "value": 0 }, # new name owner output { "script_hex": make_pay_to_address_script(new_name_owner_address), "value": dust_value }, # change output { "script_hex": make_pay_to_address_script(change_address), "value": calculate_change_amount(inputs, op_fee, dust_fee) } ]
def make_outputs(data, inputs, new_name_owner_address, change_address, tx_fee=0, pay_fee=True): """ Builds the outputs for a name transfer operation. Raise ValueError if there are not enough inputs to make the transaction """ dust_fee = None op_fee = None dust_value = DEFAULT_DUST_FEE if pay_fee: dust_fee = (len(inputs) + 2) * DEFAULT_DUST_FEE + DEFAULT_OP_RETURN_FEE + tx_fee op_fee = DEFAULT_DUST_FEE else: dust_fee = 0 op_fee = 0 return [ # main output { "script_hex": make_op_return_script(str(data), format='hex'), "value": 0 }, # new name owner output { "script_hex": virtualchain.make_payment_script(new_name_owner_address), "value": dust_value }, # change output { "script_hex": virtualchain.make_payment_script(change_address), "value": calculate_change_amount(inputs, op_fee, dust_fee) } ]
def make_outputs(data, inputs, change_addr, fee, pay_fee=True, format='bin'): """ Make outputs for a namespace preorder: [0] OP_RETURN with the name [1] change address with the NAME_PREORDER sender's address [2] pay-to-address with the *burn address* with the fee """ dust_fee = DEFAULT_OP_RETURN_FEE + (len(inputs) + 2) * DEFAULT_DUST_FEE op_fee = max(fee, DEFAULT_DUST_FEE) dust_value = DEFAULT_DUST_FEE bill = op_fee if not pay_fee: # subsidized dust_fee = 0 op_fee = 0 dust_value = 0 bill = 0 return [ # main output { "script_hex": make_op_return_script(data, format=format), "value": 0 }, # change address { "script_hex": make_pay_to_address_script(change_addr), "value": calculate_change_amount(inputs, bill, dust_fee) }, # burn address { "script_hex": make_pay_to_address_script(BLOCKSTORE_BURN_ADDRESS), "value": op_fee } ]
def tx_make_subsidization_output(payer_utxo_inputs, payer_address, op_fee, dust_fee): """ Given the set of utxo inputs for both the client and payer, as well as the client's desired tx outputs, generate the inputs and outputs that will cause the payer to pay the operation's fees and dust fees. The client should send its own address as an input, with the same amount of BTC as the output. Return the payer output to include in the transaction on success, which should pay for the operation's fee and dust. Raise ValueError it here aren't enough inputs to subsidize """ return { 'script_hex': virtualchain.make_payment_script(payer_address), 'value': calculate_change_amount(payer_utxo_inputs, op_fee, int(round(dust_fee))) }
def make_outputs( data, inputs, change_addr, fee, format='bin' ): """ Make outputs for a name preorder: [0] OP_RETURN with the name [1] change address with the NAME_PREORDER sender's address [2] pay-to-address with the *burn address* with the fee """ total_to_send = DEFAULT_OP_RETURN_FEE + DEFAULT_DUST_FEE + max(fee, DEFAULT_DUST_FEE) return [ # main output {"script_hex": make_op_return_script(data, format=format), "value": DEFAULT_OP_RETURN_FEE}, # change address {"script_hex": make_pay_to_address_script(change_addr), "value": calculate_change_amount(inputs, total_to_send, (len(inputs) + 3) * DEFAULT_DUST_FEE)}, # burn address {"script_hex": make_pay_to_address_script(BLOCKSTORE_BURN_ADDRESS), "value": max(fee, DEFAULT_DUST_FEE)} ]
def make_outputs( data, inputs, reveal_addr, change_addr, format='bin', testset=False ): """ Make outputs for a register: [0] OP_RETURN with the name [1] pay-to-address with the *reveal_addr*, not the sender's address. [2] change address with the NAMESPACE_PREORDER sender's address """ total_to_send = DEFAULT_OP_RETURN_FEE + DEFAULT_DUST_FEE return [ # main output {"script_hex": make_op_return_script(data, format=format), "value": 0}, # register address {"script_hex": make_pay_to_address_script(reveal_addr), "value": DEFAULT_DUST_FEE}, # change address {"script_hex": make_pay_to_address_script(change_addr), "value": calculate_change_amount(inputs, total_to_send, DEFAULT_DUST_FEE * (len(inputs) + 3))}, ]
def make_outputs( data, inputs, reveal_addr, change_addr, format='bin', testset=False ): """ Make outputs for a register: [0] OP_RETURN with the name [1] pay-to-address with the *reveal_addr*, not the sender's address. [2] change address with the NAMESPACE_PREORDER sender's address """ total_to_send = DEFAULT_OP_RETURN_FEE + DEFAULT_DUST_FEE return [ # main output {"script_hex": make_op_return_script(data, format=format), "value": DEFAULT_OP_RETURN_FEE}, # register address {"script_hex": make_pay_to_address_script(reveal_addr), "value": DEFAULT_DUST_FEE}, # change address {"script_hex": make_pay_to_address_script(change_addr), "value": calculate_change_amount(inputs, total_to_send, DEFAULT_DUST_FEE * (len(inputs) + 3))}, ]
def make_outputs( data, inputs, reveal_addr, change_addr, tx_fee): """ Make outputs for a register: [0] OP_RETURN with the name [1] pay-to-address with the *reveal_addr*, not the sender's address. [2] change address with the NAMESPACE_PREORDER sender's address Raise ValueError if there are not enough inputs to make the transaction """ total_to_send = DEFAULT_OP_RETURN_FEE + DEFAULT_DUST_FEE return [ # main output {"script_hex": make_op_return_script(str(data), format='hex'), "value": 0}, # register address {"script_hex": make_pay_to_address_script(reveal_addr), "value": DEFAULT_DUST_FEE}, # change address {"script_hex": make_pay_to_address_script(change_addr), "value": calculate_change_amount(inputs, total_to_send, DEFAULT_DUST_FEE * (len(inputs) + 3)) + tx_fee}, ]
def make_outputs(data, inputs, register_addr, change_addr, renewal_fee=None, pay_fee=True, format='bin'): """ Make outputs for a register: [0] OP_RETURN with the name [1] pay-to-address with the *register_addr*, not the sender's address. [2] change address with the NAME_PREORDER sender's address [3] (OPTIONAL) renewal fee, sent to the burn address """ dust_fee = None dust_value = None op_fee = None bill = None if pay_fee: # sender pays if renewal_fee is not None: # renewing dust_fee = (len(inputs) + 3) * DEFAULT_DUST_FEE + DEFAULT_OP_RETURN_FEE dust_value = DEFAULT_DUST_FEE op_fee = max(renewal_fee, DEFAULT_DUST_FEE) bill = op_fee else: # registering dust_fee = (len(inputs) + 2) * DEFAULT_DUST_FEE + DEFAULT_OP_RETURN_FEE dust_value = DEFAULT_DUST_FEE op_fee = 0 bill = 0 else: # subsidized by another address if renewal_fee is not None: # renewing dust_fee = 0 dust_value = 0 op_fee = max(renewal_fee, DEFAULT_DUST_FEE) bill = 0 else: # registering dust_fee = 0 dust_value = 0 op_fee = 0 bill = 0 outputs = [ # main output { "script_hex": make_op_return_script(data, format=format), "value": 0 }, # register address { "script_hex": make_pay_to_address_script(register_addr), "value": dust_value }, # change address { "script_hex": make_pay_to_address_script(change_addr), "value": calculate_change_amount(inputs, bill, dust_fee) }, ] if renewal_fee is not None: outputs.append( # burn address (when renewing) { "script_hex": make_pay_to_address_script(BLOCKSTORE_BURN_ADDRESS), "value": op_fee }) return outputs
def make_outputs(data, change_inputs, register_addr, change_addr, tx_fee, renewal_fee=None, pay_fee=True): """ Make outputs for a register: [0] OP_RETURN with the name [1] pay-to-address with the *register_addr*, not the sender's address. [2] change address with the NAME_PREORDER sender's address [3] (OPTIONAL) renewal fee, sent to the burn address Raise ValueError if there are not enough inputs to make the transaction """ dust_fee = None dust_value = DEFAULT_DUST_FEE op_fee = None bill = None if pay_fee: # sender pays if renewal_fee is not None: # renewing dust_fee = (len(change_inputs) + 3) * DEFAULT_DUST_FEE + DEFAULT_OP_RETURN_FEE + tx_fee op_fee = max(renewal_fee, DEFAULT_DUST_FEE) bill = op_fee else: # registering dust_fee = (len(change_inputs) + 2) * DEFAULT_DUST_FEE + DEFAULT_OP_RETURN_FEE + tx_fee op_fee = 0 bill = DEFAULT_DUST_FEE * 2 else: # subsidized by another address if renewal_fee is not None: # renewing dust_fee = 0 op_fee = max(renewal_fee, DEFAULT_DUST_FEE) bill = 0 else: # registering dust_fee = 0 op_fee = 0 bill = 0 outputs = [ # main output { "script_hex": make_op_return_script(str(data), format='hex'), "value": 0 }, # register address { "script_hex": virtualchain.make_payment_script(register_addr), "value": dust_value }, # change address (can be the subsidy address) { "script_hex": virtualchain.make_payment_script(change_addr), "value": calculate_change_amount(change_inputs, bill, dust_fee) }, ] if renewal_fee is not None: outputs.append( # burn address (when renewing) { "script_hex": virtualchain.make_payment_script(BLOCKSTACK_BURN_ADDRESS), "value": op_fee }) return outputs
def make_outputs(data, change_inputs, register_addr, change_addr, renewal_fee=None, pay_fee=True, format="bin"): """ Make outputs for a register: [0] OP_RETURN with the name [1] pay-to-address with the *register_addr*, not the sender's address. [2] change address with the NAME_PREORDER sender's address [3] (OPTIONAL) renewal fee, sent to the burn address """ dust_fee = None dust_value = None op_fee = None bill = None if pay_fee: # sender pays if renewal_fee is not None: # renewing dust_fee = (len(change_inputs) + 3) * DEFAULT_DUST_FEE + DEFAULT_OP_RETURN_FEE dust_value = DEFAULT_DUST_FEE op_fee = max(renewal_fee, DEFAULT_DUST_FEE) bill = op_fee else: # registering dust_fee = (len(change_inputs) + 2) * DEFAULT_DUST_FEE + DEFAULT_OP_RETURN_FEE dust_value = DEFAULT_DUST_FEE op_fee = 0 bill = DEFAULT_DUST_FEE * 2 else: # subsidized by another address if renewal_fee is not None: # renewing dust_fee = 0 dust_value = 0 op_fee = max(renewal_fee, DEFAULT_DUST_FEE) bill = 0 else: # registering dust_fee = 0 dust_value = 0 op_fee = 0 bill = 0 outputs = [ # main output {"script_hex": make_op_return_script(data, format=format), "value": 0}, # register address {"script_hex": make_pay_to_address_script(register_addr), "value": dust_fee}, # change address (can be the subsidy address) { "script_hex": make_pay_to_address_script(change_addr), "value": calculate_change_amount(change_inputs, bill, dust_fee), }, ] if renewal_fee is not None: outputs.append( # burn address (when renewing) {"script_hex": make_pay_to_address_script(BLOCKSTORE_BURN_ADDRESS), "value": op_fee} ) return outputs