@@ -288,58 +288,6 @@ impl std::error::Error for ApplyBlockError {}
288288pub type WalletTx < ' a > = CanonicalTx < ' a , Arc < Transaction > , ConfirmationBlockTime > ;
289289
290290impl Wallet {
291- pub fn new ( key_ring : KeyRing ) -> CreateParams {
292- let network = key_ring. network ( ) ;
293- CreateParams :: new_with_keyring ( key_ring, network)
294- }
295-
296- /// Build a new single descriptor [`Wallet`].
297- ///
298- /// If you have previously created a wallet, use [`load`](Self::load) instead.
299- ///
300- /// # Note
301- ///
302- /// Only use this method when creating a wallet designed to be used with a single
303- /// descriptor and keychain. Otherwise the recommended way to construct a new wallet is
304- /// by using [`Wallet::create`]. It's worth noting that not all features are available
305- /// with single descriptor wallets, for example setting a [`change_policy`] on [`TxBuilder`]
306- /// and related methods such as [`do_not_spend_change`]. This is because all payments are
307- /// received on the external keychain (including change), and without a change keychain
308- /// BDK lacks enough information to distinguish between change and outside payments.
309- ///
310- /// Additionally because this wallet has no internal (change) keychain, all methods that
311- /// require a [`KeychainKind`] as input, e.g. [`reveal_next_address`] should only be called
312- /// using the [`External`] variant. In most cases passing [`Internal`] is treated as the
313- /// equivalent of [`External`] but this behavior must not be relied on.
314- ///
315- /// # Example
316- ///
317- /// ```rust
318- /// # use bdk_wallet::Wallet;
319- /// # use bitcoin::Network;
320- /// # const EXTERNAL_DESC: &str = "wpkh(tprv8ZgxMBicQKsPdy6LMhUtFHAgpocR8GC6QmwMSFpZs7h6Eziw3SpThFfczTDh5rW2krkqffa11UpX3XkeTTB2FvzZKWXqPY54Y6Rq4AQ5R8L/84'/1'/0'/0/*)";
321- /// # let temp_dir = tempfile::tempdir().expect("must create tempdir");
322- /// # let file_path = temp_dir.path().join("store.db");
323- /// // Create a wallet that is persisted to SQLite database.
324- /// use bdk_wallet::rusqlite::Connection;
325- /// let mut conn = Connection::open(file_path)?;
326- /// let wallet = Wallet::create_single(EXTERNAL_DESC)
327- /// .network(Network::Testnet)
328- /// .create_wallet(&mut conn)?;
329- /// # Ok::<_, anyhow::Error>(())
330- /// ```
331- /// [`change_policy`]: TxBuilder::change_policy
332- /// [`do_not_spend_change`]: TxBuilder::do_not_spend_change
333- /// [`External`]: KeychainKind::External
334- /// [`Internal`]: KeychainKind::Internal
335- /// [`reveal_next_address`]: Self::reveal_next_address
336- // pub fn create_single<D>(descriptor: D) -> CreateParams
337- // where
338- // D: IntoWalletDescriptor + Send + Clone + 'static,
339- // {
340- // CreateParams::new_single(descriptor)
341- // }
342-
343291 /// Build a new [`Wallet`].
344292 ///
345293 /// If you have previously created a wallet, use [`load`](Self::load) instead.
@@ -348,33 +296,30 @@ impl Wallet {
348296 ///
349297 /// ```rust
350298 /// # use bdk_wallet::Wallet;
299+ /// # use bdk_wallet::keyring::KeyRing;
351300 /// # use bitcoin::Network;
352301 /// # fn main() -> anyhow::Result<()> {
353- /// # const EXTERNAL_DESC: &str = "wpkh(tprv8ZgxMBicQKsPdy6LMhUtFHAgpocR8GC6QmwMSFpZs7h6Eziw3SpThFfczTDh5rW2krkqffa11UpX3XkeTTB2FvzZKWXqPY54Y6Rq4AQ5R8L/84'/1'/0'/0/*)";
354- /// # const INTERNAL_DESC: &str = "wpkh(tprv8ZgxMBicQKsPdy6LMhUtFHAgpocR8GC6QmwMSFpZs7h6Eziw3SpThFfczTDh5rW2krkqffa11UpX3XkeTTB2FvzZKWXqPY54Y6Rq4AQ5R8L/84'/1'/0'/1/*)";
302+ /// # const MY_DESCRIPTOR: &str = "wpkh(tprv8ZgxMBicQKsPdy6LMhUtFHAgpocR8GC6QmwMSFpZs7h6Eziw3SpThFfczTDh5rW2krkqffa11UpX3XkeTTB2FvzZKWXqPY54Y6Rq4AQ5R8L/84'/1'/0'/0/*)";
303+ /// // Create a KeyRing
304+ /// let mut key_ring = KeyRing::new(MY_DESCRIPTOR, Network::Signet);
355305 /// // Create a non-persisted wallet.
356- /// let wallet = Wallet::create(EXTERNAL_DESC, INTERNAL_DESC)
357- /// .network(Network::Testnet)
306+ /// let wallet = Wallet::create(key_ring)
358307 /// .create_wallet_no_persist()?;
359308 ///
360309 /// // Create a wallet that is persisted to SQLite database.
361310 /// # let temp_dir = tempfile::tempdir().expect("must create tempdir");
362311 /// # let file_path = temp_dir.path().join("store.db");
363312 /// use bdk_wallet::rusqlite::Connection;
364313 /// let mut conn = Connection::open(file_path)?;
365- /// let wallet = Wallet::create(EXTERNAL_DESC, INTERNAL_DESC)
366- /// .network(Network::Testnet)
314+ /// let wallet = Wallet::create(key_ring)
367315 /// .create_wallet(&mut conn)?;
368316 /// # Ok(())
369317 /// # }
370318 /// ```
371- // pub fn create<D>(descriptor: D, change_descriptor: D) -> CreateParams
372- // where
373- // D: IntoWalletDescriptor + Send + Clone + 'static,
374- // {
375- // CreateParams::new(descriptor, change_descriptor)
376- // }
377- //
319+ pub fn create ( key_ring : KeyRing ) -> CreateParams {
320+ CreateParams :: new ( key_ring)
321+ }
322+
378323 // /// Create a new [`Wallet`] with given `params`.
379324 // ///
380325 // /// Refer to [`Wallet::create`] for more.
0 commit comments