Update API docs to version 0.11.0

This commit is contained in:
thunderbiscuit 2022-11-08 13:53:49 -05:00
parent ffd85e6bd1
commit 3be23ad7f9
No known key found for this signature in database
GPG Key ID: 88253696EB836462
3 changed files with 37 additions and 18 deletions

View File

@ -27,7 +27,7 @@ tasks.withType<org.jetbrains.dokka.gradle.DokkaTask>().configureEach {
dokkaSourceSets {
named("main") {
moduleName.set("bdk-android")
moduleVersion.set("0.10.0")
moduleVersion.set("0.11.0")
includes.from("Module1.md")
samples.from("src/test/kotlin/org/bitcoindevkit/Samples.kt")
}
@ -38,7 +38,7 @@ tasks.withType<org.jetbrains.dokka.gradle.DokkaTask>().configureEach {
// dokkaSourceSets {
// named("main") {
// moduleName.set("bdk-jvm")
// moduleVersion.set("0.10.0")
// moduleVersion.set("0.11.0")
// includes.from("Module2.md")
// samples.from("src/test/kotlin/org/bitcoindevkit/Samples.kt")
// }

View File

@ -457,16 +457,6 @@ class BumpFeeTxBuilder() {
fun finish(wallet: Wallet): TxBuilderResult {}
}
/**
* Generates a new mnemonic using the English word list and the given number of words (12, 15, 18, 21, or 24).
*
* @param wordCount The number of words to use for the mnemonic (also determines the amount of entropy that is used).
* @return The mnemonic words separated by a space in a String
*
* @sample org.bitcoindevkit.generateMnemonicSample
*/
fun generateMnemonic(wordCount: WordCount): String
/**
* A BIP-32 derivation path.
*
@ -485,7 +475,7 @@ class DerivationPath(path: String) {}
* @sample org.bitcoindevkit.descriptorSecretKeyDeriveSample
* @sample org.bitcoindevkit.descriptorSecretKeyExtendSample
*/
class DescriptorSecretKey(network: Network, mnemonic: String, password: String?) {
class DescriptorSecretKey(network: Network, mnemonic: Mnemonic, password: String?) {
/** Derive a private descriptor at a given path. */
fun derive(path: DerivationPath): DescriptorSecretKey {}
@ -568,3 +558,25 @@ class Address(address: String) {
/* Return the ScriptPubKey. */
fun scriptPubkey(): Script
}
/**
* Mnemonic phrases are a human-readable version of the private keys. Supported number of words are 12, 15, 18, 21 and 24.
*
* @constructor Generates Mnemonic with a random entropy.
* @param mnemonic The mnemonic as a string of space-separated words.
*
* @sample org.bitcoindevkit.mnemonicSample
*/
class Mnemonic(mnemonic: String) {
/* Returns Mnemonic as string */
fun asString(): String
/* Parse a Mnemonic from a given string. */
fun fromString(): Mnemonic
/*
* Create a new Mnemonic in the specified language from the given entropy. Entropy must be a
* multiple of 32 bits (4 bytes) and 128-256 bits in length.
*/
fun fromEntropy(): Mnemonic
}

View File

@ -130,7 +130,7 @@ fun descriptorSecretKeyExtendSample() {
// The `DescriptorSecretKey.extend()` method allows you to extend a key to any given path.
// val mnemonic: String = generateMnemonic(WordCount.WORDS12)
val mnemonic: String = "scene change clap smart together mind wheel knee clip normal trial unusual"
val mnemonic: Mnemonic = Mnemonic("scene change clap smart together mind wheel knee clip normal trial unusual")
// the initial DescriptorSecretKey will always be at the "master" node,
// i.e. the derivation path is empty
@ -159,7 +159,7 @@ fun descriptorSecretKeyDeriveSample() {
// The DescriptorSecretKey.derive() method allows you to derive an extended key for a given
// node in the derivation tree (for example to create an xpub for a particular account)
val mnemonic: String = "scene change clap smart together mind wheel knee clip normal trial unusual"
val mnemonic: Mnemonic = Mnemonic("scene change clap smart together mind wheel knee clip normal trial unusual")
val bip32RootKey: DescriptorSecretKey = DescriptorSecretKey(
network = Network.TESTNET,
mnemonic = mnemonic,
@ -221,6 +221,13 @@ fun walletSample() {
)
}
fun generateMnemonicSample() {
val mnemonic: String = generateMnemonic(WordCount.WORDS12)
}
fun mnemonicSample() {
val mnemonic0: Mnemonic = Mnemonic(WordCount.WORDS12)
val mnemonic1: Mnemonic = Mnemonic.fromString("scene change clap smart together mind wheel knee clip normal trial unusual")
val entropy: List<UByte> = listOf<UByte>(0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u)
val mnemonic2: Mnemonic = Mnemonic.fromEntropy(entropy)
println(mnemonic0.asString(), mnemonic1.asString(), mnemonic2.asString())
}