def test_static_output(): outpoint = OutPoint.from_bytes(get_random_bytes(34)) txout = TxOut(get_random_int(8), Script(get_random_bytes(30))) descriptor = SpendableOutputDescriptor.static_output(outpoint, txout) assert isinstance( descriptor, SpendableOutputDescriptor) and descriptor.type == "StaticOutput"
def get_utxo(self, genesis_hash, short_channel_id): if genesis_hash == BlockHash(bytes(32)): raise UnknownChain() if short_channel_id % 2: raise UnknownTx() value = pow(2, 64) - 15 script_pubkey = Script(get_random_bytes(80)) return TxOut(value, script_pubkey)
def test_spendable_outputs_getters(): outpoint = OutPoint.from_bytes(get_random_bytes(34)) output = TxOut(get_random_int(8), Script(get_random_bytes(50))) descriptor = SpendableOutputDescriptor.static_output(outpoint, output) event = Event.spendable_outputs([descriptor]) for local_output, binded_output in zip(event.outputs, [descriptor]): assert local_output.type == binded_output.type assert local_output.outpoint == binded_output.outpoint assert local_output.output == binded_output.output
def test_static_output_counterparty_payment(): outpoint = OutPoint.from_bytes(get_random_bytes(34)) txout = TxOut(get_random_int(8), Script(get_random_bytes(30))) key_derivation_params = (get_random_int(8), get_random_int(8)) descriptor = SpendableOutputDescriptor.static_output_counterparty_payment( outpoint, txout, key_derivation_params) assert isinstance( descriptor, SpendableOutputDescriptor ) and descriptor.type == "StaticOutputCounterpartyPayment"
def test_static_output_getters(): outpoint = OutPoint.from_bytes(get_random_bytes(34)) txout = TxOut(get_random_int(8), Script(get_random_bytes(30))) descriptor = SpendableOutputDescriptor.static_output(outpoint, txout) assert descriptor.outpoint == outpoint assert descriptor.output == txout # Check no other getters are available local_attributes = ["outpoint", "output"] check_not_available_getters(descriptor, local_attributes, all_attributes)
def test_dynamic_output_pwsh(): outpoint = OutPoint.from_bytes(get_random_bytes(34)) per_commitment_point = PublicKey(get_random_pk_bytes()) to_self_delay = 20 txout = TxOut(get_random_int(8), Script(get_random_bytes(30))) key_derivation_params = (get_random_int(8), get_random_int(8)) revocation_pubkey = PublicKey(get_random_pk_bytes()) descriptor = SpendableOutputDescriptor.dynamic_output_pwsh( outpoint, per_commitment_point, to_self_delay, txout, key_derivation_params, revocation_pubkey) assert isinstance( descriptor, SpendableOutputDescriptor) and descriptor.type == "DynamicOutputP2WSH"
def test_static_output_counterparty_payment_getters(): outpoint = OutPoint.from_bytes(get_random_bytes(34)) txout = TxOut(get_random_int(8), Script(get_random_bytes(30))) key_derivation_params = (get_random_int(8), get_random_int(8)) descriptor = SpendableOutputDescriptor.static_output_counterparty_payment( outpoint, txout, key_derivation_params) assert descriptor.outpoint == outpoint assert descriptor.output == txout assert descriptor.key_derivation_params == key_derivation_params # Check no other getters are available local_attributes = ["outpoint", "output", "key_derivation_params"] check_not_available_getters(descriptor, local_attributes, all_attributes)
def test_dynamic_output_pwsh_getters(): outpoint = OutPoint.from_bytes(get_random_bytes(34)) per_commitment_point = PublicKey(get_random_pk_bytes()) to_self_delay = 20 txout = TxOut(get_random_int(8), Script(get_random_bytes(30))) key_derivation_params = (get_random_int(8), get_random_int(8)) revocation_pubkey = PublicKey(get_random_pk_bytes()) descriptor = SpendableOutputDescriptor.dynamic_output_pwsh( outpoint, per_commitment_point, to_self_delay, txout, key_derivation_params, revocation_pubkey) assert descriptor.outpoint == outpoint assert descriptor.per_commitment_point == per_commitment_point assert descriptor.to_self_delay == to_self_delay assert descriptor.output == txout assert descriptor.key_derivation_params == key_derivation_params assert descriptor.revocation_pubkey == revocation_pubkey
def test_spendable_outputs(): outpoint = OutPoint.from_bytes(get_random_bytes(34)) output = TxOut(get_random_int(8), Script(get_random_bytes(50))) descriptor = SpendableOutputDescriptor.static_output(outpoint, output) event = Event.spendable_outputs([descriptor]) assert isinstance(event, Event) and event.type == "SpendableOutputs"