Skip to content

Commit 685d59c

Browse files
committed
refactor: rename plan and plan_mall to have into_ prefix
These functions consume `self`, therefore they should be prefixed with `into_`. The old functions are now deprecated.
1 parent 2e4b89e commit 685d59c

3 files changed

Lines changed: 31 additions & 7 deletions

File tree

bitcoind-tests/tests/test_desc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ fn test_plan_satisfy(
475475

476476
let plan = definite_desc
477477
.clone()
478-
.plan(&assets)
478+
.into_plan(&assets)
479479
.expect("plan creation failed");
480480

481481
let mut unsigned_tx = Transaction {

src/descriptor/mod.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,8 +556,20 @@ impl<Pk: MiniscriptKey + ToPublicKey> Descriptor<Pk> {
556556
/// Returns a plan if the provided assets are sufficient to produce a non-malleable satisfaction
557557
///
558558
/// If the assets aren't sufficient for generating a Plan, the descriptor is returned
559+
#[deprecated(since = "13.0.0", note = "use into_plan instead")]
559560
#[allow(clippy::result_large_err)] // our "error type" is the original descriptor
560561
pub fn plan<P>(self, provider: &P) -> Result<Plan<Pk>, Self>
562+
where
563+
P: AssetProvider<Pk>,
564+
{
565+
self.into_plan(provider)
566+
}
567+
568+
/// Returns a plan if the provided assets are sufficient to produce a non-malleable satisfaction
569+
///
570+
/// If the assets aren't sufficient for generating a Plan, the descriptor is returned
571+
#[allow(clippy::result_large_err)] // our "error type" is the original descriptor
572+
pub fn into_plan<P>(self, provider: &P) -> Result<Plan<Pk>, Self>
561573
where
562574
P: AssetProvider<Pk>,
563575
{
@@ -585,8 +597,20 @@ impl<Pk: MiniscriptKey + ToPublicKey> Descriptor<Pk> {
585597
/// Returns a plan if the provided assets are sufficient to produce a malleable satisfaction
586598
///
587599
/// If the assets aren't sufficient for generating a Plan, the descriptor is returned
600+
#[deprecated(since = "13.0.0", note = "use into_plan_mall instead")]
588601
#[allow(clippy::result_large_err)] // our "error type" is the original descriptor
589602
pub fn plan_mall<P>(self, provider: &P) -> Result<Plan<Pk>, Self>
603+
where
604+
P: AssetProvider<Pk>,
605+
{
606+
self.into_plan_mall(provider)
607+
}
608+
609+
/// Returns a plan if the provided assets are sufficient to produce a malleable satisfaction
610+
///
611+
/// If the assets aren't sufficient for generating a Plan, the descriptor is returned
612+
#[allow(clippy::result_large_err)] // our "error type" is the original descriptor
613+
pub fn into_plan_mall<P>(self, provider: &P) -> Result<Plan<Pk>, Self>
590614
where
591615
P: AssetProvider<Pk>,
592616
{

src/plan.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ mod test {
766766
assets = assets.add(hashes[hi]);
767767
}
768768

769-
let result = desc.clone().plan(&assets);
769+
let result = desc.clone().into_plan(&assets);
770770
assert_eq!(
771771
result.as_ref().ok().map(|plan| plan.satisfaction_weight()),
772772
expected,
@@ -1105,7 +1105,7 @@ mod test {
11051105
let mut psbt_input = bitcoin::psbt::Input::default();
11061106
let assets = Assets::new().add(internal_key);
11071107
desc.clone()
1108-
.plan(&assets)
1108+
.into_plan(&assets)
11091109
.unwrap()
11101110
.update_psbt_input(&mut psbt_input);
11111111
assert!(psbt_input.tap_internal_key.is_some(), "Internal key is missing");
@@ -1116,7 +1116,7 @@ mod test {
11161116
let mut psbt_input = bitcoin::psbt::Input::default();
11171117
let assets = Assets::new().add(first_branch);
11181118
desc.clone()
1119-
.plan(&assets)
1119+
.into_plan(&assets)
11201120
.unwrap()
11211121
.update_psbt_input(&mut psbt_input);
11221122
assert!(psbt_input.tap_internal_key.is_none(), "Internal key is present");
@@ -1126,7 +1126,7 @@ mod test {
11261126

11271127
let mut psbt_input = bitcoin::psbt::Input::default();
11281128
let assets = Assets::new().add(second_branch);
1129-
desc.plan(&assets)
1129+
desc.into_plan(&assets)
11301130
.unwrap()
11311131
.update_psbt_input(&mut psbt_input);
11321132
assert!(psbt_input.tap_internal_key.is_none(), "Internal key is present");
@@ -1149,7 +1149,7 @@ mod test {
11491149

11501150
let mut psbt_input = bitcoin::psbt::Input::default();
11511151
let assets = Assets::new().add(asset_key);
1152-
desc.plan(&assets)
1152+
desc.into_plan(&assets)
11531153
.unwrap()
11541154
.update_psbt_input(&mut psbt_input);
11551155
assert!(psbt_input.witness_script.is_some(), "Witness script missing");
@@ -1202,7 +1202,7 @@ mod test {
12021202
assets = assets.add(DescriptorPublicKey::from_str(&pk.to_string()).unwrap());
12031203
}
12041204

1205-
let plan = desc.plan(&assets).expect("plan should succeed");
1205+
let plan = desc.into_plan(&assets).expect("plan should succeed");
12061206

12071207
let (witness, script_sig) = plan.satisfy(&satisfier).expect("satisfy should succeed");
12081208
assert_eq!(witness.last().unwrap(), &exp_witness_script.into_bytes());

0 commit comments

Comments
 (0)