Skip to content

Commit 543b263

Browse files
committed
miniscript bug workaround
1 parent 86fdda9 commit 543b263

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/wallet/mod.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,12 +1551,18 @@ where
15511551
Ok(self
15521552
.iter_unspent()?
15531553
.map(|utxo| {
1554-
let keychain = utxo.keychain;
1554+
let desc = self.get_descriptor_for_keychain(utxo.keychain);
1555+
1556+
// WORKAROUND: There is a bug in miniscript where they fail to take into
1557+
// consideration an `OP_PUSH..` (4 weight units) for `pkh` script types.
1558+
let workaround_weight = match desc.desc_type() {
1559+
DescriptorType::Pkh => 4_usize,
1560+
_ => 0_usize,
1561+
};
1562+
15551563
(
15561564
utxo,
1557-
self.get_descriptor_for_keychain(keychain)
1558-
.max_satisfaction_weight()
1559-
.unwrap(),
1565+
desc.max_satisfaction_weight().unwrap() + workaround_weight,
15601566
)
15611567
})
15621568
.collect())

0 commit comments

Comments
 (0)