Wallet Contract
Properties
If an invitation has been created, save it here
Returns the currently active destination. null if the contract is not ready to provide a destination
This is the contract type as specified in contractTypes. Contracts are deserialized according to this type so if a new version of the contract has an incompatible deserialization it should use a different contract type via the convention contractName_major.minor.release.bugfix, e.g. multisig_1.2.3.4
Functions
For interactive contracts, join based on the provided invitation
Balance of ungrouped Nexa held in this contract.
Find inputs in this wallet to use in a new transaction. This does NOT mark them as used, so cannot be called repeatedly until consumeInputs is called. Inputs are already filtered by members of this contract. If the provided filter is null, only ungrouped UTXOs are selected.
Contract UTXO (unspent transaction output) iterator. Visits each unspent transaction output. Return true ("I found it") from your callback to stop the iteration early, false ("not what I wanted") to continue with the next UTXO. Contracts should implement this so that the wallet's transaction completion tools can be used to build transactions for this contract.
This is called by the wallet when it processes incoming transactions. It notifies this contract of a transaction that could be interesting to it. This may provide every transaction interesting to the wallet. Contracts should do further filtering. Note that this callback may modify the txh object or any child objects, and set txh.dirty to store information in the Wallet databases.
Load contract information from the wallet DB.
For interactive contracts, make an invitation for others to join
This is called by the wallet when it processes incoming transactions. It notifies this contract of a UTXO that it might be able to spend. The wallet may provide every spendable it sees so the contract MUST filter for spendables that it really can spend. In particular, the contract should set the contractId field of outputs to "claim" them as unspendable as "normal" coins (if they are unspendable), since the "contractId" is used in UTXO filtering. The destination installed by the contract also "knows" how to spend coins. So a contract wants to "claim" a utxo if it is not automatically spendable or if the contract wants to isolate their spending. For example, a "time vault or early multisig access" contract could set the contractId, to prevent automatic spending. It would then clear it when the time has passed. But before the time passed, the contract could access its own marked-by-contractId UTXOs and execute the multisig protocol to spend them
Move to the next destination
Store contract information to the wallet DB. Note that this contract does not have to store its Txos or transactions, that is done automatically as part of the main wallet
Return an object of the expected Wallet Contract Interface