-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minimal SwiftUI additions to bdk-swift #9
Comments
To create a Wallet, you need: let databaseconfig ...
let network ...
let descriptor ...
// to init
let wallet = try Wallet.init(descriptor: descriptor, changeDescriptor: changeDescriptor, network: network, databaseConfig: databaseConfig) To get balance (should happen after every sync): self.wallet!.getBalance() To get transactions (should happen after every sync): self.wallet!.listTransactions() To sync: let url = ...
let electrumConfig = ElectrumConfig(url: url!, socks5: nil, retry: ELECTRUM_RETRY, timeout: nil, stopGap: ELECTRUM_STOPGAP)
let blockchainConfig = BlockchainConfig.electrum(config: electrumConfig)
let blockchain = try Blockchain(config: blockchainConfig)
// to sync
try wallet.sync(blockchain: blockchain, progress: nil) To send: let psbt = try TxBuilder().addRecipient(address: recipient, amount: amount).feeRate(satPerVbyte: feeRate).finish(wallet: self.wallet!)
let success = try self.wallet!.sign(psbt: psbt)
let blockchainConfig = self.blockchainConfig(network: self.network, syncSource: self.syncSource)
let blockchain = try Blockchain(config: blockchainConfig)
try blockchain.broadcast(psbt: psbt) |
Proposed minimal interface: public class BDKManager: ObservableObject {
@Published public var wallet: Wallet
@Published public var balance: Balance?
@Published public var transactions: [TransactionDetails]?
private var blockchain: Blockchain
// Sync the loaded wallet once
public func sync() {
... (also updates Balance and Transactions)
}
// Send an amount of bitcoin (in sats) to a recipient, optional feeRate
public func sendBitcoin(recipient: String, amount: UInt64, feeRate: Float) -> Bool {
...
}
} |
Or should this not be part of bdk-swift at all, maybe just be a reference class? |
👀 |
I have moved this discussion to bdk-ffi: bitcoindevkit/bdk-ffi#266 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Instead of creating a 'fat' BDKManager class, what is the most minimal version of SwiftUI syntactic sugar we could add to BitcoinDevKit itself? This could either be done directly in the only file at the moment, or as a separate file for clarity.
What does every SwiftUI wallet developer need?
To support these, you need to create / keep references to:
The text was updated successfully, but these errors were encountered: