Add API docs samples for Network, BlockchainConfig, and Blockchain
This commit is contained in:
parent
b9c283c89b
commit
3f35a18d41
@ -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
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user