Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
abstract fun blockHash(serializedBlockHeader: ByteArray): ByteArray

Calculates the block hash given a serialized header. Note that by convention hashes are displayed in byte-reverse order (as if a little-endian number was being displayed). This return value is not reversed. (hash.reversed().toHex() == "hex header from explorer") -> true

abstract fun blockHash(serializedBlockHeader: UByteArray): UByteArray
Link copied to clipboard
abstract fun capdCheck(capdMsg: CapdMsg): Boolean

Return true if this CAPD message is solved.

Link copied to clipboard
abstract fun capdHash(capdMsg: CapdMsg): ByteArray?

Return the hash of this message.

Link copied to clipboard
abstract fun capdSolve(capdMsg: CapdMsg): Boolean

Solve the passed CAPD message, modifying it. Return true if it was solved.

Link copied to clipboard
abstract fun createBloomFilter(items: Array<Any>, falsePosRate: Double, capacity: Int, maxSize: Int, flags: Int = 0, tweak: Int = 1): ByteArray

Given an array of items, creates a bloom filter and returns it serialized. Typical items are addresses (just the raw 20 bytes), transaction hashes, and outpoints

Link copied to clipboard
abstract fun decode64(encoded: String): ByteArray
Link copied to clipboard
abstract fun decodeCashAddr(chainSelector: ChainSelector, addr: String): ByteArray
Link copied to clipboard
abstract fun decodeWifPrivateKey(chainSelector: ChainSelector, secretWIF: String): ByteArray

Decodes a private key provided in Satoshi's original fnormat

Link copied to clipboard
open fun decryptAES256(ciphertext: ByteArray, secret: ByteArray): ByteArray

AES256 decryption if you encrypted with encryptAES256.

Link copied to clipboard
abstract fun decryptAES256by16(ciphertext: ByteArray, secret: ByteArray, initial: ByteArray): ByteArray

AES256 decryption if you KNOW the message length is a multiple of 16 (and you encrypted with encryptAES256by16) For variable sized messages, use decryptAES256.

Link copied to clipboard
abstract fun deriveHd44ChildKey(secretSeed: ByteArray, purpose: Long, coinType: Long, account: Long, change: Boolean, index: Int): Pair<ByteArray, String>

This function calculates the BIP44 key from the specified path. BIP44 requires that purpose, coinType and account are "hardened". This function will automatically harden those parameters if you pass unhardened values. Therefore this function cannot be used for generalized (non-BIP44) child key derivation.

Link copied to clipboard
abstract fun encode64(data: ByteArray): String
Link copied to clipboard
abstract fun encodeCashAddr(chainSelector: ChainSelector, type: PayAddressType, data: ByteArray): String
Link copied to clipboard
open fun encryptAES256(plaintext: ByteArray, secret: ByteArray): ByteArray

AES256 encryption of arbitrary length messages. A random initialization vector (IV) is generated and included with the ciphertext. For the maximum size efficiency when the IV can be inferred or calculated and the size is known use encryptAES256by16

Link copied to clipboard
abstract fun encryptAES256by16(plaintext: ByteArray, secret: ByteArray, initial: ByteArray): ByteArray

AES256 encryption if you KNOW the message length is a multiple of 16. This is a lower level API that offers greater size efficiency if you know what you are doing. For variable sized messages, use encryptAES256.

Link copied to clipboard
abstract fun extractFromMerkleBlock(numTxes: Int, merkleProofPath: ByteArray, hashes: Array<ByteArray>): Array<ByteArray>?
Link copied to clipboard
open fun generateBip39SecretWords(bytes: ByteArray, wordList: Array<String> = englishWordList): String
Link copied to clipboard
Link copied to clipboard
abstract fun getPubKey(privateKey: ByteArray): ByteArray

abstract fun getPubKey(privateKey: UByteArray): UByteArray

Given a private key, return the corresponding (secp256k1) public key -- that is the privKey*G where G is the group generator

Link copied to clipboard

Returns the work -- that is the expected number of hashes to find a solution -- given the difficulty expressed in Bitcoin's "bits" notation

Link copied to clipboard
abstract fun groupIdFromAddr(chainSelector: ChainSelector, addr: String): ByteArray
Link copied to clipboard
abstract fun groupIdToAddr(chainSelector: ChainSelector, data: ByteArray): String
Link copied to clipboard
abstract fun hash160(data: ByteArray): ByteArray
abstract fun hash160(data: UByteArray): UByteArray

Calculates the RIPEMD160 of the SHA256 of data. Result is 20 bytes

Link copied to clipboard
abstract fun hash256(data: ByteArray): ByteArray
abstract fun hash256(data: UByteArray): UByteArray

Returns the double sha256 of data. Result is 32 bytes

Link copied to clipboard
abstract fun minDust(chain: ChainSelector): Long

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

Link copied to clipboard
abstract fun secureRandomBytes(amt: Int): ByteArray
Link copied to clipboard
abstract fun sha256(data: ByteArray): ByteArray
abstract fun sha256(data: UByteArray): UByteArray

Returns the sha256 of data. Result is 32 bytes

Link copied to clipboard
abstract fun signBchTxOneInputUsingECDSA(txData: ByteArray, sigHashType: Int, inputIdx: Long, inputAmount: Long, prevoutScript: ByteArray, secret: ByteArray): ByteArray

Create an ECDSA signature for the passed transaction

Link copied to clipboard
abstract fun signBchTxOneInputUsingSchnorr(txData: ByteArray, sigHashType: Int, inputIdx: Long, inputAmount: Long, prevoutScript: ByteArray, secret: ByteArray): ByteArray

Create a Schnorr signature for the passed transaction

Link copied to clipboard
abstract fun signHashSchnorr(data: ByteArray, secret: ByteArray): ByteArray
abstract fun signHashSchnorr(data: UByteArray, secret: UByteArray): UByteArray
Link copied to clipboard
abstract fun signMessage(message: ByteArray, secret: ByteArray): ByteArray?

Sign a message using the same algorithm as the original bitcoin wallet's signmessage functionality

Link copied to clipboard
abstract fun signTxOneInputUsingSchnorr(txData: ByteArray, sigHashType: ByteArray, inputIdx: Long, inputAmount: Long, prevoutScript: ByteArray, secret: ByteArray): ByteArray

Create a Schnorr signature for the passed transaction

Link copied to clipboard
abstract fun txid(serializedTx: ByteArray): ByteArray
abstract fun txid(serializedTx: UByteArray): UByteArray
Link copied to clipboard
abstract fun txidem(serializedTx: ByteArray): ByteArray
abstract fun txidem(serializedTx: UByteArray): UByteArray
Link copied to clipboard
abstract fun verifyBlockHeader(chainSelector: ChainSelector, serializedBlockHeader: ByteArray): Boolean
abstract fun verifyBlockHeader(chainSelector: ChainSelector, serializedBlockHeader: UByteArray): Boolean
Link copied to clipboard
abstract fun verifyMessage(message: ByteArray, address: ByteArray, signature: ByteArray): ByteArray?

Verify a message using the same algorithm as the original bitcoin wallet's signmessage functionality