851f61296a16fb9dfbcad00e3e3f11331a56eb12 Fix Wallet.broadcast function, now returns a tx id as a hex string (Steve Myers)
Pull request description:
ACKs for top commit:
thunderbiscuit:
Tested ACK 851f612.
Tree-SHA512: 86e1d39029924e4fa3a0c21e9f45c1ba0694f4db9d1cfd8dee25a5675d5a8b7851a7c712ce57fb74382a7428fcecbe8ecee4b7b87b9245672bbd6ccea63dfc13
cc3736809a2910d3a739b37a61f1613404fba572 Fix memory database configuration enum (thunderbiscuit)
Pull request description:
The `DatabaseConfig.Memory` enum currently requires a "junk" string argument which is not used when creating the wallet:
```rust
// lib.rs line 24
pub enum DatabaseConfig {
Memory { junk: String },
Sled { config: SledDbConfiguration },
}
// lib.rs line 209
impl Wallet {
fn new(
descriptor: String,
change_descriptor: Option<String>,
network: Network,
database_config: DatabaseConfig,
blockchain_config: BlockchainConfig,
) -> Result<Self, BdkError> {
let any_database_config = match database_config {
DatabaseConfig::Memory { .. } => AnyDatabaseConfig::Memory(()),
DatabaseConfig::Sled { config } => AnyDatabaseConfig::Sled(config),
};
```
Which translates to the udl file like this:
```txt
[Enum]
interface DatabaseConfig {
Memory(string junk);
Sled(SledDbConfiguration config);
};
```
According to the [docs from uniffi-rs](https://mozilla.github.io/uniffi-rs/udl/enumerations.html) the `interface` here is required because the enums have named fields. But after testing I found that we can declare the udl file like so, and remove the requirement for the `junk` argument:
```txt
[Enum]
interface DatabaseConfig {
Memory();
Sled(SledDbConfiguration config);
};
```
On the Rust side we then have
```rust
pub enum DatabaseConfig {
Memory,
Sled { config: SledDbConfiguration },
}
```
And the resulting bindings go from (note that the bindings transform the enum into a sealed class rather than a Kotlin enum)
```kotlin
sealed class DatabaseConfig {
data class Memory(
val junk: String
) : DatabaseConfig()
data class Sled(
val config: SledDbConfiguration
) : DatabaseConfig()
```
to
```kotlin
sealed class DatabaseConfig {
object Memory : DatabaseConfig()
data class Sled(
val config: SledDbConfiguration
) : DatabaseConfig()
```
Which makes the API simpler to use, and removes the confusion created by having to provide an empty string (or not know what we're supposed to provide) to the `Memory()` enum.
The final call-site looks like this:
```kotlin
fun onlineWalletSyncGetBalance() {
// val db = DatabaseConfig.Memory("")
val db = DatabaseConfig.Memory
val client = BlockchainConfig.Electrum(
ElectrumConfig(
"ssl://electrum.blockstream.info:60002",
null,
5u,
null,
100u
)
)
val wallet = Wallet(descriptor, null, Network.REGTEST, databaseConfig, blockchainConfig)
wallet.sync(LogProgress(), null)
val balance = wallet.getBalance()
assertTrue(balance > 0u)
}
```
All tests run well on my side of things, but I'm opening this more as a discussion piece because I wasn't sure if there were other reasons for the choice of providing the argument to the `Memory` enum, or other design choices I'm not aware of. Any thoughts on this @artfuldev? I think you were the one who wrote the initial enum.
Top commit has no ACKs.
Tree-SHA512: 135e5943039a08522773f721a7cf6bbb93bd5bb9394bf42a30bab5f3e16fd35ce078056756e020a666d4f574d74080bc3404cc81809c0d7e0afe5c9471878425
12f4784b85fa2a263d9648dcccd8bac2da44644d Add sqlite database option (Steve Myers)
Pull request description:
### Description
Add sqlite db database option.
### Notes to the reviewers
When https://github.com/bitcoindevkit/bdk/pull/566 is released we need to updated this project to use the `sqlite-packaged` feature, see TODO in Cargo.toml.
ACKs for top commit:
thunderbiscuit:
Tested ACK [12f4784](12f4784b85).
Tree-SHA512: c39472507596e036dd81c22a05d424c6d363545b1a8bd622bf9647967b1b86ab44764da1a15169ac542c80a62a79331b5abcda7b657cc28d93ffdda51a62bd6e