diff --git a/api-docs/src/main/kotlin/org/bitcoindevkit/bdk.kt b/api-docs/src/main/kotlin/org/bitcoindevkit/bdk.kt index 01759aa..74db8c2 100644 --- a/api-docs/src/main/kotlin/org/bitcoindevkit/bdk.kt +++ b/api-docs/src/main/kotlin/org/bitcoindevkit/bdk.kt @@ -2,6 +2,8 @@ package org.bitcoindevkit /** * The cryptocurrency to act on. + * + * @sample org.bitcoindevkit.networkSample */ enum class Network { /** Bitcoin's mainnet. */ @@ -146,6 +148,8 @@ data class EsploraConfig ( /** * Type that can contain any of the blockchain configurations defined by the library. + * + * @sample org.bitcoindevkit.electrumBlockchainConfigSample */ sealed class BlockchainConfig { /** Electrum client. */ @@ -178,6 +182,8 @@ data class TransactionDetails ( * @constructor Create the new blockchain client. * * @param config The blockchain configuration required. + * + * @sample org.bitcoindevkit.blockchainSample */ class Blockchain( config: BlockchainConfig diff --git a/api-docs/src/test/kotlin/org/bitcoindevkit/Samples.kt b/api-docs/src/test/kotlin/org/bitcoindevkit/Samples.kt index b160a68..36e7c33 100644 --- a/api-docs/src/test/kotlin/org/bitcoindevkit/Samples.kt +++ b/api-docs/src/test/kotlin/org/bitcoindevkit/Samples.kt @@ -1,5 +1,14 @@ package org.bitcoindevkit +fun networkSample() { + val wallet = Wallet( + descriptor = descriptor, + changeDescriptor = changeDescriptor, + network = Network.TESTNET, + databaseConfig = DatabaseConfig.Memory + ) +} + fun balanceSample() { object LogProgress : Progress { override fun update(progress: Float, message: String?) {} @@ -26,11 +35,11 @@ fun balanceSample() { fun electrumBlockchainConfigSample() { val blockchainConfig = BlockchainConfig.Electrum( ElectrumConfig( - "ssl://electrum.blockstream.info:60002", - null, - 5u, - null, - 200u + url = "ssl://electrum.blockstream.info:60002", + socks5 = null, + retry = 5u, + timeout = null, + stopGap = 200u ) ) } @@ -72,3 +81,20 @@ fun addressInfoSample() { println("New address at index ${newAddress.index} is ${newAddress.address}") } + +fun blockchainSample() { + val blockchainConfig: BlockchainConfig = BlockchainConfig.Electrum( + ElectrumConfig( + electrumURL, + null, + 5u, + null, + 10u + ) + ) + + val blockchain: Blockchain = Blockchain(blockchainConfig) + + blockchain.broadcast(signedPsbt) +} +