Skip to content

Commit 6927b3c

Browse files
committed
deprecate(wallet): phase out wallet-as-keystore
1 parent f01bab1 commit 6927b3c

4 files changed

Lines changed: 42 additions & 0 deletions

File tree

src/wallet/export.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,11 @@ impl FullyNodedExport {
249249
}
250250

251251
/// Export a wallet to FullyNoded format using keys stored in the wallet.
252+
#[deprecated(
253+
since = "3.2.0",
254+
note = "pass external and internal KeyMaps explicitly; use FullyNodedExport::export_wallet_with_keymaps instead."
255+
)]
256+
#[allow(deprecated)]
252257
pub fn export_wallet(
253258
wallet: &Wallet,
254259
label: &str,

src/wallet/mod.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,6 +1122,10 @@ impl Wallet {
11221122
/// Add an external signer
11231123
///
11241124
/// See [the `signer` module](signer) for an example.
1125+
#[deprecated(
1126+
since = "3.2.0",
1127+
note = "use your KeyMap or Xpriv and sign with Wallet::sign_psbt for software signing, or use your own signer for hardware signing. Wallet::sign_with_signers lets you keep using a SignersContainer while the signer module is phased out (issue #70)."
1128+
)]
11251129
pub fn add_signer(
11261130
&mut self,
11271131
keychain: KeychainKind,
@@ -1140,6 +1144,10 @@ impl Wallet {
11401144
///
11411145
/// Note this does nothing if the given keychain has no descriptor because we won't
11421146
/// know the context (segwit, taproot, etc) in which to create signatures.
1147+
#[deprecated(
1148+
since = "3.2.0",
1149+
note = "use your KeyMap or Xpriv and sign with Wallet::sign_psbt for software signing, or use your own signer for hardware signing. Wallet::sign_with_signers lets you keep using a SignersContainer while the signer module is phased out (issue #70)."
1150+
)]
11431151
pub fn set_keymap(&mut self, keychain: KeychainKind, keymap: KeyMap) {
11441152
let wallet_signers = match keychain {
11451153
KeychainKind::External => Arc::make_mut(&mut self.signers),
@@ -1151,6 +1159,11 @@ impl Wallet {
11511159
}
11521160

11531161
/// Set the keymap for each keychain.
1162+
#[deprecated(
1163+
since = "3.2.0",
1164+
note = "use your KeyMap or Xpriv and sign with Wallet::sign_psbt for software signing, or use your own signer for hardware signing. Wallet::sign_with_signers lets you keep using a SignersContainer while the signer module is phased out (issue #70)."
1165+
)]
1166+
#[allow(deprecated)]
11541167
pub fn set_keymaps(&mut self, keymaps: impl IntoIterator<Item = (KeychainKind, KeyMap)>) {
11551168
for (keychain, keymap) in keymaps {
11561169
self.set_keymap(keychain, keymap);
@@ -1169,13 +1182,18 @@ impl Wallet {
11691182
/// let wallet = Wallet::create(descriptor, change_descriptor)
11701183
/// .network(Network::Testnet)
11711184
/// .create_wallet_no_persist()?;
1185+
/// #[allow(deprecated)]
11721186
/// for secret_key in wallet.get_signers(KeychainKind::External).signers().iter().filter_map(|s| s.descriptor_secret_key()) {
11731187
/// // secret_key: tprv8ZgxMBicQKsPe73PBRSmNbTfbcsZnwWhz5eVmhHpi31HW29Z7mc9B4cWGRQzopNUzZUT391DeDJxL2PefNunWyLgqCKRMDkU1s2s8bAfoSk/84'/0'/0'/0/*
11741188
/// println!("secret_key: {}", secret_key);
11751189
/// }
11761190
///
11771191
/// Ok::<(), Box<dyn core::error::Error>>(())
11781192
/// ```
1193+
#[deprecated(
1194+
since = "3.2.0",
1195+
note = "the Wallet is being phased out as a key store; keep your own KeyMap or Xpriv instead. During the transition you can still pass the returned SignersContainer to Wallet::sign_with_signers (issue #70)."
1196+
)]
11791197
pub fn get_signers(&self, keychain: KeychainKind) -> Arc<SignersContainer> {
11801198
match keychain {
11811199
KeychainKind::External => Arc::clone(&self.signers),
@@ -1747,10 +1765,15 @@ impl Wallet {
17471765
/// builder.add_recipient(to_address.script_pubkey(), Amount::from_sat(50_000));
17481766
/// builder.finish()?
17491767
/// };
1768+
/// #[allow(deprecated)]
17501769
/// let finalized = wallet.sign(&mut psbt, SignOptions::default())?;
17511770
/// assert!(finalized, "we should have signed all the inputs");
17521771
/// # Ok::<(),anyhow::Error>(())
17531772
/// ```
1773+
#[deprecated(
1774+
since = "3.2.0",
1775+
note = "use your KeyMap or Xpriv and sign with Wallet::sign_psbt for software signing, or use your own signer for hardware signing. Wallet::sign_with_signers lets you keep using a SignersContainer while the signer module is phased out (issue #70)."
1776+
)]
17541777
pub fn sign(&self, psbt: &mut Psbt, sign_options: SignOptions) -> Result<bool, SignerError> {
17551778
self.sign_with_signers(
17561779
psbt,
@@ -3217,6 +3240,7 @@ mod test {
32173240
}
32183241

32193242
#[test]
3243+
#[allow(deprecated)] // get_signers is deprecated by this PR; still used here to verify get_keymap
32203244
fn test_get_keymap() {
32213245
use crate::test_utils::get_test_wpkh_and_change_desc;
32223246
let (external_desc, internal_desc) = get_test_wpkh_and_change_desc();

src/wallet/params.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ impl CreateParams {
141141
}
142142

143143
/// Extend the given `keychain`'s `keymap`.
144+
#[deprecated(
145+
since = "3.2.0",
146+
note = "use your KeyMap or Xpriv and sign with Wallet::sign_psbt for software signing, or use your own signer for hardware signing. Wallet::sign_with_signers lets you keep using a SignersContainer while the signer module is phased out (issue #70)."
147+
)]
144148
pub fn keymap(mut self, keychain: KeychainKind, keymap: KeyMap) -> Self {
145149
match keychain {
146150
KeychainKind::External => &mut self.descriptor_keymap,
@@ -243,6 +247,10 @@ impl LoadParams {
243247
}
244248

245249
/// Extend the given `keychain`'s `keymap`.
250+
#[deprecated(
251+
since = "3.2.0",
252+
note = "use your KeyMap or Xpriv and sign with Wallet::sign_psbt for software signing, or use your own signer for hardware signing. Wallet::sign_with_signers lets you keep using a SignersContainer while the signer module is phased out (issue #70)."
253+
)]
246254
pub fn keymap(mut self, keychain: KeychainKind, keymap: KeyMap) -> Self {
247255
match keychain {
248256
KeychainKind::External => &mut self.descriptor_keymap,
@@ -307,6 +315,10 @@ impl LoadParams {
307315

308316
/// Whether to try extracting private keys from the *provided descriptors* upon loading.
309317
/// See also [`LoadParams::descriptor`].
318+
#[deprecated(
319+
since = "3.2.0",
320+
note = "use your KeyMap or Xpriv and sign with Wallet::sign_psbt for software signing, or use your own signer for hardware signing. Wallet::sign_with_signers lets you keep using a SignersContainer while the signer module is phased out (issue #70)."
321+
)]
310322
pub fn extract_keys(mut self) -> Self {
311323
self.extract_keys = true;
312324
self

tests/persisted_wallet.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ fn wallet_is_persisted() -> anyhow::Result<()> {
230230
}
231231

232232
#[test]
233+
#[allow(deprecated)]
233234
fn wallet_load_checks() -> anyhow::Result<()> {
234235
fn run<Db, CreateDb, OpenDb>(
235236
filename: &str,

0 commit comments

Comments
 (0)