Skip to content

Commit 20d4b0a

Browse files
committed
deprecate Wallet::ChangeSet fields
Since these fields(`network`, `descriptor`, `change_descriptor`) will be replaced by `keyring` when we have the multi-keychain wallet.
1 parent c422104 commit 20d4b0a

4 files changed

Lines changed: 15 additions & 0 deletions

File tree

src/persist_test_utils.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ fn spk_at_index(descriptor: &Descriptor<DescriptorPublicKey>, index: u32) -> Scr
7474
/// We create a dummy [`ChangeSet`], persist it and check if loaded [`ChangeSet`] matches
7575
/// the persisted one. We then create another such dummy [`ChangeSet`], persist it and load it to
7676
/// check if merged [`ChangeSet`] is returned.
77+
#[allow(deprecated)]
7778
pub fn persist_wallet_changeset<Store, CreateStore>(filename: &str, create_store: CreateStore)
7879
where
7980
CreateStore: Fn(&Path) -> anyhow::Result<Store>,
@@ -250,6 +251,7 @@ where
250251
/// We create a dummy [`ChangeSet`] for first wallet and persist it then we create a dummy
251252
/// [`ChangeSet`] for second wallet and persist that. Finally we load these two [`ChangeSet`]s and
252253
/// check if they were persisted correctly.
254+
#[allow(deprecated)]
253255
pub fn persist_multiple_wallet_changesets<Store, CreateStores>(
254256
filename: &str,
255257
create_dbs: CreateStores,
@@ -321,6 +323,7 @@ pub fn persist_multiple_wallet_changesets<Store, CreateStores>(
321323
///
322324
/// We create a dummy [`ChangeSet`] with only network field populated, persist it and check if
323325
/// loaded [`ChangeSet`] has the same [`Network`] as what we persisted.
326+
#[allow(deprecated)]
324327
pub fn persist_network<Store, CreateStore>(filename: &str, create_store: CreateStore)
325328
where
326329
CreateStore: Fn(&Path) -> anyhow::Result<Store>,
@@ -357,6 +360,7 @@ where
357360
///
358361
/// We create a dummy [`ChangeSet`] with only descriptor fields populated, persist it and check if
359362
/// loaded [`ChangeSet`] has the same descriptors as what we persisted.
363+
#[allow(deprecated)]
360364
pub fn persist_keychains<Store, CreateStore>(filename: &str, create_store: CreateStore)
361365
where
362366
CreateStore: Fn(&Path) -> anyhow::Result<Store>,
@@ -399,6 +403,7 @@ where
399403
///
400404
/// We create a dummy [`ChangeSet`] with only descriptor field populated, persist it and check if
401405
/// loaded [`ChangeSet`] has the same descriptor as what we persisted.
406+
#[allow(deprecated)]
402407
pub fn persist_single_keychain<Store, CreateStore>(filename: &str, create_store: CreateStore)
403408
where
404409
CreateStore: Fn(&Path) -> anyhow::Result<Store>,

src/wallet/changeset.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,13 @@ type IndexedTxGraphChangeSet =
105105
#[derive(Default, Debug, Clone, PartialEq, Deserialize, Serialize)]
106106
pub struct ChangeSet {
107107
/// Descriptor for recipient addresses.
108+
#[deprecated(since = "3.0.0", note = "To be removed in v5.0")]
108109
pub descriptor: Option<Descriptor<DescriptorPublicKey>>,
109110
/// Descriptor for change addresses.
111+
#[deprecated(since = "3.0.0", note = "To be removed in v5.0")]
110112
pub change_descriptor: Option<Descriptor<DescriptorPublicKey>>,
111113
/// Stores the network type of the transaction data.
114+
#[deprecated(since = "3.0.0", note = "To be removed in v5.0")]
112115
pub network: Option<bitcoin::Network>,
113116
/// Changes to the [`LocalChain`](local_chain::LocalChain).
114117
pub local_chain: local_chain::ChangeSet,
@@ -122,6 +125,7 @@ pub struct ChangeSet {
122125

123126
impl Merge for ChangeSet {
124127
/// Merge another [`ChangeSet`] into itself.
128+
#[allow(deprecated)]
125129
fn merge(&mut self, other: Self) {
126130
if other.descriptor.is_some() {
127131
debug_assert!(
@@ -154,6 +158,7 @@ impl Merge for ChangeSet {
154158
Merge::merge(&mut self.indexer, other.indexer);
155159
}
156160

161+
#[allow(deprecated)]
157162
fn is_empty(&self) -> bool {
158163
self.descriptor.is_none()
159164
&& self.change_descriptor.is_none()
@@ -215,6 +220,7 @@ impl ChangeSet {
215220
}
216221

217222
/// Recover a [`ChangeSet`] from sqlite database.
223+
#[allow(deprecated)]
218224
pub fn from_sqlite(db_tx: &chain::rusqlite::Transaction) -> chain::rusqlite::Result<Self> {
219225
use bitcoin::{OutPoint, Txid};
220226
use chain::rusqlite::OptionalExtension;
@@ -269,6 +275,7 @@ impl ChangeSet {
269275
}
270276

271277
/// Persist [`ChangeSet`] to sqlite database.
278+
#[allow(deprecated)]
272279
pub fn persist_to_sqlite(
273280
&self,
274281
db_tx: &chain::rusqlite::Transaction,

src/wallet/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ impl Wallet {
309309
/// Create a new [`Wallet`] with given `params`.
310310
///
311311
/// Refer to [`Wallet::create`] for more.
312+
#[allow(deprecated)]
312313
pub fn create_with_params(params: CreateParams) -> Result<Self, DescriptorError> {
313314
let secp = SecpCtx::new();
314315
let network = params.network;
@@ -428,6 +429,7 @@ impl Wallet {
428429
/// Load [`Wallet`] from the given previously persisted [`ChangeSet`] and `params`.
429430
///
430431
/// Returns `Ok(None)` if the changeset is empty. Refer to [`Wallet::load`] for more.
432+
#[allow(deprecated)]
431433
pub fn load_with_params(
432434
changeset: ChangeSet,
433435
params: LoadParams,

src/wallet/persisted.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ impl<E: fmt::Display> fmt::Display for CreateWithPersistError<E> {
393393
impl<E: fmt::Debug + fmt::Display> std::error::Error for CreateWithPersistError<E> {}
394394

395395
/// Helper function to display basic information about a [`ChangeSet`].
396+
#[allow(deprecated)]
396397
fn changeset_info(f: &mut fmt::Formatter<'_>, changeset: &ChangeSet) -> fmt::Result {
397398
let network = changeset
398399
.network

0 commit comments

Comments
 (0)