Bip44Wallet

class Bip44Wallet(val name: String, val chainSelector: ChainSelector, var wdb: WalletDatabase) : CommonWallet

This wallet uses a single piece of random data, deriving new private keys and addresses using the technique described in BIP-0032 with key derivation paths specified by BIP-043 and BIP-044. In essence, key derivation is: m/'/'/'//index

Constructors

Link copied to clipboard
constructor(wdb: WalletDatabase, wd: Bip44WalletData)

Load an existing wallet

constructor(wdb: WalletDatabase, name: String)

Load an existing wallet

constructor(wdb: WalletDatabase, name: String, chainSelector: ChainSelector, wop: WalletStartup)

Create a new wallet with a random secret

constructor(wdb: WalletDatabase, name: String, chainSelector: ChainSelector, secretWordList: String, maxAddr: Int = -1)

Create a new wallet given secret words

constructor(name: String, chainSelector: ChainSelector, wdb: WalletDatabase)

Types

Link copied to clipboard
object Companion
Link copied to clipboard
data class HdDerivationPath(val secret: Secret?, val purpose: Long, val coinType: Long, val account: Long, val change: Boolean, var index: Int)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Get a set of every address in this wallet

Link copied to clipboard

Control whether saving the wallet to underlying storage is automatic (true, default), or initiated by API calls. Wallet performance could improve if automaticFlush is false and the wallet is saved rarely. However state may be lost!

Link copied to clipboard
open override val balance: Long
Link copied to clipboard
open override val balanceConfirmed: Long
Link copied to clipboard
open override val balanceUnconfirmed: Long
Link copied to clipboard
open override val blockchain: Blockchain

This wallet finds its coins on this blockchain

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

After startup, chainstate should always be set. It connects this wallet to a particular location in the blockchain

Link copied to clipboard

Used to encrypt/decrypt wallet secrets. NOT SAVED, erased after some time. Change the value INSIDE the encryptionKey object whenever the wallet is locked or unlocked. Changing encryptionKey itself is used to change the wallet secret. It detaches all old SecuredSecrets from this wallet, but keeps them viable (if the contents is not null). So you can simultaneously access old SecuredSecrets while making new Secured and Unsecured Secrets. Keep the wallet lock and don't save until this process is complete, so that you don't have new and old SecuredSecrets both written to the DB.

Link copied to clipboard

Used to verify that the provided encryption key is correct. Saved.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
var historicalPrice: (String, Long) -> BigDecimal?

Give this wallet access to the historical price (epoch seconds) of its token in the provided fiat currency code.

Link copied to clipboard
Link copied to clipboard
open override val isDeleted: Boolean

True if this wallet is deleted

Link copied to clipboard

when was this wallet last saved

Link copied to clipboard
Link copied to clipboard

No addresses have be calculated beyond this index

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override val name: String

Any name you may want to call this wallet

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override var pause: Boolean

Pause blockchain processing if true

Link copied to clipboard
Link copied to clipboard

transactions that this wallet has generated that have not yet been confirmed

Link copied to clipboard
Link copied to clipboard
var processingThread: iThread?

Thread that handles keeping wallet synced

Link copied to clipboard

Get the 12 word recovery secret phrase. If the wallet is encrypted and locked, an exception is thrown.

Link copied to clipboard

This variable captures HD derivation paths that should be monitored and spent but never offered as new payment destinations

Link copied to clipboard

Wallet seed derived from words + password

Link copied to clipboard

Wallet secret seed

Link copied to clipboard

This is part of generating the secret from the recovery phrase (currently unused)

Link copied to clipboard
var spotPrice: (String) -> BigDecimal?

Give this wallet access to the spot price of its token in the provided fiat currency code. You should supply a function that takes a fiat (or digital) currency code, and returns the current price in that currency.

Link copied to clipboard
open override val syncedDate: Long

Returns the current position of this wallet in the blockchain by block time. Since a fork may have occurred, this information does not unambiguously locate the wallet, but it is valuable for UI.

Link copied to clipboard
open override val syncedHash: ByteArray

Returns the current position of this wallet in the blockchain by block hash. Since a fork may have occurred, this information does not unambiguously locate the wallet, but it is valuable for UI.

Link copied to clipboard
open override val syncedHeight: Long

Returns the current position of this wallet in the blockchain by block height. Since a fork may have occurred, this information does not unambiguously locate the wallet, but it is valuable for UI.

Link copied to clipboard
Link copied to clipboard

rebroadcast historical unconfirmed transactions every hour (and when we first start up)

Link copied to clipboard

rebroadcast wallet transaction every minute

Link copied to clipboard
Link copied to clipboard

Addresses that have already been generated and are in the bloom filter, but are not yet used. Public for display/debugging purposes only. DO NOT USE ADDRESSES OUT OF ORDER!

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
Link copied to clipboard
open override fun abortTransaction(tx: iTransaction, returnUnusedAddresses: List<PayAddress>?)

Abort this transaction, whose inputs were reserved by "prepareSend". Update the wallet to release all inputs reserved by this transaction

Link copied to clipboard
fun add(name: String, wc: WalletContract)

Add a new contract to this wallet

Link copied to clipboard
fun addBlockchain(chain: Blockchain, earliestHeight: Long?, earliestDate: Long?)

Add this blockchain and start syncing it. (or call @ref addBlockchain do do both). You should determine either earliestHeight or earliestDate, possibly via Rostrum, or you may be in for a very long sync operation.

Link copied to clipboard
fun addProposal(tx: iTransaction, reason: String, mine: Boolean, postConstruction: (TxSpendingProposal) -> Unit): TxSpendingProposal
Link copied to clipboard

Return all configured identity domains

Link copied to clipboard
Link copied to clipboard
fun Wallet.chunkInto(payAddress: PayAddress, numUtxos: Int, amt: Long, delta: Long = 100000): List<iTransaction>

This function will split the wallet's native coin so that there are numUtxos of amt satoshis. If the wallet already has some UTXOs that fit the requirements, they count. So its possible that no transactions will be created

Link copied to clipboard
fun Wallet.chunkTokenInto(gid: GroupId, payAddress: PayAddress, numUtxos: Int, tokenAmt: Long = 1): List<iTransaction>

This function will split the wallet's Tokens so that there are numUtxos of amt satoshis. If the wallet already has some UTXOs that fit the requirements, they count. So its possible that no transactions will be created

Link copied to clipboard
open override fun cleanReserved(before: Long)

Free up any UTXOs that have been allocated for pending transactions to be used again. This means that they might be double spent if that old reservation is still in progress.

Link copied to clipboard
open override fun cleanUnconfirmed(before: Long)

Forget about all unconfirmed transactions in the wallet. It the transactions are in the network and are confirmed they will be added to the wallet at that point. This API is used to clear out tx that will never confirm for some reason. This API causes the wallet to forget about the inputs that weren't confirmed. "Rediscover" can get those back

Forget about certain transactions in the wallet. If the transactions are in the network and are later confirmed they will be added to the wallet then. This API is used to clear out tx that will never confirm for some reason. This API causes the wallet to forget about the inputs that weren't confirmed. "Rediscover" can get those back

Link copied to clipboard
fun cleanupProposals(before: Long = millinow())
Link copied to clipboard
Link copied to clipboard
fun close()
Link copied to clipboard
fun commitWalletTransaction(tx: iTransaction, txbytes: ByteArray? = null, note: String? = null)

track this transaction and periodically resubmit until it has been committed.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Return all contracts in this wallet

Link copied to clipboard
fun createChangeOutput(amtSatoshis: Long, changeAddress: PayAddress? = null, contractId: ByteArray? = null): iTxOutput
Link copied to clipboard
open override fun createConsolidationTx(maxAmount: Long?): Pair<iTransaction, ByteArray>

Consolidate utxos. This allows you to spend larger quantities of coin because a transaction can only have 256 inputs.

Link copied to clipboard
fun createExchangeOffer(gid: GroupId, grpAmt: Long, askingAmt: Long, minConfirms: Int = 0): iTransaction

Create a partial transaction that offers to trade an asset (that you own) for native coin (nexa). It is expected that this wallet contains the asset, but this command will find the UTXOs and populate the transaction.

Link copied to clipboard
fun createGroupedChangeOutput(groupId: GroupId, groupAmount: Long, amtSatoshis: Long = dust(chainSelector), changeAddress: PayAddress? = null, contractId: ByteArray? = null): NexaTxOutput
Link copied to clipboard

print debugging data to the log

Link copied to clipboard
fun decrypt(ciphertext: ByteArray): ByteArray

Decrypt arbitrary length bytes

Link copied to clipboard
fun decryptPrivateKey(ciphertext: ByteArray, keyIndex: Int): ByteArray
Link copied to clipboard
open fun delete(underlyingFileName: String?)
Link copied to clipboard

Remove a contract from this account

Link copied to clipboard
open override fun deleteTxo(vararg txos: iTxOutpoint)

delete a TXO from the wallet's history. This should be used ONLY if the txo does not exist on the main chain, not when the txo is spent.

Link copied to clipboard
open override fun destinationFor(seed: String): PayDestination

Get a repeatable destination, generally used for identity purposes. Given 2 different seeds, this API should at a minimum be statistically unlikely to produce the same address The seed may be public data (a domain name, for example) so wallet security must not depend on it being a secret.

Link copied to clipboard
open override fun encrypt(passphrase: String)

switch this wallet from unencrypted to encrypted, or from one encryption passkey to another

fun encrypt(plaintext: ByteArray): ByteArray

Encrypt arbitrary length bytes

Link copied to clipboard
fun encryptPrivateKey(plaintext: ByteArray, keyIndex: Int): ByteArray

Encrypt an address's private key

Link copied to clipboard
open override fun fastForward(syncedHeight: Long, syncedDate: Long, syncedHash: Hash256, txhist: List<TransactionHistory>)

If you provide the complete transaction history prior to the passed point, OR you provide the additional transactions from where this wallet currently is to the passed point, then you can call this function to jump the wallet forward. If you do not provide the complete transaction history, the wallet may attempt to spend already spent coins (if you miss a spend) or not have the complete balance (if you miss a receive). In the receive case, these funds are not "lost" since they are on the blockchain. They are simply inaccessible by this instance of the wallet. If you did a correct recovery, they would appear.

Link copied to clipboard
fun Bip44Wallet.fastForward(displayFastForwardInfo: (String?) -> Unit): Objectify<Boolean>

Asynchronously fast forward a Bip44Wallet by searching address derivation paths using Rostrum.

Link copied to clipboard
fun feeForSize(txSize: Long): Long

Get the desired fee (in satoshis) for a transaction of the provided size

Link copied to clipboard
fun fieldDbKey(fieldName: String): String
Link copied to clipboard

In case someone sends coins to one of your identities, the wallet should be able to spend them It is not recommended to send coins to identities, as that makes the payments identifiable, and also a subsequent payment may mix other incoming payments with identity payments. So the identity address is never provided as a payment address. However, someone may use it as such.

Link copied to clipboard

If you clear the "receiving" addresses map, you need to fill them back up with derived class injected destinations using this function

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

Select inputs based on the provided filter. If a filter is NOT provided, only ungrouped, uncontracted UTXOs are provided, and minAmt is counted in Satoshis. NOTE: If a filter IS provided, you must filter out groups and contracts if you want to!

Link copied to clipboard
fun finalize()
Link copied to clipboard
fun findGroupId(firstOutpoint: iTxOutpoint, opRetTokenDesc: SatoshiScript?, flags: UInt, authorityFlags: ULong): Pair<GroupId, Long>
Link copied to clipboard
fun findInputs(amountSatoshis: Long, minConfirms: Int = 0, contractId: ByteArray? = null, filter: (Spendable) -> Long? = null): MutableList<Spendable>?

Find ungrouped inputs in this wallet to use in a new transaction. To be viable, the input needs to actually be spendable (have a backing pay destination). This DOES mark them as used, so can be called repeatedly.

Link copied to clipboard
fun flushTxHistoryCache(clear: Boolean = false)
Link copied to clipboard
fun flushTxo(txo: Array<Spendable?>, count: Int)
Link copied to clipboard
fun flushTxoCache(clear: Boolean = false)
Link copied to clipboard
fun <T> forEachContract(fn: (WalletContract) -> T?): T?

Iterate through all contracts

Link copied to clipboard
Link copied to clipboard
open override fun forEachTx(doit: (TransactionHistory) -> Boolean)

Wallet history iterator

Link copied to clipboard
open override fun forEachTxByAddress(addr: PayAddress, doit: (TransactionHistory) -> Boolean)

Wallet history iterator, of a particular address.

Link copied to clipboard
open override fun forEachTxByDate(doit: (TransactionHistory) -> Boolean)
open override fun forEachTxByDate(startingDate: Long, count: Long, doit: (TransactionHistory) -> Boolean)

Wallet history iterator, sorted by newest first.

Link copied to clipboard
open override fun forEachTxByOldestDate(startingDate: Long, count: Long, doit: (TransactionHistory) -> Boolean)

Wallet history iterator, sorted by oldest first, starting at @startingDate. This is the most efficient chunked history access. Approximately count records are made available; however every record of a given date is provided meaning that the actual number of available records can exceed the passed count. This ensures that no records are missed if you chunk requests and decrement the date by 1 after processing all the records in each chunk. Providing starting dates is much more efficient than an index because the system does not know the index of a record, so must process every prior record to count them.

Link copied to clipboard
open override fun forEachTxo(doit: (Spendable) -> Boolean)

Wallet TXO iterator. Your callback should return true to exit early from the loop.

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

Wallet UTXO iterator.

Link copied to clipboard
Link copied to clipboard
fun generateAddressesUntil(addressIndex: Int)

Bip44 addresses are indexed. This function addresses indexed from 0 to the passed parameter into the list of monitored addresses

Link copied to clipboard
open override fun generateDestination(): PayDestination

This function does not actually store or track the address in the wallet. It simply produces one. It is intended to be used so derived (specialized) wallet classes can provide addresses to a base wallet that saves and tracks addresses.

Link copied to clipboard
fun generateDestinationsInto(newUnusedAddresses: MutableList<PayAddress>, minAmt: Int = genAddressChunkSize)
Link copied to clipboard
open override fun getBalanceIn(dest: PayAddress, unspent: Boolean): Long
open override fun getBalanceIn(groupId: GroupId, dest: PayAddress?, minConfirms: Int, unspent: Boolean): Long
Link copied to clipboard

Get a contract by name

Link copied to clipboard

Get the current address to receive funds. Different wallets may support different payment destination types. This API returns whatever is the "default" type for this wallet. This allows generic algorithms to be created that can be applied to many different wallet types. When this API returns, the destination is ready for use (monitoring is installed in remote nodes, IF any remote nodes exist). This API may pre-generate destinations. This address will be returned until activity is detected on-chain, or until markAddressUsed is called

Link copied to clipboard
Link copied to clipboard

Gets a new address: convenience function that is functionally similar to @newDestination but mirrors the bitcoin-cli command.

Link copied to clipboard

Gets a new address: convenience function that is functionally similar to @newDestination but mirrors the bitcoin-cli command.

Link copied to clipboard
open override fun getNewDestination(): PayDestination

Get a new address to receive funds. This will return and "retire" the current address. Different wallets may support different payment destination types. This API returns whatever is the "default" type for this wallet. This allows generic algorithms to be created that can be applied to many different wallet types. When this API returns, the destination is ready for use (monitoring is installed in remote nodes, IF any remote nodes exist). This API may pre-generate destinations.

Link copied to clipboard
fun getPrice(whenInMsSinceEpoch: Long, currencyCode: String): BigDecimal

Get the price of this crypto's finest unit in fiat, using some external service

Link copied to clipboard
Link copied to clipboard

Wallet implementations may allow access to addresses generated from specific private keys or nonstandard HD derivation paths. The wallet will never offer these destinations as current payment targets. It will only spend them (and show their balance).

Link copied to clipboard
fun GetSecret(plaintext: ByteArray, keyIndex: Int): Secret

Wraps the plaintext secret into a Secured secret, with a decryption function that will work if a secret is supplied to this wallet

Link copied to clipboard
open override fun getTx(txIdem: Hash256): TransactionHistory?

wallet history by transaction idem

Link copied to clipboard

Count of transactions in the wallet

Link copied to clipboard
open override fun getTxo(txo: iTxOutpoint): Spendable?

wallet output by outpoint

Link copied to clipboard

Get a list of transaction outpoint that is spendable or was spent by this wallet. This is much more efficient than doing it in a loop

Link copied to clipboard
Link copied to clipboard

Place receive addresses into this wallet. These addresses will NOT be given out in @ref getnewaddress queries, but this wallet will monitor these addresses and can spend from them (you must provide the secret as part of PayDestination). Note that if the provided addresses are not derived from the wallet's recovery key, they won't be able to be recovered. Therefore using this API is discouraged for "normal" wallets! Instead "sweep" the coins into an address derived from the wallet's recovery key.

Link copied to clipboard
fun injectUnspent(vararg spend: Spendable)
Link copied to clipboard

Insert a record into the unspentByAddress structure

Link copied to clipboard

A contract tells us about the addresses that it is interested in. The wallet will callback the contract if it encounters a transaction that receives from or spends to this address

Link copied to clipboard
fun interestingTx(txUnsorted: List<iTransaction>, blockHash: Hash256?, blockHeight: Long?, msSinceEpoch: Long?, note: String?, forceRelevant: Boolean = false): Pair<Long, Long>

Give every transaction that might have something to do with this wallet to this function. The transaction will be analyzed and added to the wallet if it is relevant

Link copied to clipboard

Returns whether this address has been provided to the GUI (it may or may not have actually been used by someone)

Link copied to clipboard
open override fun isUnspentWalletAddress(dest: PayAddress): Boolean
Link copied to clipboard
open override fun isWalletAddress(dest: PayAddress): Boolean
Link copied to clipboard
fun launchRediscover(forgetAddresses: Boolean = false, noPrehistory: Boolean = false, forgetHistory: Boolean = false)
Link copied to clipboard
Link copied to clipboard

Save wallet contract state to the database. Called by saveWalletTo. Assumes that the datalock is taken

Link copied to clipboard
open fun loadPendingTxFromUnspent(throwIllegal: Boolean = true)
Link copied to clipboard

Load wallet transaction state from the database

Link copied to clipboard
open override fun lock()

relock an unlocked wallet

Link copied to clipboard
open override fun lockedState(): Boolean?
Link copied to clipboard
fun logDump()
Link copied to clipboard
open override fun lookupIdentityDomain(name: String): IdentityDomain?

Return identity domain data if this domain has previously been used

Link copied to clipboard
open override fun lookupIdentityInfo(id: PayAddress): IdentityInfo?

Return identity domain data if this domain has previously been used

Link copied to clipboard
open override fun markAddressUsed(addr: PayAddress)

Indicate that an address has been used (maybe it really has, or maybe not, but the point is that its reserved). If we start to run low, we'll also make more

Link copied to clipboard
fun minFeeForSize(txSize: Long): Long

Get the minimum relayable fee (in satoshis) for a transaction of the provided size

Link copied to clipboard
open override fun mintTokens(address: PayAddress, gid: GroupId, amountTokens: Long): iTransaction

Mint tokens.

Link copied to clipboard
open suspend override fun newDestination(): PayDestination

Get a new address to receive funds. Different wallets may support different payment destination types. This API returns whatever is the "default" type for this wallet. This allows generic algorithms to be created that can be applied to many different wallet types. When this API returns, the destination is ready for use (monitoring is installed in remote nodes, IF any remote nodes exist). This API may pre-generate destinations.

Link copied to clipboard
open override fun newToken(authAddress: PayAddress, opRetTokenDesc: SatoshiScript?, groupFlags: Int, authorityFlags: Long): Pair<iTransaction, GroupId>

Create a new group token

Link copied to clipboard
open override fun numTx(): Int
Link copied to clipboard
open override fun numTxos(): Int

Return the total number of ledger entries (TXOs) this wallet has ever used

Link copied to clipboard
open override fun numUtxos(): Int

Return the number of currently active ledger entries (UTXOs) in this wallet

Link copied to clipboard
fun pause(maxWait: Long = 30000): Boolean

Pauses the processing thread

Link copied to clipboard
Link copied to clipboard
open override fun prepareDestinations(minAmt: Int, chunk: Int)

Tell the wallet that now is a good time to top-up a cache of unused destinations

Link copied to clipboard
open override fun prepareSend(outputs: MutableList<iTxOutput>, minConfirms: Int, deductFeeFromAmount: Boolean): iTransaction

Creates an unsigned transaction that sends to a list of outputs. This function will select input coins from the wallet to fill the passed quantity and sign the transaction, but will not relay the transaction to the network.

Link copied to clipboard
fun proposeSignTransaction(tx: iTransaction, reason: String, sigHashType: ByteArray = byteArrayOf()): TxSpendingProposal
Link copied to clipboard
open override fun pubkeyToSecret(pubkey: ByteArray): Secret?

Find and return the secret corresponding to the passed pubkey.

Link copied to clipboard

This function re-checks all tx marked unconfirmed in this wallet to see if they are actually unconfirmed. It uses an electrumx server to do so, so may be unavailable if electrumx is not supported or no servers are available.

Link copied to clipboard
fun recoverUnspent(wallet: Wallet, numAddrToSearch: Int, numAccountToSearch: Int = 1, startAddrIndex: Int = 0, startAccountIndex: Int = 0): List<Spendable>

Search a variety of derivation paths for unspent utxos and add them into this wallet if discovered. These utxos are not swept, so may be forgotten if you recreate this wallet from a recovery key.

Link copied to clipboard
open override fun rediscover(forgetAddresses: Boolean, noPrehistory: Boolean, forgetHistory: Boolean)

Forget all transaction and blockchain state, and the redo the search for wallet transactions.

Link copied to clipboard
fun rediscoverAddresses(lastAddr: Long)

Forget all transaction and blockchain state, regenerate the first N addresses

Link copied to clipboard
fun regenerateBloom(onBloomInstalled: () -> Unit?)
Link copied to clipboard
open override fun removeIdentityDomain(name: String)

Remove identity domain data

Link copied to clipboard
open override fun removeIdentityInfo(id: PayAddress)

Remove identity domain data

Link copied to clipboard
open override fun removeOnWalletChange(key: Int)

clear a change handler that will get called whenever this wallet's state changes

Link copied to clipboard
Link copied to clipboard
fun restart()
Link copied to clipboard
fun resume()

Resumes the processing thread

Link copied to clipboard

Retire destination removes a PayDestination from the list of destinations we scan for payments. A typical use is for change addresses, since we know that that address will only be used once.

Link copied to clipboard
fun rewind()

Undo 1 block's changes to this wallet This function is slow compared to rewindForkedTx() and so it not used.

Link copied to clipboard
Link copied to clipboard
fun run()
Link copied to clipboard
open override fun save(force: Boolean)

Write this wallet's changes to underlying storage. Called internally if @automaticSave is true, and/or explicitly called. Synchronous. An inability to save the wallet is a severe problem so exceptions are thrown.

Link copied to clipboard
Link copied to clipboard

Save wallet contract state to the database. Called by saveWalletTo

Link copied to clipboard
Link copied to clipboard

Save wallet transaction state to the database

Link copied to clipboard
open override fun <T> searchTx(doit: (tx: TransactionHistory) -> T?): T?

Wallet history iterator.

Link copied to clipboard
open override fun send(tx: iTransaction, sync: Boolean, note: String?)

Post this transaction and update the wallet based on any inputs spent. Typically the provided tx came from calling prepareSend

open override fun send(addrAmt: List<Pair<PayAddress, Long>>, sync: Boolean, note: String?, minConfirms: Int): iTransaction

Send funds to multiple destinations. This function will select input coins from the wallet to fill the passed quantity

open override fun send(amountSatoshis: Long, destAddress: String, deductFeeFromAmount: Boolean, sync: Boolean, note: String?, minConfirms: Int): iTransaction
open override fun send(amountSatoshis: Long, destAddress: PayAddress, deductFeeFromAmount: Boolean, sync: Boolean, note: String?, minConfirms: Int): iTransaction
open override fun send(amountSatoshis: Long, destScript: SatoshiScript, deductFeeFromAmount: Boolean, sync: Boolean, note: String?, minConfirms: Int): iTransaction

Send funds to this destination. This function will select input coins from the wallet to fill the passed quantity

fun send(vararg outputs: iTxOutput, sync: Boolean = false, flags: Int = TxCompletionFlags.BIND_OUTPUT_PARAMETERS or TxCompletionFlags.FUND_GROUPS or TxCompletionFlags.FUND_NATIVE or TxCompletionFlags.USE_GROUP_AUTHORITIES or TxCompletionFlags.SIGN, note: String? = null, minConfirms: Int = 0): iTransaction

fun send(amountTokens: Long, destAddress: PayAddress, groupId: GroupId, sync: Boolean = false, note: String? = null): iTransaction

Send tokens to a destination. This is a convenience function to send to one destination. Use send(vararg outputs:iTxOutput...) to send multiple token types at once.

Link copied to clipboard
fun sendNative(vararg outputs: iTxOutput, sync: Boolean = false, note: String? = null): iTransaction

Send funds to multiple destinations (native coin only). This function will select input coins from the wallet to fill the passed quantity

Link copied to clipboard
open override fun setOnWalletChange(callback: (Wallet, List<TransactionHistory>?) -> Unit): Int

Install a change handler that will get called whenever this wallet's state changes

Link copied to clipboard
open override fun signData(message: ByteArray, addr: PayAddress?): ByteArray

Sign (using blockchain compatible SHA256 and Schnorr) the provided data with the provided address (this wallet must have the private key for that address), or pass null to use the common identity.

Link copied to clipboard
open override fun signHash(hash: ByteArray, addr: PayAddress?): ByteArray
open override fun signHash(hash: Hash256, addr: PayAddress?): ByteArray

Sign (using blockchain compatible Schnorr) the provided data with the provided address (this wallet must have the private key for that address), or pass null to use the common identity.

Link copied to clipboard
open override fun signMessage(message: ByteArray, addr: PayAddress?): ByteArray
fun signMessage(message: String, addr: PayAddress? = null): String

Sign the passed message with the passed address (which must be owned by this wallet) using Bitcoin-style message signing.

Link copied to clipboard
fun signTransaction(tx: iTransaction, sigHashType: ByteArray = byteArrayOf()): iTransaction
Link copied to clipboard
Link copied to clipboard
fun startChain(earliestHeight: Long?, earliestDate: Long?)

Start syncing against the blockchain provided with @ref usesChain, which MUST be called first. (or call @ref addBlockchain do do both). You should determine either earliestHeight or earliestDate, possibly via Rostrum, or you may be in for a very long sync operation.

Link copied to clipboard
open override fun statistics(): Wallet.WalletStatistics

Report various wallet statistics, see WalletStatistics

Link copied to clipboard
Link copied to clipboard
fun stop(waitForThreadCompletion: Boolean = true)
Link copied to clipboard
open override fun suggestFee(tx: iTransaction, pad: Int, priority: Int): Long

Calculate a suggested fee for this transaction

Link copied to clipboard
fun sync(maxWait: Long = 10L*86400L*365L, epochTimeinMsOrBlockHeight: Long = -1L): Boolean

Return whether this wallet is synced with its underlying blockchain. If it is not synced, properties like balance and balanceUnconfirmed express some previous state. In the unsynced case, this API will wait for it to do so, but no more than the provided time in milliseconds. If a height is provided, this API returns true if the wallet is synced up to or beyond this height If a height is not provided (or is -1), this API assumes you mean up to "now". This is special cased with an extra check that the blockchain's tip timestamp is within an hour of now. Of course, since blocks can be discovered at any time, and connected nodes can be slow at processing blocks one cannot ever absolutely know whether the wallet is really synced up to "now", so this function is more accurately described as "nearly synced" for any "now" call.

Link copied to clipboard
open override fun synced(epochTimeinMsOrBlockHeight: Long): Boolean

Return whether this wallet is synced with its underlying blockchain. If it is not synced, properties like balance and balanceUnconfirmed express some previous state. In the unsynced case, this API will wait for it to do so, but no more than the provided time in milliseconds. If a height is provided, this API returns true if the wallet is synced up to or beyond this height If a height is not provided (or is -1), this API assumes you mean up to "now". This is special cased with an extra check that the blockchain's tip timestamp is within an hour of now. Of course, since blocks can be discovered at any time, and connected nodes can be slow at processing blocks one cannot ever absolutely know whether the wallet is really synced up to "now", so this function is more accurately described as "nearly synced" for any "now" call.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun txCompleter(tx: iTransaction, minConfirms: Int, flags: Int, inputAmount: Long?, adjustableOutput: Int?, destinationAddress: PayAddress?, changeAddress: PayAddress?, sigHashTypeOverride: ByteArray?, contractId: ByteArray?)

Modifies a transaction based on the passed allowed operations to move it closer to a fully balanced, fully signed state. This function finds inputs needed to supply funds (token or native) for this transaction, generates change outputs, completes partially-defined output scripts, and signs inputs. All of these functions are enabled/disabled by the "flags"parameter.

Link copied to clipboard
fun txRejection(rejectInfo: RejectInfo)
Link copied to clipboard
fun txSanityCheck(tx: iTransaction, checkFullySigned: Boolean = true, checkFee: Boolean = true, returnUnusedAddresses: List<PayAddress>? = null)

Checks the transaction's final fee. Throws an exception and aborts the transaction if the fee is too big.

Link copied to clipboard
Link copied to clipboard
open override fun unlock(passphrase: String): Boolean?

unlock this wallet by providing the passphrase.

Link copied to clipboard
open override fun upsertIdentityDomain(id: IdentityDomain)

Add or update identity domain data

Link copied to clipboard
open override fun upsertIdentityInfo(id: IdentityInfo)

Add or update identity domain data

Link copied to clipboard
fun usesChain(chain: Blockchain)
Link copied to clipboard
fun verifyMessage(message: String, addr: PayAddress, sigS: String): Boolean

Verify that the provided message was signed properly (using Bitcoin-style message signing)

Link copied to clipboard
open override fun verifySigForData(data: ByteArray, sig: ByteArray, addr: PayAddress?): Boolean

verify (using blockchain compatible SHA256 and Schnorr) the provided data with the provided address (this wallet must have the private key for that address), or pass null to use the common identity. Use LibNexa.verifySignedHashSchnorr or LibNexa.verifySignedDataSchnorr if you need to verify a non-wallet signature with a public key.

Link copied to clipboard
open override fun verifySigForHash(hash: ByteArray, sig: ByteArray, addr: PayAddress?): Boolean

verify (using blockchain compatible SHA256 and Schnorr) the provided data with the provided address (this wallet must have the private key for that address), or pass null to use the common identity. Use LibNexa.verifySignedHashSchnorr or LibNexa.verifySignedDataSchnorr if you need to verify a non-wallet signature with a public key. You may call verifySigForData instead as a shortcut if you have the data "preimage" not the hash and want to automatically use the standard cryptographic hash for this blockchain.

Link copied to clipboard
open override fun walletDestination(dest: PayAddress): PayDestination?
Link copied to clipboard
fun <T> withContract(cname: String, thunk: (WalletContract) -> T): T?

Use a contract by name

Link copied to clipboard
fun <U> withContractType(cname: String, thunk: (U) -> Unit): Boolean

Use a contract by name, auto-downcasting to your expected contract type