Skip to content

Latest commit

 

History

History
556 lines (247 loc) · 16.4 KB

utxo.md

File metadata and controls

556 lines (247 loc) · 16.4 KB

Module 0x4::utxo

Resource UTXO

The UTXO Object

struct UTXO has key

Struct UTXOSeal

struct UTXOSeal has copy, drop, store

Struct SealOut

struct SealOut has copy, drop, store

Struct SpendUTXOEvent

Event emitted when a UTXO is spent In the Bitcoin UTXO model, there's no inherent concept of sender and receiver. However, for simplifying payment scenarios, we define sender and receiver as follows:

  • Sender: The address of the first input UTXO that can be identified
  • Receiver: The address of each output UTXO that can be identified
struct SpendUTXOEvent has copy, drop, store

Struct ReceiveUTXOEvent

Event emitted when a UTXO is received In the Bitcoin UTXO model, there's no inherent concept of sender and receiver. However, for simplifying payment scenarios, we define sender and receiver as follows:

  • Sender: The address of the first input UTXO that can be identified
  • Receiver: The address of each output UTXO that can be identified
struct ReceiveUTXOEvent has copy, drop, store

Struct TempStateDropEvent

Event emitted when the temporary state of a UTXO is dropped The temporary state is dropped when the UTXO is spent The event is onchain event, and the event_queue name is type_name of the temporary state

struct TempStateDropEvent has copy, drop, store

Resource BitcoinUTXOStore

struct BitcoinUTXOStore has key

Constants

const ErrorDeprecatedFunction: u64 = 1;

const TEMPORARY_AREA: vector<u8> = [116, 101, 109, 112, 111, 114, 97, 114, 121, 95, 97, 114, 101, 97];

Function genesis_init

public(friend) fun genesis_init()

Function borrow_utxo_store

Function borrow_mut_utxo_store

Function new

public(friend) fun new(txid: address, vout: u32, value: u64): object::Object<utxo::UTXO>

Function mock_utxo

public(friend) fun mock_utxo(outpoint: types::OutPoint, value: u64): utxo::UTXO

Function derive_utxo_id

Function value

Get the UTXO's value

public fun value(utxo: &utxo::UTXO): u64

Function txid

Get the UTXO's txid

public fun txid(utxo: &utxo::UTXO): address

Function vout

Get the UTXO's vout

public fun vout(utxo: &utxo::UTXO): u32

Function exists_utxo

public fun exists_utxo(outpoint: types::OutPoint): bool

Function borrow_utxo

Function borrow_mut_utxo

public(friend) fun borrow_mut_utxo(outpoint: types::OutPoint): &mut object::Object<utxo::UTXO>

Function has_seal

public fun has_seal<T>(utxo: &utxo::UTXO): bool

Function has_seal_internal

public(friend) fun has_seal_internal(utxo: &utxo::UTXO, protocol: &string::String): bool

Function get_seals

Function remove_seals_internal

Function add_seal_internal

public(friend) fun add_seal_internal(utxo: &mut utxo::UTXO, utxo_seal: utxo::UTXOSeal)

Function transfer

public(friend) fun transfer(utxo_obj: object::Object<utxo::UTXO>, sender: option::Option<address>, receiver: address)

Function take

public(friend) fun take(object_id: object::ObjectID): object::Object<utxo::UTXO>

Function remove

public(friend) fun remove(utxo_obj: object::Object<utxo::UTXO>): utxo::UTXO

Function drop

public(friend) fun drop(utxo: utxo::UTXO)

Function new_utxo_seal

public(friend) fun new_utxo_seal(protocol: string::String, seal_object_id: object::ObjectID): utxo::UTXOSeal

Function unpack_utxo_seal

Function new_seal_out

public(friend) fun new_seal_out(vout: u32, seal: utxo::UTXOSeal): utxo::SealOut

Function unpack_seal_out

public(friend) fun unpack_seal_out(seal_out: utxo::SealOut): (u32, utxo::UTXOSeal)

Function add_temp_state

#[private_generics(#[S])]
public fun add_temp_state<S: drop, store>(utxo: &mut object::Object<utxo::UTXO>, state: S)

Function contains_temp_state

public fun contains_temp_state<S: drop, store>(utxo: &object::Object<utxo::UTXO>): bool

Function borrow_temp_state

public fun borrow_temp_state<S: drop, store>(utxo: &object::Object<utxo::UTXO>): &S

Function borrow_mut_temp_state

#[private_generics(#[S])]
public fun borrow_mut_temp_state<S: drop, store>(utxo: &mut object::Object<utxo::UTXO>): &mut S

Function remove_temp_state

#[private_generics(#[S])]
public fun remove_temp_state<S: drop, store>(utxo: &mut object::Object<utxo::UTXO>): S

Function check_utxo_input

public(friend) fun check_utxo_input(): bool

Function unpack_spend_utxo_event

public fun unpack_spend_utxo_event(event: utxo::SpendUTXOEvent): (address, address, option::Option<address>, u64)

Function unpack_receive_utxo_event

public fun unpack_receive_utxo_event(event: utxo::ReceiveUTXOEvent): (address, option::Option<address>, address, u64)

Function unpack_temp_state_drop_event