Skip to content

Commit dd0017c

Browse files
committed
Tweak PSBT signing for bindings compatibility
In bindings we can't practically pass a mutable PSBT, and instead need to pass an owned transaction and have the sign method return a signed copy. We do this here for all build modes as its not a material API change for Rust users.
1 parent 4a13789 commit dd0017c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lightning/src/sign/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,7 +1312,7 @@ impl KeysManager {
13121312
///
13131313
/// May panic if the [`SpendableOutputDescriptor`]s were not generated by channels which used
13141314
/// this [`KeysManager`] or one of the [`InMemorySigner`] created by this [`KeysManager`].
1315-
pub fn sign_spendable_outputs_psbt<C: Signing>(&self, descriptors: &[&SpendableOutputDescriptor], psbt: &mut PartiallySignedTransaction, secp_ctx: &Secp256k1<C>) -> Result<(), ()> {
1315+
pub fn sign_spendable_outputs_psbt<C: Signing>(&self, descriptors: &[&SpendableOutputDescriptor], mut psbt: PartiallySignedTransaction, secp_ctx: &Secp256k1<C>) -> Result<PartiallySignedTransaction, ()> {
13161316
let mut keys_cache: Option<(InMemorySigner, [u8; 32])> = None;
13171317
for outp in descriptors {
13181318
match outp {
@@ -1374,7 +1374,7 @@ impl KeysManager {
13741374
}
13751375
}
13761376

1377-
Ok(())
1377+
Ok(psbt)
13781378
}
13791379

13801380
/// Creates a [`Transaction`] which spends the given descriptors to the given outputs, plus an
@@ -1396,7 +1396,7 @@ impl KeysManager {
13961396
/// this [`KeysManager`] or one of the [`InMemorySigner`] created by this [`KeysManager`].
13971397
pub fn spend_spendable_outputs<C: Signing>(&self, descriptors: &[&SpendableOutputDescriptor], outputs: Vec<TxOut>, change_destination_script: Script, feerate_sat_per_1000_weight: u32, locktime: Option<PackedLockTime>, secp_ctx: &Secp256k1<C>) -> Result<Transaction, ()> {
13981398
let (mut psbt, expected_max_weight) = SpendableOutputDescriptor::create_spendable_outputs_psbt(descriptors, outputs, change_destination_script, feerate_sat_per_1000_weight, locktime)?;
1399-
self.sign_spendable_outputs_psbt(descriptors, &mut psbt, secp_ctx)?;
1399+
psbt = self.sign_spendable_outputs_psbt(descriptors, psbt, secp_ctx)?;
14001400

14011401
let spend_tx = psbt.extract_tx();
14021402

0 commit comments

Comments
 (0)