Package-level declarations

Introduction

This library is comprehensive and therefore complex. Learning it is best accomplished via example code, with this documentation used as a reference. The library contains Wallet, Blockchain, Network and Scripting sections. All are needed to implement a fully-functional Nexa wallet, but portions can be used separately if full functionality is not needed.

Basic Objects

Multiple blockchains are supported via the ChainSelector object. Currently this includes Nexa and Bitcoin Cash, and all of the secondary (i.e. regtest and testnet) networks for these two blockchains.

This is accomplished using a class hierarchy, with interfaces designated by iXXXX (for example iBlockHeader, iBlock, iTransaction, iTxInput, iTxOutput, iTxOutpoint). These interfaces are implemented by a class that implements common functionality "CommonBlockHeader", and this class is the parent of blockchain-specific derived classes (NexaBlockHeader, BchBlockHeader).

Rather than create instances of blockchain-specific classes, it is best to use the "xxxFor" and "xxxFrom" APIs (blockFor, blockFromHex, blockHeaderFor, txFor, txFromHex, txInputFor, txOutputFor).
These "factory" APIs create the correct derived class, returning the interface type. Using them, it is surprising how much common code can be written that works across both BCH and NEXA, and potentially other UTXO-based chains.

Blockchains and Wallets

APIs exist to create wallets, launch blockchains, and attach the two. Right now, a wallet can only attach to a single blockchain. See newWallet, openWallet, and deleteWallet.

Blockchain

The Blockchain class represents a blockchain and synchronizes with the public chain. It stores block headers to a database and has APIs to query the chain.

Blockchain objects (Blocks and Transactions)

Although one may create Nexa or Bch objects directly, it is recommended that construction of blockchain objects occur via global helper functions:

These functions will create the correct blockchain-specific derived class, returning the parent iXXXX object. By doing this whenever possible, you maximize the likelihood that your source code will apply to multiple blockchains. To use blockchain-specific functionality, you may downcast "(header as NexaBlockHeader)" when needed.

Network Access

You may access either P2P or Electrum nodes in the network via the RequestMgr class. This class automatically manages connection for you. Going lower, you may directly connect to a specific node via the P2pClient or ElectrumClient classes.

Scripting

Full scripting functionality is available via the OP class, which captures all opcodes, and via the SatoshiScript and ScriptTemplate classes.
The SatoshiScript class is the generalized script language. ScriptTemplate creates the Nexa-specific script template transaction output. Note that a partner library Nexa Script Machine can be used to execute and debug these scripts.

Wallet

At the top level, the Bip44Wallet exists to create an manage a bip-44 compliant (meaning based on a 12-word recovery key) wallet. If set up, this object automatically uses the Blockchain Network and Scripting APIs to automatically sync with the blockchain and parse and create transactions. However, it is also possible to use this object in an offline mode, simply by not "hooking" it to a network object. After creating this object, use the Wallet interface for general purpose functionality, to allow your code to work with any wallet type.

Example

import org.nexa.libnexakotlin.*

class Test
{

fun docObjectExample()
{
// This is the Nexa genesis block
val hdr = blockFromHex(ChainSelector.NEXA, "00000000000000000000000000000000000000000000000000000000000000000000011e0000000000000000000000000000000000000000000000000000000000000000cdafb522e41f4b94618c8ee546f0fab8aaae7057f80e4730ea32df145dec73910000000000000000000000000000000000000000000000000000000000000000c0b2b16200ffffff00000000000000000000000000000000000000000000000000000000007201000000000000010000000403001700010000020000000000000000000100000000000000000000a06a00023b1c4c99526575746572733a204a6170616e20504d204b697368696461206261636b7320424f4a20756c7472612d6561737920706f6c696379207768696c652079656e20776f7272696573206d6f756e74204254433a3734313731313a3030303030303030303030303030303030303037356634626330386531643738613361623361663832373464313333333463306163326465323533303937363800000000")
println("Height ${hdr.height} Size ${hdr.size} Chain Work ${hdr.chainWork}")
val tx = hdr.txes[0]
println("Tx 0 inputs: ${tx.inputs.size}")
println("Tx 0 outputs: ${tx.outputs.size}")

// I'm cheating here a little because I know this is the genesis block so I know that the last output
// of the last transaction is text within an OP_RETURN script.
val output0Asm = tx.outputs.last().script.toAsm(" ")
println("tx 0 output 0: $output0Asm")
val stmts = tx.outputs.last().script.parsed()
println("\nNexa genesis block says:" + OP.parse(stmts.last()).data!!.decodeUtf8())

// Create a regtest address object
val addr = PayAddress("nexareg:nqtsq5g53q3sqyhhp45a86792a7wkkm3gyw9gylhp7kr703l")
}

fun docWalletExample()
{
// This needs to be run before APIs are called, but you should do a single time upon app startup
initializeLibNexa()

// This call automatically creates the underlying blockchain object if it hasn't already been created.
val wal = openOrNewWallet("exampleWallet", ChainSelector.NEXAREGTEST)
while(!wal.synced())
{
// Note that the blockchain may also be syncing headers simultaneously with the wallet syncing, so both
// numbers may increase.
//
// Sync also depends on time -- if the synced block isn't recent enough the wallet does not believe its
// synced. So if you are using REGTEST make sure you have recently created a new block before running this test.
println("syncing ${wal.chainstate?.syncedHeight} of ${wal.blockchain.curHeight}..." )
millisleep(2000U)
}

val newAddress = wal.getNewAddress()
println("wallet balance is: ${wal.balance}. An address for this wallet is ${newAddress}.")
try
{
// send some coins to myself. Amounts in this library are ALWAYS in the finest unit.
wal.send(10000, wal.getNewAddress())
}
catch (e: WalletNotEnoughBalanceException)
{
if (wal.balance <= 10000) println("You don't have enough coins to actually send.")
}
}

}

Introduction

This library is comprehensive and therefore complex. Learning it is best accomplished via example code, with this documentation used as a reference. The library contains Wallet, Blockchain, Network and Scripting sections. All are needed to implement a fully-functional Nexa wallet, but portions can be used separately if full functionality is not needed.

Basic Objects

Multiple blockchains are supported via the ChainSelector object. Currently this includes Nexa and Bitcoin Cash, and all of the secondary (i.e. regtest and testnet) networks for these two blockchains.

This is accomplished using a class hierarchy, with interfaces designated by iXXXX (for example iBlockHeader, iBlock, iTransaction, iTxInput, iTxOutput, iTxOutpoint). These interfaces are implemented by a class that implements common functionality "CommonBlockHeader", and this class is the parent of blockchain-specific derived classes (NexaBlockHeader, BchBlockHeader).

Rather than create instances of blockchain-specific classes, it is best to use the "xxxFor" and "xxxFrom" APIs (blockFor, blockFromHex, blockHeaderFor, txFor, txFromHex, txInputFor, txOutputFor).
These "factory" APIs create the correct derived class, returning the interface type. Using them, it is surprising how much common code can be written that works across both BCH and NEXA, and potentially other UTXO-based chains.

Blockchains and Wallets

APIs exist to create wallets, launch blockchains, and attach the two. Right now, a wallet can only attach to a single blockchain. See newWallet, openWallet, and deleteWallet.

Blockchain

The Blockchain class represents a blockchain and synchronizes with the public chain. It stores block headers to a database and has APIs to query the chain.

Blockchain objects (Blocks and Transactions)

Although one may create Nexa or Bch objects directly, it is recommended that construction of blockchain objects occur via global helper functions:

These functions will create the correct blockchain-specific derived class, returning the parent iXXXX object. By doing this whenever possible, you maximize the likelihood that your source code will apply to multiple blockchains. To use blockchain-specific functionality, you may downcast "(header as NexaBlockHeader)" when needed.

Network Access

You may access either P2P or Electrum nodes in the network via the RequestMgr class. This class automatically manages connection for you. Going lower, you may directly connect to a specific node via the P2pClient or ElectrumClient classes.

Scripting

Full scripting functionality is available via the OP class, which captures all opcodes, and via the SatoshiScript and ScriptTemplate classes.
The SatoshiScript class is the generalized script language. ScriptTemplate creates the Nexa-specific script template transaction output. Note that a partner library Nexa Script Machine can be used to execute and debug these scripts.

Wallet

At the top level, the Bip44Wallet exists to create an manage a bip-44 compliant (meaning based on a 12-word recovery key) wallet. If set up, this object automatically uses the Blockchain Network and Scripting APIs to automatically sync with the blockchain and parse and create transactions. However, it is also possible to use this object in an offline mode, simply by not "hooking" it to a network object. After creating this object, use the Wallet interface for general purpose functionality, to allow your code to work with any wallet type.

Example

import org.nexa.libnexakotlin.*

class Test
{

fun docObjectExample()
{
// This is the Nexa genesis block
val hdr = blockFromHex(ChainSelector.NEXA, "00000000000000000000000000000000000000000000000000000000000000000000011e0000000000000000000000000000000000000000000000000000000000000000cdafb522e41f4b94618c8ee546f0fab8aaae7057f80e4730ea32df145dec73910000000000000000000000000000000000000000000000000000000000000000c0b2b16200ffffff00000000000000000000000000000000000000000000000000000000007201000000000000010000000403001700010000020000000000000000000100000000000000000000a06a00023b1c4c99526575746572733a204a6170616e20504d204b697368696461206261636b7320424f4a20756c7472612d6561737920706f6c696379207768696c652079656e20776f7272696573206d6f756e74204254433a3734313731313a3030303030303030303030303030303030303037356634626330386531643738613361623361663832373464313333333463306163326465323533303937363800000000")
println("Height ${hdr.height} Size ${hdr.size} Chain Work ${hdr.chainWork}")
val tx = hdr.txes[0]
println("Tx 0 inputs: ${tx.inputs.size}")
println("Tx 0 outputs: ${tx.outputs.size}")

// I'm cheating here a little because I know this is the genesis block so I know that the last output
// of the last transaction is text within an OP_RETURN script.
val output0Asm = tx.outputs.last().script.toAsm(" ")
println("tx 0 output 0: $output0Asm")
val stmts = tx.outputs.last().script.parsed()
println("\nNexa genesis block says:" + OP.parse(stmts.last()).data!!.decodeUtf8())

// Create a regtest address object
val addr = PayAddress("nexareg:nqtsq5g53q3sqyhhp45a86792a7wkkm3gyw9gylhp7kr703l")
}

fun docWalletExample()
{
// This needs to be run before APIs are called, but you should do a single time upon app startup
initializeLibNexa()

// This call automatically creates the underlying blockchain object if it hasn't already been created.
val wal = openOrNewWallet("exampleWallet", ChainSelector.NEXAREGTEST)
while(!wal.synced())
{
// Note that the blockchain may also be syncing headers simultaneously with the wallet syncing, so both
// numbers may increase.
//
// Sync also depends on time -- if the synced block isn't recent enough the wallet does not believe its
// synced. So if you are using REGTEST make sure you have recently created a new block before running this test.
println("syncing ${wal.chainstate?.syncedHeight} of ${wal.blockchain.curHeight}..." )
millisleep(2000U)
}

val newAddress = wal.getNewAddress()
println("wallet balance is: ${wal.balance}. An address for this wallet is ${newAddress}.")
try
{
// send some coins to myself. Amounts in this library are ALWAYS in the finest unit.
wal.send(10000, wal.getNewAddress())
}
catch (e: WalletNotEnoughBalanceException)
{
if (wal.balance <= 10000) println("You don't have enough coins to actually send.")
}
}

}

Introduction

This library is comprehensive and therefore complex. Learning it is best accomplished via example code, with this documentation used as a reference. The library contains Wallet, Blockchain, Network and Scripting sections. All are needed to implement a fully-functional Nexa wallet, but portions can be used separately if full functionality is not needed.

Basic Objects

Multiple blockchains are supported via the ChainSelector object. Currently this includes Nexa and Bitcoin Cash, and all of the secondary (i.e. regtest and testnet) networks for these two blockchains.

This is accomplished using a class hierarchy, with interfaces designated by iXXXX (for example iBlockHeader, iBlock, iTransaction, iTxInput, iTxOutput, iTxOutpoint). These interfaces are implemented by a class that implements common functionality "CommonBlockHeader", and this class is the parent of blockchain-specific derived classes (NexaBlockHeader, BchBlockHeader).

Rather than create instances of blockchain-specific classes, it is best to use the "xxxFor" and "xxxFrom" APIs (blockFor, blockFromHex, blockHeaderFor, txFor, txFromHex, txInputFor, txOutputFor).
These "factory" APIs create the correct derived class, returning the interface type. Using them, it is surprising how much common code can be written that works across both BCH and NEXA, and potentially other UTXO-based chains.

Blockchains and Wallets

APIs exist to create wallets, launch blockchains, and attach the two. Right now, a wallet can only attach to a single blockchain. See newWallet, openWallet, and deleteWallet.

Blockchain

The Blockchain class represents a blockchain and synchronizes with the public chain. It stores block headers to a database and has APIs to query the chain.

Blockchain objects (Blocks and Transactions)

Although one may create Nexa or Bch objects directly, it is recommended that construction of blockchain objects occur via global helper functions:

These functions will create the correct blockchain-specific derived class, returning the parent iXXXX object. By doing this whenever possible, you maximize the likelihood that your source code will apply to multiple blockchains. To use blockchain-specific functionality, you may downcast "(header as NexaBlockHeader)" when needed.

Network Access

You may access either P2P or Electrum nodes in the network via the RequestMgr class. This class automatically manages connection for you. Going lower, you may directly connect to a specific node via the P2pClient or ElectrumClient classes.

Scripting

Full scripting functionality is available via the OP class, which captures all opcodes, and via the SatoshiScript and ScriptTemplate classes.
The SatoshiScript class is the generalized script language. ScriptTemplate creates the Nexa-specific script template transaction output. Note that a partner library Nexa Script Machine can be used to execute and debug these scripts.

Wallet

At the top level, the Bip44Wallet exists to create an manage a bip-44 compliant (meaning based on a 12-word recovery key) wallet. If set up, this object automatically uses the Blockchain Network and Scripting APIs to automatically sync with the blockchain and parse and create transactions. However, it is also possible to use this object in an offline mode, simply by not "hooking" it to a network object. After creating this object, use the Wallet interface for general purpose functionality, to allow your code to work with any wallet type.

Example

import org.nexa.libnexakotlin.*

class Test
{

fun docObjectExample()
{
// This is the Nexa genesis block
val hdr = blockFromHex(ChainSelector.NEXA, "00000000000000000000000000000000000000000000000000000000000000000000011e0000000000000000000000000000000000000000000000000000000000000000cdafb522e41f4b94618c8ee546f0fab8aaae7057f80e4730ea32df145dec73910000000000000000000000000000000000000000000000000000000000000000c0b2b16200ffffff00000000000000000000000000000000000000000000000000000000007201000000000000010000000403001700010000020000000000000000000100000000000000000000a06a00023b1c4c99526575746572733a204a6170616e20504d204b697368696461206261636b7320424f4a20756c7472612d6561737920706f6c696379207768696c652079656e20776f7272696573206d6f756e74204254433a3734313731313a3030303030303030303030303030303030303037356634626330386531643738613361623361663832373464313333333463306163326465323533303937363800000000")
println("Height ${hdr.height} Size ${hdr.size} Chain Work ${hdr.chainWork}")
val tx = hdr.txes[0]
println("Tx 0 inputs: ${tx.inputs.size}")
println("Tx 0 outputs: ${tx.outputs.size}")

// I'm cheating here a little because I know this is the genesis block so I know that the last output
// of the last transaction is text within an OP_RETURN script.
val output0Asm = tx.outputs.last().script.toAsm(" ")
println("tx 0 output 0: $output0Asm")
val stmts = tx.outputs.last().script.parsed()
println("\nNexa genesis block says:" + OP.parse(stmts.last()).data!!.decodeUtf8())

// Create a regtest address object
val addr = PayAddress("nexareg:nqtsq5g53q3sqyhhp45a86792a7wkkm3gyw9gylhp7kr703l")
}

fun docWalletExample()
{
// This needs to be run before APIs are called, but you should do a single time upon app startup
initializeLibNexa()

// This call automatically creates the underlying blockchain object if it hasn't already been created.
val wal = openOrNewWallet("exampleWallet", ChainSelector.NEXAREGTEST)
while(!wal.synced())
{
// Note that the blockchain may also be syncing headers simultaneously with the wallet syncing, so both
// numbers may increase.
//
// Sync also depends on time -- if the synced block isn't recent enough the wallet does not believe its
// synced. So if you are using REGTEST make sure you have recently created a new block before running this test.
println("syncing ${wal.chainstate?.syncedHeight} of ${wal.blockchain.curHeight}..." )
millisleep(2000U)
}

val newAddress = wal.getNewAddress()
println("wallet balance is: ${wal.balance}. An address for this wallet is ${newAddress}.")
try
{
// send some coins to myself. Amounts in this library are ALWAYS in the finest unit.
wal.send(10000, wal.getNewAddress())
}
catch (e: WalletNotEnoughBalanceException)
{
if (wal.balance <= 10000) println("You don't have enough coins to actually send.")
}
}

}

Introduction

This library is comprehensive and therefore complex. Learning it is best accomplished via example code, with this documentation used as a reference. The library contains Wallet, Blockchain, Network and Scripting sections. All are needed to implement a fully-functional Nexa wallet, but portions can be used separately if full functionality is not needed.

Basic Objects

Multiple blockchains are supported via the ChainSelector object. Currently this includes Nexa and Bitcoin Cash, and all of the secondary (i.e. regtest and testnet) networks for these two blockchains.

This is accomplished using a class hierarchy, with interfaces designated by iXXXX (for example iBlockHeader, iBlock, iTransaction, iTxInput, iTxOutput, iTxOutpoint). These interfaces are implemented by a class that implements common functionality "CommonBlockHeader", and this class is the parent of blockchain-specific derived classes (NexaBlockHeader, BchBlockHeader).

Rather than create instances of blockchain-specific classes, it is best to use the "xxxFor" and "xxxFrom" APIs (blockFor, blockFromHex, blockHeaderFor, txFor, txFromHex, txInputFor, txOutputFor).
These "factory" APIs create the correct derived class, returning the interface type. Using them, it is surprising how much common code can be written that works across both BCH and NEXA, and potentially other UTXO-based chains.

Blockchains and Wallets

APIs exist to create wallets, launch blockchains, and attach the two. Right now, a wallet can only attach to a single blockchain. See newWallet, openWallet, and deleteWallet.

Blockchain

The Blockchain class represents a blockchain and synchronizes with the public chain. It stores block headers to a database and has APIs to query the chain.

Blockchain objects (Blocks and Transactions)

Although one may create Nexa or Bch objects directly, it is recommended that construction of blockchain objects occur via global helper functions:

  • txFor, txFromHex, txInputFor, txOutputFor

  • blockHeaderFor, blockHeaderFromHex, and merkleBlockFor

These functions will create the correct blockchain-specific derived class, returning the parent iXXXX object. By doing this whenever possible, you maximize the likelihood that your source code will apply to multiple blockchains. To use blockchain-specific functionality, you may downcast "(header as NexaBlockHeader)" when needed.

Network Access

You may access either P2P or Electrum nodes in the network via the RequestMgr class. This class automatically manages connection for you. Going lower, you may directly connect to a specific node via the P2pClient or ElectrumClient classes.

Scripting

Full scripting functionality is available via the OP class, which captures all opcodes, and via the SatoshiScript and ScriptTemplate classes.
The SatoshiScript class is the generalized script language. ScriptTemplate creates the Nexa-specific script template transaction output. Note that a partner library Nexa Script Machine can be used to execute and debug these scripts.

Wallet

At the top level, the Bip44Wallet exists to create an manage a bip-44 compliant (meaning based on a 12-word recovery key) wallet. If set up, this object automatically uses the Blockchain Network and Scripting APIs to automatically sync with the blockchain and parse and create transactions. However, it is also possible to use this object in an offline mode, simply by not "hooking" it to a network object. After creating this object, use the Wallet interface for general purpose functionality, to allow your code to work with any wallet type.

Example

import org.nexa.libnexakotlin.*

class Test
{

fun docObjectExample()
{
// This is the Nexa genesis block
val hdr = blockFromHex(ChainSelector.NEXA, "00000000000000000000000000000000000000000000000000000000000000000000011e0000000000000000000000000000000000000000000000000000000000000000cdafb522e41f4b94618c8ee546f0fab8aaae7057f80e4730ea32df145dec73910000000000000000000000000000000000000000000000000000000000000000c0b2b16200ffffff00000000000000000000000000000000000000000000000000000000007201000000000000010000000403001700010000020000000000000000000100000000000000000000a06a00023b1c4c99526575746572733a204a6170616e20504d204b697368696461206261636b7320424f4a20756c7472612d6561737920706f6c696379207768696c652079656e20776f7272696573206d6f756e74204254433a3734313731313a3030303030303030303030303030303030303037356634626330386531643738613361623361663832373464313333333463306163326465323533303937363800000000")
println("Height ${hdr.height} Size ${hdr.size} Chain Work ${hdr.chainWork}")
val tx = hdr.txes[0]
println("Tx 0 inputs: ${tx.inputs.size}")
println("Tx 0 outputs: ${tx.outputs.size}")

// I'm cheating here a little because I know this is the genesis block so I know that the last output
// of the last transaction is text within an OP_RETURN script.
val output0Asm = tx.outputs.last().script.toAsm(" ")
println("tx 0 output 0: $output0Asm")
val stmts = tx.outputs.last().script.parsed()
println("\nNexa genesis block says:" + OP.parse(stmts.last()).data!!.decodeUtf8())

// Create a regtest address object
val addr = PayAddress("nexareg:nqtsq5g53q3sqyhhp45a86792a7wkkm3gyw9gylhp7kr703l")
}

fun docWalletExample()
{
// This needs to be run before APIs are called, but you should do a single time upon app startup
initializeLibNexa()

// This call automatically creates the underlying blockchain object if it hasn't already been created.
val wal = openOrNewWallet("exampleWallet", ChainSelector.NEXAREGTEST)
while(!wal.synced())
{
// Note that the blockchain may also be syncing headers simultaneously with the wallet syncing, so both
// numbers may increase.
//
// Sync also depends on time -- if the synced block isn't recent enough the wallet does not believe its
// synced. So if you are using REGTEST make sure you have recently created a new block before running this test.
println("syncing ${wal.chainstate?.syncedHeight} of ${wal.blockchain.curHeight}..." )
millisleep(2000U)
}

val newAddress = wal.getNewAddress()
println("wallet balance is: ${wal.balance}. An address for this wallet is ${newAddress}.")
try
{
// send some coins to myself. Amounts in this library are ALWAYS in the finest unit.
wal.send(10000, wal.getNewAddress())
}
catch (e: WalletNotEnoughBalanceException)
{
if (wal.balance <= 10000) println("You don't have enough coins to actually send.")
}
}

}

Introduction

This library is comprehensive and therefore complex. Learning it is best accomplished via example code, with this documentation used as a reference. The library contains Wallet, Blockchain, Network and Scripting sections. All are needed to implement a fully-functional Nexa wallet, but portions can be used separately if full functionality is not needed.

Basic Objects

Multiple blockchains are supported via the ChainSelector object. Currently this includes Nexa and Bitcoin Cash, and all of the secondary (i.e. regtest and testnet) networks for these two blockchains.

This is accomplished using a class hierarchy, with interfaces designated by iXXXX (for example iBlockHeader, iBlock, iTransaction, iTxInput, iTxOutput, iTxOutpoint). These interfaces are implemented by a class that implements common functionality "CommonBlockHeader", and this class is the parent of blockchain-specific derived classes (NexaBlockHeader, BchBlockHeader).

Rather than create instances of blockchain-specific classes, it is best to use the "xxxFor" and "xxxFrom" APIs (blockFor, blockFromHex, blockHeaderFor, txFor, txFromHex, txInputFor, txOutputFor).
These "factory" APIs create the correct derived class, returning the interface type. Using them, it is surprising how much common code can be written that works across both BCH and NEXA, and potentially other UTXO-based chains.

Blockchains and Wallets

APIs exist to create wallets, launch blockchains, and attach the two. Right now, a wallet can only attach to a single blockchain. See newWallet, openWallet, and deleteWallet.

Blockchain

The Blockchain class represents a blockchain and synchronizes with the public chain. It stores block headers to a database and has APIs to query the chain.

Blockchain objects (Blocks and Transactions)

Although one may create Nexa or Bch objects directly, it is recommended that construction of blockchain objects occur via global helper functions:

These functions will create the correct blockchain-specific derived class, returning the parent iXXXX object. By doing this whenever possible, you maximize the likelihood that your source code will apply to multiple blockchains. To use blockchain-specific functionality, you may downcast "(header as NexaBlockHeader)" when needed.

Network Access

You may access either P2P or Electrum nodes in the network via the RequestMgr class. This class automatically manages connection for you. Going lower, you may directly connect to a specific node via the P2pClient or ElectrumClient classes.

Scripting

Full scripting functionality is available via the OP class, which captures all opcodes, and via the SatoshiScript and ScriptTemplate classes.
The SatoshiScript class is the generalized script language. ScriptTemplate creates the Nexa-specific script template transaction output. Note that a partner library Nexa Script Machine can be used to execute and debug these scripts.

Wallet

At the top level, the Bip44Wallet exists to create an manage a bip-44 compliant (meaning based on a 12-word recovery key) wallet. If set up, this object automatically uses the Blockchain Network and Scripting APIs to automatically sync with the blockchain and parse and create transactions. However, it is also possible to use this object in an offline mode, simply by not "hooking" it to a network object. After creating this object, use the Wallet interface for general purpose functionality, to allow your code to work with any wallet type.

Example

import org.nexa.libnexakotlin.*

class Test
{

fun docObjectExample()
{
// This is the Nexa genesis block
val hdr = blockFromHex(ChainSelector.NEXA, "00000000000000000000000000000000000000000000000000000000000000000000011e0000000000000000000000000000000000000000000000000000000000000000cdafb522e41f4b94618c8ee546f0fab8aaae7057f80e4730ea32df145dec73910000000000000000000000000000000000000000000000000000000000000000c0b2b16200ffffff00000000000000000000000000000000000000000000000000000000007201000000000000010000000403001700010000020000000000000000000100000000000000000000a06a00023b1c4c99526575746572733a204a6170616e20504d204b697368696461206261636b7320424f4a20756c7472612d6561737920706f6c696379207768696c652079656e20776f7272696573206d6f756e74204254433a3734313731313a3030303030303030303030303030303030303037356634626330386531643738613361623361663832373464313333333463306163326465323533303937363800000000")
println("Height ${hdr.height} Size ${hdr.size} Chain Work ${hdr.chainWork}")
val tx = hdr.txes[0]
println("Tx 0 inputs: ${tx.inputs.size}")
println("Tx 0 outputs: ${tx.outputs.size}")

// I'm cheating here a little because I know this is the genesis block so I know that the last output
// of the last transaction is text within an OP_RETURN script.
val output0Asm = tx.outputs.last().script.toAsm(" ")
println("tx 0 output 0: $output0Asm")
val stmts = tx.outputs.last().script.parsed()
println("\nNexa genesis block says:" + OP.parse(stmts.last()).data!!.decodeUtf8())

// Create a regtest address object
val addr = PayAddress("nexareg:nqtsq5g53q3sqyhhp45a86792a7wkkm3gyw9gylhp7kr703l")
}

fun docWalletExample()
{
// This needs to be run before APIs are called, but you should do a single time upon app startup
initializeLibNexa()

// This call automatically creates the underlying blockchain object if it hasn't already been created.
val wal = openOrNewWallet("exampleWallet", ChainSelector.NEXAREGTEST)
while(!wal.synced())
{
// Note that the blockchain may also be syncing headers simultaneously with the wallet syncing, so both
// numbers may increase.
//
// Sync also depends on time -- if the synced block isn't recent enough the wallet does not believe its
// synced. So if you are using REGTEST make sure you have recently created a new block before running this test.
println("syncing ${wal.chainstate?.syncedHeight} of ${wal.blockchain.curHeight}..." )
millisleep(2000U)
}

val newAddress = wal.getNewAddress()
println("wallet balance is: ${wal.balance}. An address for this wallet is ${newAddress}.")
try
{
// send some coins to myself. Amounts in this library are ALWAYS in the finest unit.
wal.send(10000, wal.getNewAddress())
}
catch (e: WalletNotEnoughBalanceException)
{
if (wal.balance <= 10000) println("You don't have enough coins to actually send.")
}
}

}

Introduction

This library is comprehensive and therefore complex. Learning it is best accomplished via example code, with this documentation used as a reference. The library contains Wallet, Blockchain, Network and Scripting sections. All are needed to implement a fully-functional Nexa wallet, but portions can be used separately if full functionality is not needed.

Basic Objects

Multiple blockchains are supported via the ChainSelector object. Currently this includes Nexa and Bitcoin Cash, and all of the secondary (i.e. regtest and testnet) networks for these two blockchains.

This is accomplished using a class hierarchy, with interfaces designated by iXXXX (for example iBlockHeader, iBlock, iTransaction, iTxInput, iTxOutput, iTxOutpoint). These interfaces are implemented by a class that implements common functionality "CommonBlockHeader", and this class is the parent of blockchain-specific derived classes (NexaBlockHeader, BchBlockHeader).

Rather than create instances of blockchain-specific classes, it is best to use the "xxxFor" and "xxxFrom" APIs (blockFor, blockFromHex, blockHeaderFor, txFor, txFromHex, txInputFor, txOutputFor).
These "factory" APIs create the correct derived class, returning the interface type. Using them, it is surprising how much common code can be written that works across both BCH and NEXA, and potentially other UTXO-based chains.

Blockchains and Wallets

APIs exist to create wallets, launch blockchains, and attach the two. Right now, a wallet can only attach to a single blockchain. See newWallet, openWallet, and deleteWallet.

Blockchain

The Blockchain class represents a blockchain and synchronizes with the public chain. It stores block headers to a database and has APIs to query the chain.

Blockchain objects (Blocks and Transactions)

Although one may create Nexa or Bch objects directly, it is recommended that construction of blockchain objects occur via global helper functions:

  • txFor, txFromHex, txInputFor, txOutputFor

  • blockHeaderFor, blockHeaderFromHex, and merkleBlockFor

These functions will create the correct blockchain-specific derived class, returning the parent iXXXX object. By doing this whenever possible, you maximize the likelihood that your source code will apply to multiple blockchains. To use blockchain-specific functionality, you may downcast "(header as NexaBlockHeader)" when needed.

Network Access

You may access either P2P or Electrum nodes in the network via the RequestMgr class. This class automatically manages connection for you. Going lower, you may directly connect to a specific node via the P2pClient or ElectrumClient classes.

Scripting

Full scripting functionality is available via the OP class, which captures all opcodes, and via the SatoshiScript and ScriptTemplate classes.
The SatoshiScript class is the generalized script language. ScriptTemplate creates the Nexa-specific script template transaction output. Note that a partner library Nexa Script Machine can be used to execute and debug these scripts.

Wallet

At the top level, the Bip44Wallet exists to create an manage a bip-44 compliant (meaning based on a 12-word recovery key) wallet. If set up, this object automatically uses the Blockchain Network and Scripting APIs to automatically sync with the blockchain and parse and create transactions. However, it is also possible to use this object in an offline mode, simply by not "hooking" it to a network object. After creating this object, use the Wallet interface for general purpose functionality, to allow your code to work with any wallet type.

Example

import org.nexa.libnexakotlin.*

class Test
{

fun docObjectExample()
{
// This is the Nexa genesis block
val hdr = blockFromHex(ChainSelector.NEXA, "00000000000000000000000000000000000000000000000000000000000000000000011e0000000000000000000000000000000000000000000000000000000000000000cdafb522e41f4b94618c8ee546f0fab8aaae7057f80e4730ea32df145dec73910000000000000000000000000000000000000000000000000000000000000000c0b2b16200ffffff00000000000000000000000000000000000000000000000000000000007201000000000000010000000403001700010000020000000000000000000100000000000000000000a06a00023b1c4c99526575746572733a204a6170616e20504d204b697368696461206261636b7320424f4a20756c7472612d6561737920706f6c696379207768696c652079656e20776f7272696573206d6f756e74204254433a3734313731313a3030303030303030303030303030303030303037356634626330386531643738613361623361663832373464313333333463306163326465323533303937363800000000")
println("Height ${hdr.height} Size ${hdr.size} Chain Work ${hdr.chainWork}")
val tx = hdr.txes[0]
println("Tx 0 inputs: ${tx.inputs.size}")
println("Tx 0 outputs: ${tx.outputs.size}")

// I'm cheating here a little because I know this is the genesis block so I know that the last output
// of the last transaction is text within an OP_RETURN script.
val output0Asm = tx.outputs.last().script.toAsm(" ")
println("tx 0 output 0: $output0Asm")
val stmts = tx.outputs.last().script.parsed()
println("\nNexa genesis block says:" + OP.parse(stmts.last()).data!!.decodeUtf8())

// Create a regtest address object
val addr = PayAddress("nexareg:nqtsq5g53q3sqyhhp45a86792a7wkkm3gyw9gylhp7kr703l")
}

fun docWalletExample()
{
// This needs to be run before APIs are called, but you should do a single time upon app startup
initializeLibNexa()

// This call automatically creates the underlying blockchain object if it hasn't already been created.
val wal = openOrNewWallet("exampleWallet", ChainSelector.NEXAREGTEST)
while(!wal.synced())
{
// Note that the blockchain may also be syncing headers simultaneously with the wallet syncing, so both
// numbers may increase.
//
// Sync also depends on time -- if the synced block isn't recent enough the wallet does not believe its
// synced. So if you are using REGTEST make sure you have recently created a new block before running this test.
println("syncing ${wal.chainstate?.syncedHeight} of ${wal.blockchain.curHeight}..." )
millisleep(2000U)
}

val newAddress = wal.getNewAddress()
println("wallet balance is: ${wal.balance}. An address for this wallet is ${newAddress}.")
try
{
// send some coins to myself. Amounts in this library are ALWAYS in the finest unit.
wal.send(10000, wal.getNewAddress())
}
catch (e: WalletNotEnoughBalanceException)
{
if (wal.balance <= 10000) println("You don't have enough coins to actually send.")
}
}

}

Introduction

This library is comprehensive and therefore complex. Learning it is best accomplished via example code, with this documentation used as a reference. The library contains Wallet, Blockchain, Network and Scripting sections. All are needed to implement a fully-functional Nexa wallet, but portions can be used separately if full functionality is not needed.

Basic Objects

Multiple blockchains are supported via the ChainSelector object. Currently this includes Nexa and Bitcoin Cash, and all of the secondary (i.e. regtest and testnet) networks for these two blockchains.

This is accomplished using a class hierarchy, with interfaces designated by iXXXX (for example iBlockHeader, iBlock, iTransaction, iTxInput, iTxOutput, iTxOutpoint). These interfaces are implemented by a class that implements common functionality "CommonBlockHeader", and this class is the parent of blockchain-specific derived classes (NexaBlockHeader, BchBlockHeader).

Rather than create instances of blockchain-specific classes, it is best to use the "xxxFor" and "xxxFrom" APIs (blockFor, blockFromHex, blockHeaderFor, txFor, txFromHex, txInputFor, txOutputFor).
These "factory" APIs create the correct derived class, returning the interface type. Using them, it is surprising how much common code can be written that works across both BCH and NEXA, and potentially other UTXO-based chains.

Blockchains and Wallets

APIs exist to create wallets, launch blockchains, and attach the two. Right now, a wallet can only attach to a single blockchain. See newWallet, openWallet, and deleteWallet.

Blockchain

The Blockchain class represents a blockchain and synchronizes with the public chain. It stores block headers to a database and has APIs to query the chain.

Blockchain objects (Blocks and Transactions)

Although one may create Nexa or Bch objects directly, it is recommended that construction of blockchain objects occur via global helper functions:

  • txFor, txFromHex, txInputFor, txOutputFor

  • blockHeaderFor, blockHeaderFromHex, and merkleBlockFor

These functions will create the correct blockchain-specific derived class, returning the parent iXXXX object. By doing this whenever possible, you maximize the likelihood that your source code will apply to multiple blockchains. To use blockchain-specific functionality, you may downcast "(header as NexaBlockHeader)" when needed.

Network Access

You may access either P2P or Electrum nodes in the network via the RequestMgr class. This class automatically manages connection for you. Going lower, you may directly connect to a specific node via the P2pClient or ElectrumClient classes.

Scripting

Full scripting functionality is available via the OP class, which captures all opcodes, and via the SatoshiScript and ScriptTemplate classes.
The SatoshiScript class is the generalized script language. ScriptTemplate creates the Nexa-specific script template transaction output. Note that a partner library Nexa Script Machine can be used to execute and debug these scripts.

Wallet

At the top level, the Bip44Wallet exists to create an manage a bip-44 compliant (meaning based on a 12-word recovery key) wallet. If set up, this object automatically uses the Blockchain Network and Scripting APIs to automatically sync with the blockchain and parse and create transactions. However, it is also possible to use this object in an offline mode, simply by not "hooking" it to a network object. After creating this object, use the Wallet interface for general purpose functionality, to allow your code to work with any wallet type.

Example

import org.nexa.libnexakotlin.*

class Test
{

fun docObjectExample()
{
// This is the Nexa genesis block
val hdr = blockFromHex(ChainSelector.NEXA, "00000000000000000000000000000000000000000000000000000000000000000000011e0000000000000000000000000000000000000000000000000000000000000000cdafb522e41f4b94618c8ee546f0fab8aaae7057f80e4730ea32df145dec73910000000000000000000000000000000000000000000000000000000000000000c0b2b16200ffffff00000000000000000000000000000000000000000000000000000000007201000000000000010000000403001700010000020000000000000000000100000000000000000000a06a00023b1c4c99526575746572733a204a6170616e20504d204b697368696461206261636b7320424f4a20756c7472612d6561737920706f6c696379207768696c652079656e20776f7272696573206d6f756e74204254433a3734313731313a3030303030303030303030303030303030303037356634626330386531643738613361623361663832373464313333333463306163326465323533303937363800000000")
println("Height ${hdr.height} Size ${hdr.size} Chain Work ${hdr.chainWork}")
val tx = hdr.txes[0]
println("Tx 0 inputs: ${tx.inputs.size}")
println("Tx 0 outputs: ${tx.outputs.size}")

// I'm cheating here a little because I know this is the genesis block so I know that the last output
// of the last transaction is text within an OP_RETURN script.
val output0Asm = tx.outputs.last().script.toAsm(" ")
println("tx 0 output 0: $output0Asm")
val stmts = tx.outputs.last().script.parsed()
println("\nNexa genesis block says:" + OP.parse(stmts.last()).data!!.decodeUtf8())

// Create a regtest address object
val addr = PayAddress("nexareg:nqtsq5g53q3sqyhhp45a86792a7wkkm3gyw9gylhp7kr703l")
}

fun docWalletExample()
{
// This needs to be run before APIs are called, but you should do a single time upon app startup
initializeLibNexa()

// This call automatically creates the underlying blockchain object if it hasn't already been created.
val wal = openOrNewWallet("exampleWallet", ChainSelector.NEXAREGTEST)
while(!wal.synced())
{
// Note that the blockchain may also be syncing headers simultaneously with the wallet syncing, so both
// numbers may increase.
//
// Sync also depends on time -- if the synced block isn't recent enough the wallet does not believe its
// synced. So if you are using REGTEST make sure you have recently created a new block before running this test.
println("syncing ${wal.chainstate?.syncedHeight} of ${wal.blockchain.curHeight}..." )
millisleep(2000U)
}

val newAddress = wal.getNewAddress()
println("wallet balance is: ${wal.balance}. An address for this wallet is ${newAddress}.")
try
{
// send some coins to myself. Amounts in this library are ALWAYS in the finest unit.
wal.send(10000, wal.getNewAddress())
}
catch (e: WalletNotEnoughBalanceException)
{
if (wal.balance <= 10000) println("You don't have enough coins to actually send.")
}
}

}

Introduction

This library is comprehensive and therefore complex. Learning it is best accomplished via example code, with this documentation used as a reference. The library contains Wallet, Blockchain, Network and Scripting sections. All are needed to implement a fully-functional Nexa wallet, but portions can be used separately if full functionality is not needed.

Basic Objects

Multiple blockchains are supported via the ChainSelector object. Currently this includes Nexa and Bitcoin Cash, and all of the secondary (i.e. regtest and testnet) networks for these two blockchains.

This is accomplished using a class hierarchy, with interfaces designated by iXXXX (for example iBlockHeader, iBlock, iTransaction, iTxInput, iTxOutput, iTxOutpoint). These interfaces are implemented by a class that implements common functionality "CommonBlockHeader", and this class is the parent of blockchain-specific derived classes (NexaBlockHeader, BchBlockHeader).

Rather than create instances of blockchain-specific classes, it is best to use the "xxxFor" and "xxxFrom" APIs (blockFor, blockFromHex, blockHeaderFor, txFor, txFromHex, txInputFor, txOutputFor).
These "factory" APIs create the correct derived class, returning the interface type. Using them, it is surprising how much common code can be written that works across both BCH and NEXA, and potentially other UTXO-based chains.

Blockchains and Wallets

APIs exist to create wallets, launch blockchains, and attach the two. Right now, a wallet can only attach to a single blockchain. See newWallet, openWallet, and deleteWallet.

Blockchain

The Blockchain class represents a blockchain and synchronizes with the public chain. It stores block headers to a database and has APIs to query the chain.

Blockchain objects (Blocks and Transactions)

Although one may create Nexa or Bch objects directly, it is recommended that construction of blockchain objects occur via global helper functions:

These functions will create the correct blockchain-specific derived class, returning the parent iXXXX object. By doing this whenever possible, you maximize the likelihood that your source code will apply to multiple blockchains. To use blockchain-specific functionality, you may downcast "(header as NexaBlockHeader)" when needed.

Network Access

You may access either P2P or Electrum nodes in the network via the RequestMgr class. This class automatically manages connection for you. Going lower, you may directly connect to a specific node via the P2pClient or ElectrumClient classes.

Scripting

Full scripting functionality is available via the OP class, which captures all opcodes, and via the SatoshiScript and ScriptTemplate classes.
The SatoshiScript class is the generalized script language. ScriptTemplate creates the Nexa-specific script template transaction output. Note that a partner library Nexa Script Machine can be used to execute and debug these scripts.

Wallet

At the top level, the Bip44Wallet exists to create an manage a bip-44 compliant (meaning based on a 12-word recovery key) wallet. If set up, this object automatically uses the Blockchain Network and Scripting APIs to automatically sync with the blockchain and parse and create transactions. However, it is also possible to use this object in an offline mode, simply by not "hooking" it to a network object. After creating this object, use the Wallet interface for general purpose functionality, to allow your code to work with any wallet type.

Example

import org.nexa.libnexakotlin.*

class Test
{

fun docObjectExample()
{
// This is the Nexa genesis block
val hdr = blockFromHex(ChainSelector.NEXA, "00000000000000000000000000000000000000000000000000000000000000000000011e0000000000000000000000000000000000000000000000000000000000000000cdafb522e41f4b94618c8ee546f0fab8aaae7057f80e4730ea32df145dec73910000000000000000000000000000000000000000000000000000000000000000c0b2b16200ffffff00000000000000000000000000000000000000000000000000000000007201000000000000010000000403001700010000020000000000000000000100000000000000000000a06a00023b1c4c99526575746572733a204a6170616e20504d204b697368696461206261636b7320424f4a20756c7472612d6561737920706f6c696379207768696c652079656e20776f7272696573206d6f756e74204254433a3734313731313a3030303030303030303030303030303030303037356634626330386531643738613361623361663832373464313333333463306163326465323533303937363800000000")
println("Height ${hdr.height} Size ${hdr.size} Chain Work ${hdr.chainWork}")
val tx = hdr.txes[0]
println("Tx 0 inputs: ${tx.inputs.size}")
println("Tx 0 outputs: ${tx.outputs.size}")

// I'm cheating here a little because I know this is the genesis block so I know that the last output
// of the last transaction is text within an OP_RETURN script.
val output0Asm = tx.outputs.last().script.toAsm(" ")
println("tx 0 output 0: $output0Asm")
val stmts = tx.outputs.last().script.parsed()
println("\nNexa genesis block says:" + OP.parse(stmts.last()).data!!.decodeUtf8())

// Create a regtest address object
val addr = PayAddress("nexareg:nqtsq5g53q3sqyhhp45a86792a7wkkm3gyw9gylhp7kr703l")
}

fun docWalletExample()
{
// This needs to be run before APIs are called, but you should do a single time upon app startup
initializeLibNexa()

// This call automatically creates the underlying blockchain object if it hasn't already been created.
val wal = openOrNewWallet("exampleWallet", ChainSelector.NEXAREGTEST)
while(!wal.synced())
{
// Note that the blockchain may also be syncing headers simultaneously with the wallet syncing, so both
// numbers may increase.
//
// Sync also depends on time -- if the synced block isn't recent enough the wallet does not believe its
// synced. So if you are using REGTEST make sure you have recently created a new block before running this test.
println("syncing ${wal.chainstate?.syncedHeight} of ${wal.blockchain.curHeight}..." )
millisleep(2000U)
}

val newAddress = wal.getNewAddress()
println("wallet balance is: ${wal.balance}. An address for this wallet is ${newAddress}.")
try
{
// send some coins to myself. Amounts in this library are ALWAYS in the finest unit.
wal.send(10000, wal.getNewAddress())
}
catch (e: WalletNotEnoughBalanceException)
{
if (wal.balance <= 10000) println("You don't have enough coins to actually send.")
}
}

}

Types

Link copied to clipboard
Link copied to clipboard
class AndroidLogging(val module: String) : iLogging
Link copied to clipboard
open class AsyncOpTracker(var title: String, val update: suspend (AsyncOpTracker) -> Unit)
Link copied to clipboard
class AsyncTransactionSigner(val w: Wallet, val tx: iTransaction, val sigHashType: ByteArray = byteArrayOf(), val coctxt: CoroutineContext, var title: String, val update: suspend (AsyncOpTracker) -> Unit) : CoOpTracker
Link copied to clipboard
open class BadCryptoException(msg: String = "bad crypto code") : LibNexaException
Link copied to clipboard
open class BadHeadersProvided(val blockHash: Hash256) : HeadersNotForthcoming
Link copied to clipboard
class BanData(val reason: BanReason)

Data related to why we banned a node

Link copied to clipboard

Indicate why we chose not to connect to a node

Link copied to clipboard
class BchBlock(val chainSelector: ChainSelector) : BchBlockHeader, iBlock
Link copied to clipboard

Header of a block for bitcoin-family cryptocurrencies

Link copied to clipboard
class BchBlockHeaderDb(val name: String, val sql: SqlDriver) : BlockHeaderDatabase
Link copied to clipboard

A block that contains a subset of the total number of transactions, and includes a merkle proof that the provided transactions are part of the block

Link copied to clipboard
interface BCHserializable
Link copied to clipboard
class BCHserialized(_format: SerializationType, notCopiedData: ByteArray? = null, sizeHint: Int = 1024)
Link copied to clipboard
class BchTransaction(val chainSelector: ChainSelector) : iTransaction

Bitcoin transaction

Link copied to clipboard
class BchTxInput(val chainSelector: ChainSelector) : iTxInput

Spend a coin (aka UTXO, prevout) in a transaction

Link copied to clipboard
data class BchTxOutpoint(val txid: Hash256, var idx: Long) : iTxOutpoint
Link copied to clipboard
class BchTxOutput(val chainSelector: ChainSelector) : iTxOutput

Output of a bitcoin transaction

Link copied to clipboard
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

Link copied to clipboard

Helper class that saves/loads data needed by the Bip44Wallet

Link copied to clipboard
class Blockchain(val chainSelector: ChainSelector, val name: String, val net: CnxnMgr, val genesisBlockHash: Hash256, var checkpointPriorBlockId: Hash256, var checkpointId: Hash256, var checkpointHeight: Long, var checkpointWork: BigInteger, val dbPrefix: String = "blkhdr_", var fullSync: Boolean = true)

Access and track a blockchain

Link copied to clipboard
open class BlockchainException(msg: String, val shortMsg: String? = null, val severity: ErrorSeverity = ErrorSeverity.Abnormal) : LibNexaException
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

An array of block hashes, starting at the current block, and ending at the genesis block. The creator can skip blocks, populating whatever hashes he feels is most likely to identify a specific chain, closest to the splitoff point. Typically, some kind of exponential backoff is used. For example: The next 10 hashes are the previous 10 blocks (gap 1). After these, the gap is multiplied by 2 for each hash, until the genesis block is added

Link copied to clipboard
open class BlockNotForthcoming(val blockHash: Hash256) : BlockchainException
Link copied to clipboard

Bloom filter update flags Must be consistent with same named fields in C++ code in bloom.h:bloomflags

Link copied to clipboard
class ByteArraySlice(val data: ByteArray, val start: Int, val size: Int)
Link copied to clipboard
open class Bytes(d: ByteArray) : Comparable<Bytes>

This class is needed because ByteArray's equality is by object, not contents. So ByteArrays probably do not work as you expect as the key in any map-like data structures, for example.

Link copied to clipboard
class CallAfter(var doneBits: Long = 0, var fn: () -> Unit? = null)
Link copied to clipboard
class CallAfterN(val fn: () -> Unit?, val count: Long)

Call the passed function after this function has been called 'count times

Link copied to clipboard
open class Callbacker<T>

Organize multiple callbacks for a function that accepts a single parameter

Link copied to clipboard
open class Callbacker2<T0, T1>

Organize multiple callbacks for a function that accepts two parameters. This is a convenience class for this common case. For larger numbers of parameters you can always place them in an object or a list and use the single-parameter callbacker

Link copied to clipboard
Link copied to clipboard
open class CapdException(msg: String, val capdMsg: CapdMsg? = null) : LibNexaException
Link copied to clipboard
class CapdMsg(var data: ByteArray? = null) : BCHserializable

A CAPD message (see https://spec.nexa.org/network/capd/)

Link copied to clipboard
Link copied to clipboard
class CapdQuery(var cookie: Long, var type: Int, var start: Long, var quantity: Long, var content: ByteArray) : BCHserializable

A CAPD message (see https://spec.nexa.org/network/capd/)

Link copied to clipboard
open class CapdTooDifficult(msg: String, val capdMsg: CapdMsg? = null) : CapdException
Link copied to clipboard

Identify the cryptocurrency/blockchain.

Link copied to clipboard
annotation class cli(val display: Display, val help: String, val delve: Int = 0)

Indicates that a member field or function should be displayed in the command line interface (if one is enabled). Note that the CLI only works for JVM platforms right now, because it requires reflection.

Link copied to clipboard
abstract class CnxnMgr(val chainSelector: ChainSelector)

The CnxnMgr handles discovery, connection, and maintenance of all connections into the Peer-2-Peer network. This allows higher layers to treat peers as a grab bag of nodes, ignoring issues like reconnecting, periodically cycling connections, and searching for new nodes.

Link copied to clipboard
class CoCond<T>(val scope: CoroutineScope)

Behaves like a condition, but for co-routines

Link copied to clipboard
class Codec
Link copied to clipboard
Link copied to clipboard
abstract class CommonCnxnMgr(netType: ChainSelector) : CnxnMgr
Link copied to clipboard
abstract class CommonWallet(val name: String, val chainSelector: ChainSelector) : Wallet

This class provides implementations to for functions that are common to many blockchains and wallet types

Link copied to clipboard
abstract class CoOpTracker(val coctxt: CoroutineContext, var title: String, val update: suspend (AsyncOpTracker) -> Unit) : AsyncOpTracker
Link copied to clipboard
Link copied to clipboard
expect class DecimalFormat(fmtSpec: String)
actual class DecimalFormat(val fmtSpec: String)
Link copied to clipboard
open class DeserializationException(msg: String, val shortMsg: String? = null) : LibNexaException
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
class EJ(val json: JsonElement?)
Link copied to clipboard
class ElectrumClient(val chainSelector: ChainSelector, val name: String, val port: Int = DEFAULT_NEXA_SSL_ELECTRUM_PORT, val logName: String = name + ":" + port, autostart: Boolean = true, val useSSL: Boolean = true, connectTimeoutMs: Long = JsonRpc.CONNECT_TIMEOUT, accessTimeoutMs: Long = JsonRpc.ACCESS_TIMEOUT) : JsonRpc

Open a JSON-RPC over TCP connection to an Electrum X server

Link copied to clipboard
class ElectrumConnectError(node: String, underlyingError: String) : ElectrumException

Electrum server never replied

Link copied to clipboard
Link copied to clipboard

The reply doesn't adhere to the protocol in some manner

Link copied to clipboard

The request was not accepted by the server

Link copied to clipboard

A passed entity was not found (transaction, block, scripthash, etc).

Link copied to clipboard

Electrum server never replied

Link copied to clipboard

Electrum server never replied

Link copied to clipboard
Link copied to clipboard
class exactBytes(val data: ByteArray)

This class behaves like a function and its sole purpose is to wrap a bytearray into another class so that when we serialize it we know not to include the length

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

Helper class that glues a wallet to a blockchain

Link copied to clipboard
Link copied to clipboard
@Serializable
data class GroupId(var blockchain: ChainSelector, var data: ByteArray) : BCHserializable
Link copied to clipboard
@Serializable
data class GroupInfo(var groupId: GroupId, var tokenAmt: Long, var authorityFlags: ULong = 0.toULong())

Decoded data about a group that is stored in transactions outputs

Link copied to clipboard
class Guid(var data: Hash256 = Hash256()) : BCHserializable
Link copied to clipboard
@Serializable
data class Hash256(val hash: ByteArray = ByteArray(32, { _ -> 0 })) : BCHserializable
Link copied to clipboard
Link copied to clipboard
interface iBlock : iBlockHeader
Link copied to clipboard
Link copied to clipboard
class IdentityDomain(var domain: String, var useIdentity: Long) : BCHserializable
Link copied to clipboard
data class IdentityInfo(var identityKey: String = COMMON_IDENTITY_SEED) : BCHserializable
Link copied to clipboard
interface iLogging
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
class InteractiveMultisigDestination(chain: ChainSelector, var convoSecret: ByteArray, var minSigs: Int, var pubkeys: Array<Bytes>, var privkeys: Array<Secret?>, var comms: ProtocolCommunication) : Pay2TemplateDestination
Link copied to clipboard
open class InUseException(msg: String, val shortMsg: String? = null) : LibNexaException
Link copied to clipboard
class Inv(var type: Inv.Types = Types.ILLEGAL, var id: Hash256 = Hash256.ZERO) : BCHserializable
Link copied to clipboard
data class IpPort(val ip: String, val port: Int, val resolutionNeeded: Boolean = false)

Helper class to pass around ip and port pairs If resolutionNeeded is true, the system will use a nslookup to resolve this to ip addresses, and return a random one (if the domain is a seeder that returns multiple choices) when resolve is called

Link copied to clipboard
interface iTcpSocket
Link copied to clipboard
Link copied to clipboard

defines what UTXOs are being spent and proves ability to spend

Link copied to clipboard

Reference to a UTXO

Link copied to clipboard

defines new UTXOs

Link copied to clipboard
open class JsonRpc(val name: String, val port: Int, val logName: String = name + ":" + port, val useSSL: Boolean = false, connectTimeoutMs: Long = JsonRpc.CONNECT_TIMEOUT, accessTimeoutMs: Long = JsonRpc.ACCESS_TIMEOUT)

Open a JsonRpc communications channel with another node.

Link copied to clipboard
class JvmLogging(val module: String) : iLogging
Link copied to clipboard
interface KvpDatabase
Link copied to clipboard
Link copied to clipboard
open class LibNexaException(msg: String, val shortMsg: String? = null, val severity: ErrorSeverity = ErrorSeverity.Abnormal, val errCode: Int = -1) : Exception
Link copied to clipboard
Link copied to clipboard
class MockAndroidLogging(val module: String) : iLogging
Link copied to clipboard
class MultiNodeCnxnMgr(val name: String, netType: ChainSelector, seed: Array<IpPort>) : CommonCnxnMgr

A connection manager that handles connections to multiple nodes

Link copied to clipboard
class MultisigDestination(chain: ChainSelector, val minSigs: Int, val pubkeys: Array<Bytes>, val privkeys: Array<Secret?>) : Pay2TemplateDestination
Link copied to clipboard
class MultisigP2SHDestination(chain: ChainSelector, val minSigs: Int, val pubkeys: Array<ByteArray>, val privkeys: Array<Secret?>, index: Long) : Pay2ScriptHashDestination
Link copied to clipboard
Link copied to clipboard
class NativeIosLogging(val module: String)
Link copied to clipboard
class NativeLinuxLogging(val module: String) : iLogging
Link copied to clipboard
class NativeMacosLogging(val module: String)
Link copied to clipboard
open class NetException(msg: String) : Exception
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
class NexaBlock(val chainSelector: ChainSelector) : NexaBlockHeader, iBlock
Link copied to clipboard

Header of a block for Nexa

Link copied to clipboard
class NexaBlockHeaderDb(val name: String, val sql: SqlDriver) : BlockHeaderDatabase
Link copied to clipboard

A block that contains a subset of the total number of transactions, and includes a merkle proof that the provided transactions are part of the block

Link copied to clipboard

Construct a Nexa-style sighash type byte array

Link copied to clipboard
class NexaTransaction(val chainSelector: ChainSelector) : iTransaction

blockchain transaction

Link copied to clipboard
class NexaTxInput(val chainSelector: ChainSelector) : iTxInput

Spend a coin (aka UTXO, prevout) in a transaction

Link copied to clipboard
data class NexaTxOutpoint(val hash: Hash256) : iTxOutpoint
Link copied to clipboard
class NexaTxOutput(val chainSelector: ChainSelector) : iTxOutput

Output of a bitcoin transaction

Link copied to clipboard
Link copied to clipboard
data class Nvh(val name: String, val value: Any?, val help: String)
Link copied to clipboard
class Objectify<T>(var obj: T)

Make some type (probably a primitive type) into an object that holds one of them

Link copied to clipboard
@Serializable
class OP(val v: ByteArray)
Link copied to clipboard
class P2pClient(val chainSelector: ChainSelector, val name: String, val port: Int, val logName: String, val coCtxt: CoroutineContext, val jobPool: ThreadJobPool = libNexaJobPool)
Link copied to clipboard
Link copied to clipboard
open class P2PException(msg: String) : NetException
Link copied to clipboard
Link copied to clipboard
class Pay2PubKeyHashDestination(val chainSelector: ChainSelector, var secret: Secret, idx: Long) : PayDestination

Represents a "standard" P2PKH payment destination

Link copied to clipboard
class Pay2PubKeyTemplateDestination(val chainSelector: ChainSelector, var secret: Secret, idx: Long) : PayDestination

Represents a "standard" P2PKT payment destination

Link copied to clipboard
open class Pay2ScriptHashDestination(val chainSelector: ChainSelector, idx: Long) : PayDestination

Represents an arbitrary P2SH destination

Link copied to clipboard
class Pay2ScriptPubKeyDestination(val chainSelector: ChainSelector, val secret: Secret, idx: Long) : PayDestination

Represents a P2PK (pay to public key) destination wrapped in a P2SH script

Link copied to clipboard
Link copied to clipboard
data class PayAddress(var blockchain: ChainSelector, var type: PayAddressType, var data: ByteArray) : BCHserializable
Link copied to clipboard
Link copied to clipboard
open class PayAddressException(msg: String, val shortMsg: String? = null, val severity: ErrorSeverity = ErrorSeverity.Expected) : LibNexaException
Link copied to clipboard
Link copied to clipboard
abstract class PayDestination(val chainSelector: ChainSelector) : BCHserializable

A destination for payments. This includes all the information needed to send and spend from this destination. It is often assumed that Bitcoin addresses are payment destinations, but this is not true. You really need an output script, and also (if P2SH) a redeem script. The reason why P2PKH addresses "work" as payment destinations is because they imply a specific script. But "baking in" this assumption will make the wallet a lot less flexible.

Link copied to clipboard
Link copied to clipboard

This is a clean-room implementation of PBKDF2 using RFC 2898 as a reference.

Link copied to clipboard
class Periodically(var periodInMs: Long)

keep track of when something can happen, if there's a minimum time interval where it should happen

Link copied to clipboard
open class PermissionDeniedException(msg: String, val shortMsg: String? = null) : LibNexaException
Link copied to clipboard

This class tracks possible blockchain nodes -- we have learned about this node from some source but the data may not be accurate

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
data class RejectInfo(val command: String, val code: Int, val msg: String, val objHash: Hash256)
Link copied to clipboard
open class RequestedPrehistoryHeader(val blockHash: Hash256, val lastBlock: iBlockHeader?) : HeadersNotForthcoming
Link copied to clipboard
class RequestMgr(val net: CnxnMgr, val genesisBlockHash: Hash256)
Link copied to clipboard
Link copied to clipboard
open class SatoshiScript(val chainSelector: ChainSelector) : BCHserializable

A script the can be run in Nexa or BCH transaction validation virtual machine

Link copied to clipboard
open class ScriptException(msg: String, val shortMsg: String? = null, val severity: ErrorSeverity = ErrorSeverity.Abnormal) : LibNexaException
Link copied to clipboard
data class ScriptTemplate(var groupInfo: GroupInfo?, val templateHash: ByteArray?, val wellKnownId: Long?, val argsHash: ByteArray?, val rest: List<ByteArray>)
Link copied to clipboard
abstract class Secret
Link copied to clipboard
class SecretKeyCommon(val encoded: ByteArray)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
class SocketAddress(val addr: String)
Link copied to clipboard
class SocketOptions(var noDelay: Boolean, var receiveBufferSize: Int, var sendBufferSize: Int, var timeout: Int = 3000, var tls: Boolean = false, var keepalive: Boolean = false)
Link copied to clipboard
class Spendable(var chainSelector: ChainSelector) : BCHserializable

This represents something that can be spent. It may not be spendable by ME, in which case the secret and perhaps other items will be unknown

Link copied to clipboard
open class SpendAnInput(val tx: iTransaction, val destination: PayDestination, val input: Int, val onAccept: SpendingProposal.() -> Unit) : SpendingProposal
Link copied to clipboard
abstract class SpendingProposal(val onAccept: SpendingProposal.() -> Unit)
Link copied to clipboard
class SqldelightKvDb(val name: String, val sql: SqlDriver) : KvpDatabase
Link copied to clipboard
class SqldelightKvpDatabase(val name: String, val sql: SqlDriver) : KvpDatabase
Link copied to clipboard
class SqldelightTxDatabase(val name: String, val sql: SqlDriver) : TxDatabase
Link copied to clipboard
class SqldelightTxoDatabase(val name: String, val sql: SqlDriver) : TxoDatabase
Link copied to clipboard
class SqldelightWalletDatabase(val name: String, val drvr: SqlDriver, chainSelector: ChainSelector? = null) : WalletDatabase
Link copied to clipboard
open class StringJoiner(delimiter: String)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
@Serializable
data class TokenDesc(val ticker: String, val name: String? = null, val summary: String? = null, val description: String? = null, val legal: String? = null, val creator: String? = null, val category: String? = null, val contact: Map<String, String>? = null, val icon: String? = null, val nftId: String? = null, val nftUrl: String? = null, var signedSlice: ByteArray? = null, var tddHash: ByteArray? = null, var tddSig: ByteArray? = null, var tddAddr: String? = null, var pubkey: ByteArray? = null, var marketUri: String? = null, var genesisInfo: TokenGenesisInfo? = null) : BCHserializable
Link copied to clipboard
@Serializable
data class TokenGenesisInfo(val document_hash: String?, val document_url: String?, val height: Long, val name: String?, val ticker: String?, val token_id_hex: String, val txid: String, val txidem: String, val decimal_places: Int? = null, val op_return: String? = null) : BCHserializable
Link copied to clipboard
Link copied to clipboard
class TransactionHistory(var chainSelector: ChainSelector, var tx: iTransaction) : BCHserializable
Link copied to clipboard

Let's be blunt: Kotlin enums are unusable

Link copied to clipboard
interface TxDatabase
Link copied to clipboard
interface TxoDatabase
Link copied to clipboard
open class TxSpendingProposal(val wallet: Wallet, val tx: iTransaction, val info: String, _mine: Boolean, val onAccept: SpendingProposal.() -> Unit) : SpendingProposal
Link copied to clipboard
@Serializable
data class TxValInputMetadata(val amount: String, val constraint: String, val constraintType: String, val outpoint: String, val satisfier: String, val sequence: String, val spentAmount: String)
Link copied to clipboard
@Serializable
data class TxValInputs(val isValid: Boolean, val metadata: TxValInputMetadata, val errors: List<String>)
Link copied to clipboard
@Serializable
data class TxValInputsFlags(val isValid: Boolean, val inputs: List<TxValInputs>)
Link copied to clipboard
@Serializable
data class TxValMetadata(val size: Long? = null, val txfee: Long? = null, val txfeeneeded: Long? = null)
Link copied to clipboard
@Serializable
data class TxValReply(val txid: String, val isValid: Boolean, val isMineable: Boolean, val isFutureMineable: Boolean, val isStandard: Boolean, val metadata: TxValMetadata, val errors: List<String>, val inputs_flags: TxValInputsFlags, val inputs_mandatoryFlags: TxValInputsFlags)
Link copied to clipboard
open class UnimplementedException(msg: String, val shortMsg: String? = null) : LibNexaException
Link copied to clipboard
enum Units : Enum<Units>
Link copied to clipboard
Link copied to clipboard
class UnsecuredSecret(secretBytes: ByteArray) : Secret
Link copied to clipboard
Link copied to clipboard
class variableSized(val data: ByteArray)

This class behaves like a function and its sole purpose is to wrap a bytearray into another class so that when we serialize it we know to include the length

Link copied to clipboard
abstract class Wallet(val chainSelector: ChainSelector)

This class defines a wallet interface. A wallet is a set of payment destinations that are being tracked on a particular blockchain.

Link copied to clipboard
open class WalletAuthorityException(msg: String, val severity: ErrorSeverity = ErrorSeverity.Abnormal) : WalletException
Link copied to clipboard
interface WalletDatabase
Link copied to clipboard
Link copied to clipboard
open class WalletException(msg: String, val shortMsg: String? = null, val severity: ErrorSeverity = ErrorSeverity.Abnormal) : LibNexaException
Link copied to clipboard
open class WalletFeeException(msg: String, val severity: ErrorSeverity = ErrorSeverity.Abnormal) : WalletException
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
sealed class WalletStartup
Link copied to clipboard

Properties

Link copied to clipboard
const val AES256_BLOCKSIZE: Int = 16
Link copied to clipboard
Link copied to clipboard
const val ANCESTOR_HASH_IF_ODD: Int = 5040
Link copied to clipboard
Link copied to clipboard
var appI18n: (Int) -> String

change this function to install your own translation routine

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
const val BCH_SIGHASH_ALL: Int = 65
Link copied to clipboard
const val BCH_SIGHASH_ANYONECANPAY: Int = 128
Link copied to clipboard
const val BCH_SIGHASH_NONE: Int = 66
Link copied to clipboard
const val BCH_SIGHASH_SINGLE: Int = 67
Link copied to clipboard
const val BchDecimals: Int = 8

The number of decimal places needed to express 1 satoshi in the "normal" currency units

Link copied to clipboard

How to display BCH crypto unit

Link copied to clipboard
Link copied to clipboard
val BCHmainnetPort: Int = 8333
Link copied to clipboard
const val BCHregtest2Port: Int = 8334
Link copied to clipboard
Link copied to clipboard
const val BCHregtestPort: Int = 18444
Link copied to clipboard
Link copied to clipboard
const val BCHtestnetPort: Int = 18333
Link copied to clipboard
Link copied to clipboard
var blockchainLock: iMutex
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
var CapdSolvableCutoff: BigInteger
Link copied to clipboard
Link copied to clipboard

Convert a ChainSelector to its approx currency code at 100M units

Link copied to clipboard

Convert a ChainSelector to its currency code at 100M/1000 units

Link copied to clipboard

Convert a ChainSelector to its uri and address prefix

Link copied to clipboard
val CHOP_SIZE: Int = 8192
Link copied to clipboard
Link copied to clipboard
var cnxnMgrLock: iMutex
Link copied to clipboard
Link copied to clipboard
val CURRENCY_0: BigDecimal

The decimal number 0, with the correct "currency" rounding mode CurrencyMath. Same as CURRENCY_ZERO

Link copied to clipboard
val CURRENCY_1: BigDecimal

The decimal number 1, with the correct "currency" rounding mode CurrencyMath.

Link copied to clipboard
val CURRENCY_NEG1: BigDecimal

The decimal number -1, with the correct "currency" rounding mode CurrencyMath.

Link copied to clipboard
val CURRENCY_ZERO: BigDecimal

The decimal number 0, with the correct "currency" rounding mode CurrencyMath. Same as CURRENCY_0

Link copied to clipboard

Convert a uri or address prefix to a ChainSelector -- throws exception if not found

Link copied to clipboard
Link copied to clipboard
val CurrencyMath: DecimalMode

Tell the system details about how we want bigdecimal math handled

Link copied to clipboard
const val CurrencyScale: Int = 16

How many decimal places we need to do math without creating cumulative rounding errors

Link copied to clipboard

How convert BigDecimals to strings in preparation for serialization/deserialization

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

Adjust how many blocks are held in RAM

Link copied to clipboard

Adjust how many headers are held in RAM

Link copied to clipboard

Adjust how many merkle blocks are held in RAM

Link copied to clipboard

Adjust how many tx are held in RAM

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
const val DesiredFeeSatPerByte: Double = 1.1
Link copied to clipboard
Link copied to clipboard
const val ELECTRUM_REQ_TIMEOUT: Int = 5000
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val exceptionHandler: CoroutineExceptionHandler
Link copied to clipboard
Link copied to clipboard

How all fiat currencies are displayed (2 decimal places)

Link copied to clipboard
const val HEADER_SIZE_BYTES: Int = 80
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val jsonRpcLifecycle: iMutex
Link copied to clipboard
const val KEX: Long
Link copied to clipboard

callback to notify app of any exception that happened within the coroutine launch. Return False to raise the exception, causing program abort. If null, exception is logged and ignored

Link copied to clipboard
lateinit var libnexa: LibNexa
Link copied to clipboard

Application should set this to put non-network libnexakotlin operations into their own context (for performance). network operations have their own context: @ref NetExecContext

Link copied to clipboard
var libNexaJobPool: ThreadJobPool
Link copied to clipboard
var libNexaScope: CoroutineScope
Link copied to clipboard
expect val lineSeparator: String

Provide the line separator for this platform

actual val lineSeparator: String
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Network-defined bloom filter maximum size TODO: associate this value with the blockchain

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
const val MAX_TX_INPUTS: Int = 256
Link copied to clipboard
var MaxFee: Int
Link copied to clipboard
const val MaxFeePerByte: Double = 5.0
Link copied to clipboard

How the mBCH crypto unit is displayed (5 optional decimal places)

Link copied to clipboard
val merkleBlockLock: iMutex
Link copied to clipboard
const val MEX: Long
Link copied to clipboard
const val MIN_UNUSED_ADDRESSES: Int = 20
Link copied to clipboard
const val MinFeeSatPerByte: Double = 1.01
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Application should set this to put network operations into their own context (for performance)

Link copied to clipboard
const val NEX: Long
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
const val NexaDecimals: Int = 2

The number of decimal places needed to express 1 Satoshi (or equivalent) in the units used in the GUI

Link copied to clipboard

add or remove elements in this list to control the servers that we use to get electrum data by default

Link copied to clipboard

How the NEXA crypto unit is displayed (2 optional decimal places)

Link copied to clipboard
Link copied to clipboard

How the NEX crypto is displayed in input fields (2 optional decimal places, no thousands separator)

Link copied to clipboard
val NexaMathMode: DecimalMode

Tell the system details about how we want bigdecimal math handled

Link copied to clipboard
const val NexaPort: Int = 7228
Link copied to clipboard
Link copied to clipboard
const val NexaRegtestPort: Int = 18444
Link copied to clipboard
const val NexaRegtestRpcPort: Int = 18332
Link copied to clipboard

add or remove elements in this list to control the servers that we use to get electrum data by default

Link copied to clipboard
Link copied to clipboard
const val NexaTestnetPort: Int = 7230
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val PROTOCOL_VERSION: Int = 80003
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
const val SAT: Long = 1
Link copied to clipboard
const val SATperBCH: Long

Satoshis (finest unit) per BCH unit

Link copied to clipboard
const val SATperNEX: Long = 100

Satoshis (finest unit) per NEXA unit

Link copied to clipboard
const val SATperUBCH: Long = 100

Satoshis (finest unit) per microBCH unit

Link copied to clipboard
Link copied to clipboard
val spendingProposalContext: CloseableCoroutineDispatcher
Link copied to clipboard
expect val supportsTLS: Boolean

Return true if this platform supports ktor TLS TCP sockets

actual val supportsTLS: Boolean = false
actual val supportsTLS: Boolean = true
actual val supportsTLS: Boolean = true
actual val supportsTLS: Boolean = false
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val txHashingMutex: iMutex
Link copied to clipboard
const val uBchDecimals: Int = 2

The number of decimal places needed to express 1 Satoshi (or equivalent) in the units used in the GUI

Link copied to clipboard

How the uBCH crypto unit is displayed (2 optional decimal places)

Link copied to clipboard
val uBchMathMode: DecimalMode

tell the system details about how we want bigdecimal math handled

Link copied to clipboard
Link copied to clipboard

Convert a uri or address prefix to a ChainSelector -- throws exception if not found

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun iTransaction.addChange(wallet: Wallet, changeOverride: PayAddress? = null)
Link copied to clipboard
expect fun appContext(): Any?

In platforms that use an application context object (Android), return that object. This is meant to be called only in platform specific upper layers, so each platform specific code should "know" what to cast the returned Any into.

actual fun appContext(): Any?
actual fun appContext(): Any?
Link copied to clipboard
fun assert(value: Boolean, message: String = "Assertion failed")
Link copied to clipboard

convert this byte to an int, treating the byte as unsigned I am wrapping toUByte() because something seems broken there -- toUInt().toInt() sign extends, toUByte does not. This seems inconsistent confusing.

Link copied to clipboard
expect fun awaitAvailable(cnxns: Collection<iTcpSocket>, timeout: Long = Long.MAX_VALUE): Boolean

Close a connection to trigger an early wake

Link copied to clipboard

Given recovery phrase words converted to a byte array (see @Bip39WordsToBytes) calculate the bip39 checksum

Link copied to clipboard
Link copied to clipboard

This is unlikely what you want to call. It does NOT produce the master private key, it inverts GenerateBip39SecretWords for checksum calculation

Link copied to clipboard

Return the Bip44 address number based on this blockchain

Link copied to clipboard

Construct the proper derived-class block object for the passed blockchain, and initialize it from the passed serialized data

Link copied to clipboard
fun blockFromHex(cs: ChainSelector, hex: String, serializationType: SerializationType = SerializationType.NETWORK): iBlock

Construct the proper derived-class block object for the passed blockchain, based on the passed serialized hex string

Link copied to clipboard

Construct the proper derived-class block header object for the passed blockchain, and initialize it from the passed serialized data

Link copied to clipboard
fun blockHeaderFromHex(cs: ChainSelector, hex: String, serializationType: SerializationType = SerializationType.NETWORK): iBlockHeader

Construct the proper derived-class block header object for the passed blockchain, based on the passed serialized hex string

Link copied to clipboard
fun calcSig(tx: iTransaction, inputIdx: Int, sigHashType: ByteArray, serializedTx: ByteArray? = null): ByteArray

Calculate the Schnorr signature of the passed transaction and input index This function does not update the transaction.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun chainStateDbKey(name: String, chainSelector: ChainSelector): String
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
fun cliDump(obj: Any?, level: Display = Display.User, style: DisplayStyles = DEFAULT_STYLE, depth: Int = 2, indent: Int = 0): String
Link copied to clipboard

Connect to, and return an existing blockchain. Create the blockchain object and start it processing, if it does not already exist

Link copied to clipboard
Link copied to clipboard
fun ByteArray.copyInto(to: ByteArray, location: Int = 0): ByteArray
Link copied to clipboard
expect fun createDbDriver(dbname: String, schema: SqlSchema<QueryResult.Value<Unit>>): SqlDriver
actual fun createDbDriver(dbname: String, schema: SqlSchema<QueryResult.Value<Unit>>): SqlDriver
actual fun createDbDriver(dbname: String, schema: SqlSchema<QueryResult.Value<Unit>>): SqlDriver
Link copied to clipboard
fun CurrencyDecimal(b: BigDecimal): BigDecimal

Convert a BigDecimal of unknown math mode (rounding & precision) into one that is appropriate for currency mathematics (with lots of decimal places)

fun CurrencyDecimal(a: Int): BigDecimal
fun CurrencyDecimal(a: Long): BigDecimal
fun CurrencyDecimal(a: String): BigDecimal

Create a BigDecimal that is appropriate for currency mathematics (with lots of decimal places)

Link copied to clipboard

Convert a TxOutput type raw byte into a type enum

Convert transaction output type into a script type (for correct annotation of the script contained in the output)

Convert a script type into the type field needed for the script to be used in a transaction output

Link copied to clipboard
fun cwd(): String
Link copied to clipboard
Link copied to clipboard
fun ChainSelector.decimalMode(): DecimalMode
Link copied to clipboard

Decode a token description document JSON file into a TokenDesc structure, the hash of the proper part of the TDD, and its signature bytes. check the signature and fill TokenDesc pubkey with the resulting pubkey if an address is provided, and the signature matches that address.

fun decodeTokenDescDoc(grpId: GroupId, s: String, tokenGenesisTx: iTransaction): TokenDesc
Link copied to clipboard

Convert a byte array that contains a utf8 string into a String

Link copied to clipboard
expect fun deleteDatabase(name: String): Boolean?

Path should not contain extension (will be added) & directories may be ignored if the platform places its databases in a standard location.

actual fun deleteDatabase(name: String): Boolean?
actual fun deleteDatabase(name: String): Boolean?
Link copied to clipboard
fun deleteWallet(walletName: String, chainSelector: ChainSelector)
fun deleteWallet(db: WalletDatabase, walletName: String, chainSelector: ChainSelector)

Delete a wallet on disk

Link copied to clipboard

Deserialize any object that is nullable, but prepending a byte indicating whether this object is null or not. This API should only be used for DISK serialization because this nullable technique is not part of the network protocol. However, in one case we store to disk the network serialization of an object (if it exists).

Link copied to clipboard
Link copied to clipboard
fun dictify(obj: Any, level: Display = Display.User, depth: Int = 10, resolve: Boolean = true, help: Boolean = false, toString: Boolean = true): Any?
Link copied to clipboard
fun dictifyType(kc: KClass<out Any>, obj: Any, level: Display = Display.User, depth: Int = 10, superTypes: Boolean = true, resolve: Boolean = true, help: Boolean = false, toString: Boolean = true): FieldDict?
Link copied to clipboard
fun dust(chain: ChainSelector): Long

Returns the minimum amount of native coins (in the finest unit) that must be in every UTXO.

Link copied to clipboard
Link copied to clipboard
fun String.ellipsis(maxLen: Int): String
Link copied to clipboard

Convert a string into a utf-8 encoded byte array.

Convert a string into a utf-8 encoded byte array.

Link copied to clipboard
expect fun epochMilliSeconds(): Long

Returns milliseconds since the epoch

actual fun epochMilliSeconds(): Long

Returns milliseconds since the epoch

actual fun epochMilliSeconds(): Long
actual fun epochMilliSeconds(): Long

Returns milliseconds since the epoch

actual fun epochMilliSeconds(): Long

Returns milliseconds since the epoch

Link copied to clipboard
expect fun epochSeconds(): Long

Returns seconds since the epoch

actual fun epochSeconds(): Long

Returns seconds since the epoch

actual fun epochSeconds(): Long
actual fun epochSeconds(): Long

Returns seconds since the epoch

actual fun epochSeconds(): Long

Returns seconds since the epoch

Link copied to clipboard
expect fun epochToDate(epochSeconds: Long): String
actual fun epochToDate(epochSeconds: Long): String
Link copied to clipboard
fun formatForDisplay(style: DisplayStyles, indent: Int, name: String, type: String, help: String, value: String): String
Link copied to clipboard
fun formMultisig(cs: ChainSelector, requiredSigs: Int, dests: Array<Bytes>): SatoshiScript
Link copied to clipboard
fun BchBlockHeader.Companion.fromDb(db: BchBlockHeaderTbl): BchBlockHeader
fun NexaBlockHeader.Companion.fromDb(db: NexaBlockHeaderTbl): NexaBlockHeader
Link copied to clipboard
Link copied to clipboard
fun BigDecimal.Companion.fromJavaBigDecimal(bd: <Error class: unknown class>, decimalMode: DecimalMode? = null): BigDecimal
Link copied to clipboard
fun BigDecimal.Companion.fromNullString(s: String?, dm: DecimalMode = CurrencyMath): BigDecimal?

Get a BigDecimal from a string

Link copied to clipboard
fun BigDecimal.Companion.fromString(s: String, dm: DecimalMode): BigDecimal

Get a BigDecimal from a string

Link copied to clipboard
fun GenerateBip39SecretWords(bytes: ByteArray, wordList: Array<String> = englishWordList): String
Link copied to clipboard
expect fun generateBip39Seed(wordseed: String, passphrase: String, size: Int = 64): ByteArray
actual fun generateBip39Seed(wordseed: String, passphrase: String, size: Int): ByteArray
actual fun generateBip39Seed(wordseed: String, passphrase: String, size: Int): ByteArray
actual fun generateBip39Seed(wordseed: String, passphrase: String, size: Int): ByteArray
actual fun generateBip39Seed(wordseed: String, passphrase: String, size: Int): ByteArray
Link copied to clipboard
Link copied to clipboard
fun GetAncestorHeight(height: Int): Int

Calculate the ancestor height of the block at the passed height. This follows the Nexa ancestor algorithm, returning the height of the block indicated by the ancestorHash in the Nexa block header.

Link copied to clipboard
fun getApiHelp(obj: Any, level: Display = Display.User, style: DisplayStyles = EnumSet.of(DisplayStyle.OneLine)): String?
Link copied to clipboard
fun GetBlockchain(chainSelector: ChainSelector, cnxnMgr: CnxnMgr, name: String? = null, start: Boolean = true, fullSync: Boolean = true, dbPrefix: String = defaultDbPrefix): Blockchain
Link copied to clipboard
fun getClassApiHelp(cls: KClass<*>, level: Display = Display.User, style: DisplayStyles = EnumSet.of(DisplayStyle.OneLine)): String?
Link copied to clipboard
fun getClassApis(cls: KClass<*>, level: Display = Display.User, style: DisplayStyles = EnumSet.of(DisplayStyle.OneLine)): String?
Link copied to clipboard
fun GetCnxnMgr(chain: ChainSelector, name: String? = null, start: Boolean = true): CnxnMgr
Link copied to clipboard
expect fun getFilesDir(): String?

Return the directory that this application may use for its files

actual fun getFilesDir(): String?
actual fun getFilesDir(): String?

Return the directory that this application may use for its files

Link copied to clipboard
expect fun GetLog(module: String): iLogging

get the logging object for this platform

actual fun GetLog(module: String): iLogging
actual fun GetLog(module: String): iLogging
actual fun GetLog(module: String): iLogging
actual fun GetLog(module: String): iLogging
Link copied to clipboard
fun getTokenInfo(grpId: GroupId, getEc: () -> ElectrumClient, iHave: TokenDesc? = null): TokenDesc
Link copied to clipboard
Link copied to clipboard
fun groupedFilter(groupId: GroupId, normal: Boolean = true, authority: ULong = GroupAuthorityFlags.AUTHORITY, maskOff: ULong = 0.toULong()): (Spendable) -> Long
Link copied to clipboard
fun handleThreadException(e: Throwable, s: String = "", caughtAt: String? = "")
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
expect fun iHaveInternet(): Boolean?

Return false if this node has no internet connection, or true if it does or null if you can't tell

actual fun iHaveInternet(): Boolean?

Return false if this node has no internet connection, or true if it does or null if you can't tell

actual fun iHaveInternet(): Boolean?

Return false if this node has no internet connection, or true if it does or null if you can't tell

actual fun iHaveInternet(): Boolean?

Return false if this node has no internet connection, or true if it does or null if you can't tell

actual fun iHaveInternet(): Boolean?

Return false if this node has no internet connection, or true if it does or null if you can't tell

Link copied to clipboard
expect fun initializeLibNexa(variant: String? = ""): LibNexa

Initialize the lowest level nexa library. This function loads the .so file and calls a "native" init function.

actual fun initializeLibNexa(variant: String?): LibNexa
actual fun initializeLibNexa(variant: String?): LibNexa
Link copied to clipboard
fun <K, V> Map<K, V>.invert(): Map<V, K>

Create a new map, where the keys and values are swapped

Link copied to clipboard

Turn the lowest '1' bit in the binary representation of a number into a '0'.

Link copied to clipboard
expect fun ipAsString(ba: ByteArray): String

given a byte array, convert it into some string form of IP address Should support ipv4 and ipv6 at a minimum

actual fun ipAsString(ba: ByteArray): String
actual fun ipAsString(ba: ByteArray): String

given a byte array, convert it into some string form of IP address Should support ipv4 and ipv6 at a minimum

Link copied to clipboard
fun Url.isLocal(): Boolean
Link copied to clipboard
fun isPrimitive(obj: Any?): Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun laterJob(name: String? = null, job: () -> Unit)
Link copied to clipboard
fun laterOneJob(name: String, job: () -> Unit)
Link copied to clipboard
fun launch(scope: CoroutineScope? = null, fn: suspend () -> Unit?)
Link copied to clipboard

Decode a number from little-endian sign-magnitude format (like a Nexa script num)

fun Long.leSignMag(size: Int? = null): ByteArray

Encode in little-endian sign-magnitude format (like a Nexa script num)

Link copied to clipboard
Link copied to clipboard
fun logThreadException(e: Throwable, s: String = "", caughtAt: String? = "")
Link copied to clipboard
fun max(a: Int, b: Int): Int
fun max(a: Long, b: Long): Long
Link copied to clipboard

Construct the proper derived-class merkle block object for the passed blockchain, and initialize it from the passed serialized data

Link copied to clipboard
fun millinow(): Long

Return the epoch time in milliseconds

Link copied to clipboard
fun min(a: Int, b: Int): Int
fun min(a: Long, b: Long): Long
Link copied to clipboard
fun newSpendingProposalScope(): CoroutineScope

Get a new scope to handle all coroutines related to a particular spending proposal

Link copied to clipboard

Create a new wallet. A HD BIP44 compliant recovery key will be automatically generated.

Link copied to clipboard
fun NexaDecimal(a: Int): BigDecimal
fun NexaDecimal(a: Long): BigDecimal

Create a BigDecimal that is appropriate for Nexa currency mathematics (with 2 decimal places)

Link copied to clipboard
fun NexaToSat(a: BigDecimal): Long

Convert Nexa unit to Satoshis

Link copied to clipboard
fun objectType(obj: Any, style: DisplayStyles = DEFAULT_STYLE): String
Link copied to clipboard
Link copied to clipboard

Open a plain key/value pair database for general storage

Link copied to clipboard
Link copied to clipboard

Open this wallet if it exists, or create a new HD BIP44 wallet

Link copied to clipboard

Open an existing HD BIP44 wallet.

Link copied to clipboard
fun openWalletDB(name: String, chainSelector: ChainSelector? = null): WalletDatabase?

If you are going to create a wallet DB, you must specify the chain. Otherwise its optional (will be loaded from the db)

Link copied to clipboard
Link copied to clipboard

Construct the proper derived-class outpoint object for the passed blockchain, based on the passed serialized bytes

Construct the proper derived-class outpoint object for the passed blockchain, based on the transaction identifier, and output index. You must provide the proper identifier for this blockchain (e.g. use txid for BCH and txidem for Nexa).

Link copied to clipboard
Link copied to clipboard
expect fun PlatformHttpClient(block: HttpClientConfig<*>.() -> Unit): HttpClient

Provide the best ktor http client (engine) offered by this platform

actual fun PlatformHttpClient(block: HttpClientConfig<*>.() -> Unit): HttpClient
actual fun PlatformHttpClient(block: HttpClientConfig<*>.() -> Unit): HttpClient
Link copied to clipboard
fun range(start: Int, count: Int): IntRange
Link copied to clipboard
fun Url.readBytes(timeoutInMs: Number = 30000, maxReadSize: Number = 250000000, context: CoroutineContext? = null): ByteArray

This helper function reads the contents of the URL. This duplicates the API of other URL classes

Link copied to clipboard
fun Url.readText(timeoutInMs: Number, maxReadSize: Number = 250000000, context: CoroutineContext? = null): String

load this Uri (blocking).

Link copied to clipboard
suspend fun <T> Channel<T>.receive(timeout: Long): T?

Receive from a channel with timeout

Link copied to clipboard
Link copied to clipboard
fun recoverWallet(name: String, recoveryKey: String, bc: Blockchain): Bip44Wallet
fun recoverWallet(name: String, recoveryKey: String, cs: ChainSelector): Bip44Wallet

Create a new HD BIP44 wallet from an recovery phrase.

Link copied to clipboard
operator fun String.rem(kv: Map<String, String>): String
Link copied to clipboard
fun <K, V> MutableMap<K, V>.removeByValue(value: V): Int
Link copied to clipboard
expect fun resolveDomain(domainName: String, port: Int? = null): List<ByteArray>

convert a domain name into an address

actual fun resolveDomain(domainName: String, port: Int?): List<ByteArray>
Link copied to clipboard
fun <T> retry(count: Int, fn: (Int) -> T?): T
Link copied to clipboard
fun <T> retryOnException(count: Int, sleep: Int = 10, fn: () -> T): T
Link copied to clipboard
fun returnSpendingProposalScope(cs: CoroutineScope)
Link copied to clipboard
fun SatToNexa(a: Long): BigDecimal

Convert Satoshi unit to Nexa

Link copied to clipboard
fun scriptDataFrom(scriptBytes: ByteArray): ByteArray?

Parse out the data that would be pushed to the script stack from a byte array that corresponds to a script instruction.

Link copied to clipboard
fun scriptNumFrom(scriptBytes: ByteArray): Long?

Parse out a script num from a byte array that corresponds to a script instruction pushing it to the script's stack

Link copied to clipboard
fun shouldDisplay(obj: <Error class: unknown class>, level: Display): Boolean
Link copied to clipboard
expect fun show(p: KProperty1<*, *>, obj: Any): String

Show a particular property of an object (internal CLI API)

actual fun show(p: KProperty1<*, *>, obj: Any): String
Link copied to clipboard
fun <K, V> MutableMap<K, V>.show(level: Display = Display.User, style: DisplayStyles = DEFAULT_STYLE, indent: Int = 0): String?
Link copied to clipboard
fun showAny(obj: Any?, indent: Int, maxString: Int, delimiter: String = "", dispValue: (String) -> String = {it}, dispHelp: (String) -> String = { " (" + it + ")" }): String
Link copied to clipboard
expect fun showApis(obj: Any, level: Display = Display.User, style: DisplayStyles = setOf(DisplayStyle.OneLine)): String?
actual fun showApis(obj: Any, level: Display, style: DisplayStyles): String?
Link copied to clipboard
fun showFunction(fn: KFunction<*>, level: Display = Display.User, style: DisplayStyles = DEFAULT_STYLE, indent: Int = 0): Pair<String?, String>
Link copied to clipboard
fun showHelp(s: String?, style: DisplayStyles, indent: Int, helpIdentifier: String = ""): String

Shows or doesn't show the help and formats it depending on the display style

Link copied to clipboard
expect fun showObject(obj: Any, level: Display = Display.User, style: DisplayStyles = DEFAULT_STYLE, depth: Int = 0, indent: Int = 0, maxString: Int = 300): String

Show the an object (internal CLI API)

actual fun showObject(obj: Any, level: Display, style: DisplayStyles, depth: Int, indent: Int, maxString: Int): String
Link copied to clipboard
expect fun showProperties(obj: Any, cls: KClass<*>, level: Display, style: DisplayStyles, depth: Int = 0, indent: Int = 0): String

Show the properties of an object (internal CLI API)

actual fun showProperties(obj: Any, cls: KClass<*>, level: Display, style: DisplayStyles, depth: Int, indent: Int): String
Link copied to clipboard
fun showPropertyOf(obj: Any, p: KProperty1<*, *>, level: Display, style: DisplayStyles, depth: Int, indent: Int): String
Link copied to clipboard
fun showType(typeName: String?, style: DisplayStyles = DEFAULT_STYLE): String
Link copied to clipboard
fun signInput(tx: iTransaction, idx: Long, sigHashType: ByteArray, serializedTx: ByteArray? = null): Boolean

Sign (and create the satisfier script for) one input of the passed transaction This function modifies the transaction.

Link copied to clipboard
fun signTransaction(tx: iTransaction, sigHashType: ByteArray = byteArrayOf())

signs a transaction in place, with all inputs that have a BCHspendable with secrets (skips those that do not so others can sign) by default the sighashtype is ALL/ALL

Link copied to clipboard
expect fun sourceLoc(depth: Int = 1): String

Return the source location of the caller (for debugging and logging)

actual fun sourceLoc(depth: Int): String
actual fun sourceLoc(depth: Int): String
actual fun sourceLoc(depth: Int): String
actual fun sourceLoc(depth: Int): String
Link copied to clipboard
fun splitIpPort(s: String, defaultPort: Int): IpPort

split a (IP or FQDN):port formatted string (e.g 192.168.100.10:54 or www.example.com:54) into a string IP address (or FQDN) and an integer port

Link copied to clipboard
fun <T> synchronized(g: iGate, block: () -> T): T
Link copied to clipboard
expect fun TcpSocket(sendCtxt: CoroutineContext, receiveCtxt: CoroutineContext): iTcpSocket
actual fun TcpSocket(sendCtxt: CoroutineContext, receiveCtxt: CoroutineContext): iTcpSocket
Link copied to clipboard
fun TransactionWithoutReturn.thUpsert(db: WalletDb, idem: ByteArray, h: TransactionHistory)
Link copied to clipboard
Link copied to clipboard
expect fun String.toCurrency(chainSelector: ChainSelector? = null): BigDecimal

Get this string as a BigDecimal currency value (using your default locale's number representation)

actual fun String.toCurrency(chainSelector: ChainSelector?): BigDecimal
Link copied to clipboard
fun BigDecimal.toDouble(): Double

Convert a BigDecimal to a double

Link copied to clipboard
fun BigDecimal.toInt(): Int

Convert a BigDecimal to an int

Link copied to clipboard

tokenizeScriptBin is the opposite of flatten in the sense that each element in data will be 1 instruction

Link copied to clipboard
fun BigDecimal.toLong(): Long
Link copied to clipboard

convert this byte to an Int, treating the byte as unsigned

Link copied to clipboard

convert this byte to a Long, treating the byte as unsigned

Link copied to clipboard

convert this byte to an unsigned Int, treating the byte as unsigned

Link copied to clipboard

convert this byte to an unsigned Long, treating the byte as unsigned

Link copied to clipboard
fun BigInteger.toSizedByteArray(sz: Int): ByteArray
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun Byte.toUint(): Int
Link copied to clipboard
Link copied to clipboard

Construct the proper derived-class transaction object for the passed blockchain

Construct the proper derived-class transaction object for the passed blockchain, based on the passed serialized bytes

Link copied to clipboard
fun txFromHex(cs: ChainSelector, hex: String, serializationType: SerializationType = SerializationType.NETWORK): iTransaction

Construct the proper derived-class transaction object for the passed blockchain, based on the passed serialized hex string

Link copied to clipboard
Link copied to clipboard

Construct the proper derived-class transaction input object for the passed blockchain. This object is created with default values that then need to be set to an actual input for use.

Construct the proper derived-class transaction input object for the passed blockchain, for the passed Spendable object. This does not solve the input (create a valid input script), since that would require the complete transaction.

Link copied to clipboard
Link copied to clipboard

Construct the proper derived-class transaction output object for the passed blockchain This object is created with default values that then need to be set to an actual output for use.

Construct the proper derived-class transaction output object for the passed blockchain, and initialize it from the passed serialized data

Construct the proper derived-class transaction output object for the passed blockchain, and initialize it from the passed data

Link copied to clipboard
Link copied to clipboard
fun Byte.uAsInt(): Int
Link copied to clipboard
fun UbchDecimal(a: Long): BigDecimal

Create a BigDecimal that is appropriate for u-BCH (micro bitcoin cash) currency mathematics (with 2 decimal places)

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
expect fun String.urlDecode(): String

Converts an encoded URL to a raw string

actual fun String.urlDecode(): String
actual fun String.urlDecode(): String
actual fun String.urlDecode(): String
actual fun String.urlDecode(): String
Link copied to clipboard
expect fun String.urlEncode(): String
actual fun String.urlEncode(): String
actual fun String.urlEncode(): String
actual fun String.urlEncode(): String
Link copied to clipboard
Link copied to clipboard
fun ValidBip39Checksum(words: Array<String>, wordList: Array<String> = englishWordList): Boolean

Return true if the checksum stored within the recovery key words is valid

Link copied to clipboard
Link copied to clipboard