Manage Witnet UTXOs
Efficiently manage UTXOs in Witnet with the Witnet SDK.
Last updated
Was this helpful?
Efficiently manage UTXOs in Witnet with the Witnet SDK.
Last updated
Was this helpful?
The code examples below assume that the environment is properly set up as described in . You can easily adapt the examples to pass the URL of the Wit/RPC provider to use, and/or the wallet master key (and the password, if encrypted).
Transactions in Witnet get paid by signing Unspent Transaction Outputs (or UTXOs), pretty much the same as transactions in Bitcoin. And just like Bitcoin, UTXOs in Witnet can be time-locked. Time-locked UTXOs cannot be spent until the time-lock timestamp is reached.
Aside from UTXOs, Witnet addresses may also hold rights to withdraw delegated stake from network validators. Delegated stake can be withdrawn into UTXOs by means of Unstake Transactions (aka. Stake Withdrawal Transactions). Withdrawn UTXOs get time-locked for a minimum of two weeks.
The balance of any Witnet address is therefore divided in three different fields:
locked
Sum of all time-locked UTXOs, in nanowits. Cannot be spent at this moment.
staked
Funds currently staked into one or more validators, in nanowits. Delegated stake can be eventually withdrawn. Once withdrawn, deposits will remain time-locked for at least two weeks.
unlocked
Sum of currently unlocked UTXOs, in nanowits.
Different strategies are possible when selecting input UTXOs as for covering some target value:
"big-first"
Higher value UTXOs are selected first, until target value is covered.
"random"
UTXOs are selected randomly, until target value is covered.
"slim-fit"
The smallest of all UTXOs that individually covers target value is selected. If none fulfills this condition, UTXOs get then selected by following the BigFirst
strategy.
"small-first"
Smaller value UTXOs are selected first, until target value is covered.
Joining multiple spendable UTXOs of a wallet into a single UTXO of some specific value is possible by creating a Value Transfer Transaction (or VTT) where all inputs correspond to the spendable UTXOs that are to be joined. The sum of all input UTXOs will then be available as a single UTXO to the recipient of such VTT.
Splitting spendable funds into multiple smaller UTXOs enables automation scripts and bots to eventually handle concurrent data request transactions signed from one specific address.