UTXO Management Contract

utxomng.xsat

Actions

  • Initialize configuration

  • Add UTXO

  • Delete UTXO

  • Add block header

  • Delete block header

  • Parse UTXO

Quickstart

# init @utxomng.xsat
$ cleos push action utxo.xsat init '{"height": 840000, "hash": "0000000000000000000320283a032748cef8227873ff4872689bf23f1cda83a5", "cumulative_work": "0.00000020 BTC"}' -p utxomng.xsat

# config @utxomng.xsat
$ cleos push action utxo.xsat config '{"parse_timeout_seconds": 600, "num_validators_per_distribution": 100, "retained_spent_utxo_blocks": 5000, "num_retain_data_blocks": 100, "num_merkle_layer": 10, "num_miner_priority_blocks": 10}' -p utxomng.xsat

# addutxo @utxomng.xsat
$ cleos push action utxo.xsat addutxo '{"id": 1, "txid": "76a914536ffa992491508dca0354e52f32a3a7a679a53a88ac", "index": 1, "to": "18cBEMRxXHqzWWCxZNtU91F5sbUNKhL5PX", "value": 4075061499}' -p utxomng.xsat

# delutxo @utxomng.xsat
$ cleos push action utxo.xsat delutxo '{"id": 1}' -p utxomng.xsat

# addblock @utxomng.xsat
$ cleos push action utxo.xsat addblock '{"height":839999,"hash":"000000000000000003e251c7387c2cd5aeac480327a234ec11c9b8382455db0d","cumulative_work":"0000000000000000000000000000000000000000002fa415a1793f473a706960","version":536870912,"previous_block_hash":"000000000000000003e6820666f1a47c7771f18b03f9d24c2896a3d7356a5e3c","merkle":"da1dcebe6d631251a31969b7ed6ba55258d113be3e7ef3ef3343d8f7fc9c1702","timestamp":1479777318,"bits":386089497,"nonce":2635095261}' -p utxomng.xsat

# delblock @utxomng.xsat
$ cleos push action utxo.xsat delblock '{"height":839999}' -p utxomng.xsat

# processblock @alice
$ cleos push action utxo.xsat processblock '{"synchronizer": "alice", "height": 840000, "hash": "0000000000000000000320283a032748cef8227873ff4872689bf23f1cda83a5", "process_rows":1024, "nonce": 1}' -p utxomng.xsat

Table Information

ENUM parsing_status

STRUCT parsing_progress_row

params

  • {uint64_t} bucket_id - the bucket_id currently being parsed

  • {uint64_t} num_transactions - the number of transactions currently parsing the block

  • {uint64_t} parsed_transactions - number of transactions currently resolved

  • {uint64_t} parsed_position - the position of the currently parsed block

  • {uint64_t} parsed_vin - the current transaction has been resolved to the vin index

  • {uint64_t} parsed_vout - the current transaction has been resolved to the vout index

  • {name} parser - the account number of the parsing block

  • {time_point_sec} parsed_expiration_time - timeout for parsing chunks

example

TABLE chainstate

scope

utxomng.xsat

params

  • {uint64_t} num_utxos - total number of UTXOs

  • {uint64_t} head_height - header block height for consensus success

  • {uint64_t} irreversible_height - irreversible block height

  • {uint64_t} irreversible_hash - irreversible block hash

  • {uint64_t} migrating_height - block height in migration

  • {uint64_t} migrating_hash - block hash in migration

  • {uint64_t} migrating_num_utxos - the total number of UTXOs in the migration

  • {uint64_t} migrated_num_utxos - number of UTXOs that have been migrated

  • {uint32_t} num_provider_validators - the number of validators that have endorsed the current parsed block

  • {uint32_t} num_validators_assigned - the number of validators that have been allocated rewards

  • {name} miner - block miner account

  • {name} synchronizer - block synchronizer account

  • {name} parser - the account number of the parsing block

  • {uint64_t} parsed_height - parsed block height

  • {uint64_t} parsing_height - the current height being parsed

  • {map<checksum256, parsing_progress_row>} parsing_progress_of - parsing progress @see parsing_progress_row

  • {uint8_t} status - parsing status @see parsing_status

example

TABLE config

scope

utxomng.xsat

params

  • {uint16_t} parse_timeout_seconds - parsing timeout duration

  • {uint16_t} num_validators_per_distribution - number of endorsing users each time rewards are distributed

  • {uint16_t} num_retain_data_blocks - number of blocks to retain data

  • {uint16_t} retained_spent_utxo_blocks - number of blocks to retained spent utxo

  • {uint16_t} num_txs_per_verification - the number of tx for each verification (2^n)

  • {uint8_t} num_merkle_layer - verify the number of merkle levels (log(num_txs_per_verification))

  • {uint16_t} num_miner_priority_blocks - miners who produce blocks give priority to verifying the number of blocks

example

TABLE utxos

scope

utxomng.xsat

params

  • {uint64_t} id - primary key

  • {checksum256} txid - transaction id

  • {uint32_t} index - vout index

  • {std::vector<uint8_t>} scriptpubkey - vout's script public key

  • {uint32_t} value - utxo quantity

example

TABLE pendingutxos

scope

utxomng.xsat

params

  • {uint64_t} id - primary key

  • {uint64_t} height - block height

  • {checksum256} hash - block hash

  • {checksum256} txid - transaction id

  • {uint32_t} index - vout index

  • {std::vector<uint8_t>} scriptpubkey - script public key

  • {uint32_t} value - utxo quantity

  • {name} type - utxo type (vin or vout)

example

TABLE spentutxos

scope

utxomng.xsat

params

  • {uint64_t} id - primary key

  • {uint64_t} height - block height

  • {checksum256} txid - transaction id

  • {uint32_t} index - vout index

  • {std::vector<uint8_t>} scriptpubkey - script public key

  • {uint32_t} value - utxo quantity

example

TABLE blocks

scope

utxomng.xsat

params

  • {uint64_t} height - block height

  • {checksum256} hash - block hash

  • {checksum256} cumulative_work - the cumulative workload of the block

  • {uint32_t} version - block version

  • {checksum256} previous_block_hash - hash in internal byte order of the previous block’s header

  • {checksum256} merkle - the merkle root is derived from the hashes of all transactions included in this block

  • {uint32_t} timestamp - the block time is a Unix epoch time

  • {uint32_t} bits - an encoded version of the target threshold this block’s header hash must be less than or equal to

  • {uint32_t} nonce - an arbitrary number miners change to modify the header hash in order to produce a hash less than or

example

TABLE block.extra

scope

utxomng.xsat

params

  • {uint64_t} height - block height

  • {uint64_t} bucket_id - the associated bucket number is used to obtain block data

example

TABLE consensusblk

scope

utxomng.xsat

params

  • {uint64_t} bucket_id - the associated bucket number is used to obtain block data

  • {uint64_t} height - block height

  • {checksum256} hash - block hash

  • {checksum256} cumulative_work - the cumulative workload of the block

  • {uint32_t} version - block version

  • {checksum256} previous_block_hash - hash in internal byte order of the previous block’s header

  • {checksum256} merkle - the merkle root is derived from the hashes of all transactions included in this block

  • {uint32_t} timestamp - the block time is a Unix epoch time

  • {uint32_t} bits - an encoded version of the target threshold this block’s header hash must be less than or equal to

  • {uint32_t} nonce - an arbitrary number miners change to modify the header hash in order to produce a hash less than or

  • {name} miner - block miner account

  • {name} synchronizer - block synchronizer account

  • {name} parser - the last parser of the parsing block

  • {uint64_t} num_utxos - the total number of vin and vout of the block

  • {bool} parse - is it an parsed block

  • {bool} irreversible - is it an irreversible block

  • {time_point_sec} created_at - created at time

example

STRUCT process_block_result

params

  • {string} status - current parsing status (waiting, migrating, deleting_data, distributing_rewards, parsing, parsing_completed)

  • {uint64_t} height - block height

  • {checksum256} block_hash - block hash

example

ACTION init

  • authority: utxomng.xsat

Initialize block information to start parsing.

params

  • {uint64_t} height - block height

  • {checksum256} hash - block hash

  • {checksum256} cumulative_work - the cumulative workload of the block

example

ACTION config

  • authority: utxomng.xsat

Setting parameters.

params

  • {uint16_t} parse_timeout_seconds - parsing timeout duration

  • {uint16_t} num_validators_per_distribution - number of endorsing users each time rewards are distributed

  • {uint16_t} retained_spent_utxo_blocks - number of blocks to retain utxo

  • {uint16_t} num_retain_data_blocks - number of blocks to retain data

  • {uint8_t} num_merkle_layer - verify the number of merkle levels (log(num_txs_per_verification))

  • {uint16_t} num_miner_priority_blocks - miners who produce blocks give priority to verifying the number of blocks

example

ACTION addutxo

  • authority: utxomng.xsat

Add utxo data.

params

  • {uint64_t} id - primary id

  • {checksum256} txid - transaction id

  • {uint32_t} index - vout index

  • {vector<uint8_t>} scriptpubkey - script public key

  • {uint64_t} value - utxo quantity

example

ACTION delutxo

  • authority: utxomng.xsat

Delete utxo data.

params

  • {uint64_t} id - utxo id

example

ACTION addblock

  • authority: utxomng.xsat

Add history block header.

params

  • {uint64_t} height - block height

  • {checksum256} hash - block hash

  • {checksum256} cumulative_work - the cumulative workload of the block

  • {uint32_t} version - block version

  • {checksum256} previous_block_hash - hash in internal byte order of the previous block’s header

  • {checksum256} merkle - the merkle root is derived from the hashes of all transactions included in this block

  • {uint32_t} timestamp - the block time is a Unix epoch time

  • {uint32_t} bits - an encoded version of the target threshold this block’s header hash must be less than or equal to

  • {uint32_t} nonce - an arbitrary number miners change to modify the header hash in order to produce a hash less than or

example

ACTION delblock

  • authority: utxomng.xsat

Delete block header.

params

  • {uint64_t} height - block height

example

ACTION delspentutxo

  • authority: utxomng.xsat

Delete spent utxo.

params

  • {uint64_t} row - number of rows to delete utxo

  • {uint64_t} nonce - unique value for each call to prevent duplicate transactions

example

ACTION delblockdata

  • authority: utxomng.xsat

Delete block data.

params

  • {uint64_t} row - number of rows of block data to delete

  • {uint64_t} nonce - unique value for each call to prevent duplicate transactions

example

ACTION processblock

  • authority: synchronizer

Parse utxo

params

  • {name} synchronizer - synchronizer account

  • {uint64_t} process_rows - number of vins and vouts to be parsed

  • {uint64_t} nonce - unique value for each call to prevent duplicate transactions

example

ACTION consensus

  • authority: blksync.xsat or blkendt.xsat

Reach consensus logic

params

  • {uint64_t} height - block height

  • {checksum256} hash - block hash

example

Last updated