WalletContract

Properties

Link copied to clipboard
abstract val account: Wallet?
Link copied to clipboard

If an invitation has been created, save it here

Link copied to clipboard
Link copied to clipboard

Returns the currently active destination. null if the contract is not ready to provide a destination

Link copied to clipboard
abstract val name: String

Name the contract something. You can only have 1 contract of a particular name in your Wallet. Used as the contractId by default

Link copied to clipboard
abstract val type: String

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

Link copied to clipboard
open val wallet: Wallet?

Functions

Link copied to clipboard

For interactive contracts, join based on the provided invitation

Link copied to clipboard
abstract fun balance(): Map<GroupId, Balance>

Gets the contract-encumbered balance of this contract, calculated by iterating through contract UTXOs. The returned map always has at least one entry: nativeGroupId(Chainselector) tracking the native coin (i.e. Nexa), even if the balance is 0.

Link copied to clipboard
open fun coinBalance(): Balance?

Balance of ungrouped Nexa held in this contract.

Link copied to clipboard
abstract fun filterInputs(minAmt: Long, minConfirms: Int = 0, filter: (Spendable) -> Long? = null): MutableList<Spendable>

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.

Link copied to clipboard
abstract fun forEachUtxo(doit: (Spendable) -> Boolean)

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.

Link copied to clipboard

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.

Link copied to clipboard
abstract fun load(db: WalletDatabase)

Load contract information from the wallet DB.

Link copied to clipboard

For interactive contracts, make an invitation for others to join

Link copied to clipboard

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

Link copied to clipboard
abstract fun nextDestination(): Boolean

Move to the next destination

Link copied to clipboard
abstract fun save(db: WalletDatabase)

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

Link copied to clipboard
abstract fun send(vararg dests: iTxOutput, minConfirms: Int = 0, title: String? = null, data: ByteArray? = null): iTransaction
open fun send(amount: Long, address: String, minConfirms: Int = 0, title: String? = null, data: ByteArray? = null): iTransaction
open fun send(amount: Long, address: PayAddress, minConfirms: Int = 0, title: String? = null, data: ByteArray? = null): iTransaction
Link copied to clipboard
abstract fun ui(c: KClass<*>): Any?

Get a UI for this wallet contract. Currently you can only ask for a TextUI

Link copied to clipboard
inline fun <T> WalletContract.ui(): T?

Return an object of the expected Wallet Contract Interface