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.
|
* The cryptocurrency to act on.
|
||||||
|
*
|
||||||
|
* @sample org.bitcoindevkit.networkSample
|
||||||
*/
|
*/
|
||||||
enum class Network {
|
enum class Network {
|
||||||
/** Bitcoin's mainnet. */
|
/** Bitcoin's mainnet. */
|
||||||
@ -146,6 +148,8 @@ data class EsploraConfig (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Type that can contain any of the blockchain configurations defined by the library.
|
* Type that can contain any of the blockchain configurations defined by the library.
|
||||||
|
*
|
||||||
|
* @sample org.bitcoindevkit.electrumBlockchainConfigSample
|
||||||
*/
|
*/
|
||||||
sealed class BlockchainConfig {
|
sealed class BlockchainConfig {
|
||||||
/** Electrum client. */
|
/** Electrum client. */
|
||||||
@ -178,6 +182,8 @@ data class TransactionDetails (
|
|||||||
* @constructor Create the new blockchain client.
|
* @constructor Create the new blockchain client.
|
||||||
*
|
*
|
||||||
* @param config The blockchain configuration required.
|
* @param config The blockchain configuration required.
|
||||||
|
*
|
||||||
|
* @sample org.bitcoindevkit.blockchainSample
|
||||||
*/
|
*/
|
||||||
class Blockchain(
|
class Blockchain(
|
||||||
config: BlockchainConfig
|
config: BlockchainConfig
|
||||||
|
@ -1,5 +1,14 @@
|
|||||||
package org.bitcoindevkit
|
package org.bitcoindevkit
|
||||||
|
|
||||||
|
fun networkSample() {
|
||||||
|
val wallet = Wallet(
|
||||||
|
descriptor = descriptor,
|
||||||
|
changeDescriptor = changeDescriptor,
|
||||||
|
network = Network.TESTNET,
|
||||||
|
databaseConfig = DatabaseConfig.Memory
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
fun balanceSample() {
|
fun balanceSample() {
|
||||||
object LogProgress : Progress {
|
object LogProgress : Progress {
|
||||||
override fun update(progress: Float, message: String?) {}
|
override fun update(progress: Float, message: String?) {}
|
||||||
@ -26,11 +35,11 @@ fun balanceSample() {
|
|||||||
fun electrumBlockchainConfigSample() {
|
fun electrumBlockchainConfigSample() {
|
||||||
val blockchainConfig = BlockchainConfig.Electrum(
|
val blockchainConfig = BlockchainConfig.Electrum(
|
||||||
ElectrumConfig(
|
ElectrumConfig(
|
||||||
"ssl://electrum.blockstream.info:60002",
|
url = "ssl://electrum.blockstream.info:60002",
|
||||||
null,
|
socks5 = null,
|
||||||
5u,
|
retry = 5u,
|
||||||
null,
|
timeout = null,
|
||||||
200u
|
stopGap = 200u
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -72,3 +81,20 @@ fun addressInfoSample() {
|
|||||||
|
|
||||||
println("New address at index ${newAddress.index} is ${newAddress.address}")
|
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