Update JVM and Android API docs to version 0.25 and add samples
This commit is contained in:
		
							parent
							
								
									a925ddfc47
								
							
						
					
					
						commit
						17b3712000
					
				| @ -5,7 +5,7 @@ | |||||||
|     <a href="https://github.com/bitcoindevkit/bdk-ffi/actions?query=workflow%3ACI"><img alt="CI Status" src="https://github.com/bitcoindevkit/bdk-ffi/workflows/CI/badge.svg"></a> |     <a href="https://github.com/bitcoindevkit/bdk-ffi/actions?query=workflow%3ACI"><img alt="CI Status" src="https://github.com/bitcoindevkit/bdk-ffi/workflows/CI/badge.svg"></a> | ||||||
|     <a href="https://blog.rust-lang.org/2022/05/19/Rust-1.61.0.html"><img alt="Rustc Version 1.61.0+" src="https://img.shields.io/badge/rustc-1.61.0%2B-lightgrey.svg"/></a> |     <a href="https://blog.rust-lang.org/2022/05/19/Rust-1.61.0.html"><img alt="Rustc Version 1.61.0+" src="https://img.shields.io/badge/rustc-1.61.0%2B-lightgrey.svg"/></a> | ||||||
|     <a href="https://discord.gg/d7NkDKm"><img alt="Chat on Discord" src="https://img.shields.io/discord/753336465005608961?logo=discord"></a> |     <a href="https://discord.gg/d7NkDKm"><img alt="Chat on Discord" src="https://img.shields.io/discord/753336465005608961?logo=discord"></a> | ||||||
|   </p> | </p> | ||||||
| 
 | 
 | ||||||
| The workspace in this repository creates the `libbdkffi` multi-language library for the Rust-based  | The workspace in this repository creates the `libbdkffi` multi-language library for the Rust-based  | ||||||
| [bdk] library from the [Bitcoin Dev Kit] project. The `bdk-ffi-bindgen` package builds a tool for  | [bdk] library from the [Bitcoin Dev Kit] project. The `bdk-ffi-bindgen` package builds a tool for  | ||||||
|  | |||||||
| @ -94,6 +94,8 @@ sealed class DatabaseConfig { | |||||||
|  * Configuration type for a SQLite database. |  * Configuration type for a SQLite database. | ||||||
|  * |  * | ||||||
|  * @property path Main directory of the DB. |  * @property path Main directory of the DB. | ||||||
|  |  * | ||||||
|  |  * @sample org.bitcoindevkit.sqliteDatabaseConfigSample | ||||||
|  */ |  */ | ||||||
| data class SqliteDbConfiguration( | data class SqliteDbConfiguration( | ||||||
|     var path: String, |     var path: String, | ||||||
| @ -137,6 +139,8 @@ data class ElectrumConfig ( | |||||||
|  * @property concurrency Number of parallel requests sent to the esplora service (default: 4). |  * @property concurrency Number of parallel requests sent to the esplora service (default: 4). | ||||||
|  * @property stopGap Stop searching addresses for transactions after finding an unused gap of this length. |  * @property stopGap Stop searching addresses for transactions after finding an unused gap of this length. | ||||||
|  * @property timeout Socket timeout. |  * @property timeout Socket timeout. | ||||||
|  |  * | ||||||
|  |  * @sample org.bitcoindevkit.esploraBlockchainConfigSample | ||||||
|  */ |  */ | ||||||
| data class EsploraConfig ( | data class EsploraConfig ( | ||||||
|     var baseUrl: String, |     var baseUrl: String, | ||||||
| @ -213,7 +217,7 @@ class PartiallySignedBitcoinTransaction(psbtBase64: String) { | |||||||
|     fun txid(): String {} |     fun txid(): String {} | ||||||
| 
 | 
 | ||||||
|     /** Return the transaction as bytes. */ |     /** Return the transaction as bytes. */ | ||||||
|     fun `extractTx`(): List<UByte> |     fun extractTx(): List<UByte> | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * Combines this PartiallySignedTransaction with another PSBT as described by BIP 174. |      * Combines this PartiallySignedTransaction with another PSBT as described by BIP 174. | ||||||
| @ -343,6 +347,9 @@ class Progress { | |||||||
|  * After creating the TxBuilder, you set options on it until finally calling `.finish` to consume the builder and generate the transaction. |  * After creating the TxBuilder, you set options on it until finally calling `.finish` to consume the builder and generate the transaction. | ||||||
|  * |  * | ||||||
|  * Each method on the TxBuilder returns an instance of a new TxBuilder with the option set/added. |  * Each method on the TxBuilder returns an instance of a new TxBuilder with the option set/added. | ||||||
|  |  * | ||||||
|  |  * @sample org.bitcoindevkit.txBuilderResultSample1 | ||||||
|  |  * @sample org.bitcoindevkit.txBuilderResultSample2 | ||||||
|  */ |  */ | ||||||
| class TxBuilder() { | class TxBuilder() { | ||||||
|     /** Add data as an output using OP_RETURN. */ |     /** Add data as an output using OP_RETURN. */ | ||||||
| @ -476,6 +483,9 @@ class DerivationPath(path: String) {} | |||||||
|  * @sample org.bitcoindevkit.descriptorSecretKeyExtendSample |  * @sample org.bitcoindevkit.descriptorSecretKeyExtendSample | ||||||
|  */ |  */ | ||||||
| class DescriptorSecretKey(network: Network, mnemonic: Mnemonic, password: String?) { | class DescriptorSecretKey(network: Network, mnemonic: Mnemonic, password: String?) { | ||||||
|  |     /** Build a DescriptorSecretKey from a String */ | ||||||
|  |     fun fromString(secretKey: String): DescriptorSecretKey {} | ||||||
|  | 
 | ||||||
|     /** Derive a private descriptor at a given path. */ |     /** Derive a private descriptor at a given path. */ | ||||||
|     fun derive(path: DerivationPath): DescriptorSecretKey {} |     fun derive(path: DerivationPath): DescriptorSecretKey {} | ||||||
| 
 | 
 | ||||||
| @ -500,11 +510,14 @@ class DescriptorSecretKey(network: Network, mnemonic: Mnemonic, password: String | |||||||
|  * @param password The optional passphrase that can be provided as per BIP-39. |  * @param password The optional passphrase that can be provided as per BIP-39. | ||||||
|  */ |  */ | ||||||
| class DescriptorPublicKey(network: Network, mnemonic: String, password: String?) { | class DescriptorPublicKey(network: Network, mnemonic: String, password: String?) { | ||||||
|  |     /** Build a DescriptorPublicKey from a String */ | ||||||
|  |     fun fromString(publicKey: String): DescriptorPublicKey {} | ||||||
|  | 
 | ||||||
|     /** Derive a public descriptor at a given path. */ |     /** Derive a public descriptor at a given path. */ | ||||||
|     fun derive(path: DerivationPath): DescriptorSecretKey |     fun derive(path: DerivationPath): DescriptorPublicKey | ||||||
| 
 | 
 | ||||||
|     /** Extend the public descriptor with a custom path. */ |     /** Extend the public descriptor with a custom path. */ | ||||||
|     fun extend(path: DerivationPath): DescriptorSecretKey |     fun extend(path: DerivationPath): DescriptorPublicKey | ||||||
| 
 | 
 | ||||||
|     /** Return the public descriptor as a string. */ |     /** Return the public descriptor as a string. */ | ||||||
|     fun asString(): String |     fun asString(): String | ||||||
|  | |||||||
| @ -44,6 +44,18 @@ fun electrumBlockchainConfigSample() { | |||||||
|     ) |     ) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | fun esploraBlockchainConfigSample() { | ||||||
|  |     val esploraURL: String = "http://10.0.2.2:3002" | ||||||
|  |     val esploraConfig: EsploraConfig = EsploraConfig( | ||||||
|  |         baseUrl = esploraURL, | ||||||
|  |         proxy = null, | ||||||
|  |         concurrency = 4u, | ||||||
|  |         stopGap = 20UL, | ||||||
|  |         timeout = null | ||||||
|  |     ) | ||||||
|  |     val blockchainConfig = BlockchainConfig.Esplora(config = esploraConfig) | ||||||
|  | } | ||||||
|  | 
 | ||||||
| fun memoryDatabaseConfigSample() { | fun memoryDatabaseConfigSample() { | ||||||
|     val memoryDatabaseConfig = DatabaseConfig.Memory |     val memoryDatabaseConfig = DatabaseConfig.Memory | ||||||
| } | } | ||||||
| @ -102,9 +114,9 @@ fun blockchainSample() { | |||||||
| fun txBuilderResultSample1() { | fun txBuilderResultSample1() { | ||||||
|     val faucetAddress = Address("tb1ql7w62elx9ucw4pj5lgw4l028hmuw80sndtntxt") |     val faucetAddress = Address("tb1ql7w62elx9ucw4pj5lgw4l028hmuw80sndtntxt") | ||||||
|     // TxBuilderResult is a data class, which means you can use destructuring declarations on it to |     // TxBuilderResult is a data class, which means you can use destructuring declarations on it to | ||||||
|     // open it up in its component parts |     // open it up into its component parts | ||||||
|     val (psbt, txDetails) = TxBuilder() |     val (psbt, txDetails) = TxBuilder() | ||||||
|         .addRecipient(faucetAddress.scriptPubkey(), 1000u) |         .addRecipient(faucetAddress.scriptPubkey(), 1000uL) | ||||||
|         .feeRate(1.2f) |         .feeRate(1.2f) | ||||||
|         .finish(wallet) |         .finish(wallet) | ||||||
| 
 | 
 | ||||||
| @ -115,7 +127,7 @@ fun txBuilderResultSample1() { | |||||||
| fun txBuilderResultSample2() { | fun txBuilderResultSample2() { | ||||||
|     val faucetAddress = Address("tb1ql7w62elx9ucw4pj5lgw4l028hmuw80sndtntxt") |     val faucetAddress = Address("tb1ql7w62elx9ucw4pj5lgw4l028hmuw80sndtntxt") | ||||||
|     val txBuilderResult: TxBuilderResult = TxBuilder() |     val txBuilderResult: TxBuilderResult = TxBuilder() | ||||||
|         .addRecipient(faucetAddress.scriptPubkey(), 1000u) |         .addRecipient(faucetAddress.scriptPubkey(), 1000uL) | ||||||
|         .feeRate(1.2f) |         .feeRate(1.2f) | ||||||
|         .finish(wallet) |         .finish(wallet) | ||||||
| 
 | 
 | ||||||
| @ -200,7 +212,7 @@ fun createTransaction() { | |||||||
| 
 | 
 | ||||||
|     val paymentAddress: Address = Address("tb1ql7w62elx9ucw4pj5lgw4l028hmuw80sndtntxt") |     val paymentAddress: Address = Address("tb1ql7w62elx9ucw4pj5lgw4l028hmuw80sndtntxt") | ||||||
|     val (psbt, txDetails) = TxBuilder() |     val (psbt, txDetails) = TxBuilder() | ||||||
|         .addRecipient(faucetAddress.scriptPubkey(), 1000u) |         .addRecipient(faucetAddress.scriptPubkey(), 1000uL) | ||||||
|         .feeRate(1.2f) |         .feeRate(1.2f) | ||||||
|         .finish(wallet) |         .finish(wallet) | ||||||
| 
 | 
 | ||||||
| @ -213,7 +225,7 @@ fun walletSample() { | |||||||
|     val internalDescriptor = "wpkh(tprv8hwWMmPE4BVNxGdVt3HhEERZhondQvodUY7Ajyseyhudr4WabJqWKWLr4Wi2r26CDaNCQhhxEfVULesmhEfZYyBXdE/84h/1h/0h/1/*)" |     val internalDescriptor = "wpkh(tprv8hwWMmPE4BVNxGdVt3HhEERZhondQvodUY7Ajyseyhudr4WabJqWKWLr4Wi2r26CDaNCQhhxEfVULesmhEfZYyBXdE/84h/1h/0h/1/*)" | ||||||
|     val sqliteDatabaseConfig = DatabaseConfig.Sqlite(SqliteDbConfiguration("bdk-sqlite")) |     val sqliteDatabaseConfig = DatabaseConfig.Sqlite(SqliteDbConfiguration("bdk-sqlite")) | ||||||
| 
 | 
 | ||||||
|     val wallet = BdkWallet( |     val wallet = Wallet( | ||||||
|         descriptor = externalDescriptor, |         descriptor = externalDescriptor, | ||||||
|         changeDescriptor = internalDescriptor, |         changeDescriptor = internalDescriptor, | ||||||
|         network = Network.TESTNET, |         network = Network.TESTNET, | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user