Browse Source
Avoid cloning and allocation of tx inputs
If all we need is a mutable reference to the tx input, we can
grab one via `iter_mut`.
bdk-0.11
Thomas Eizinger
4 years ago
committed by
Lucas Soriano del Pino
No known key found for this signature in database
GPG Key ID: EE611E973A1530E7
1 changed files with
4 additions and
8 deletions
-
cfd_protocol/src/lib.rs
|
|
@ -208,7 +208,7 @@ pub fn spending_tx_sighash( |
|
|
|
} |
|
|
|
|
|
|
|
pub fn finalize_spend_transaction( |
|
|
|
tx: Transaction, |
|
|
|
mut tx: Transaction, |
|
|
|
spent_descriptor: &Descriptor<PublicKey>, |
|
|
|
(maker_pk, maker_sig): (PublicKey, Signature), |
|
|
|
(taker_pk, taker_sig): (PublicKey, Signature), |
|
|
@ -222,16 +222,12 @@ pub fn finalize_spend_transaction( |
|
|
|
satisfier |
|
|
|
}; |
|
|
|
|
|
|
|
let mut input = tx |
|
|
|
let input = tx |
|
|
|
.input |
|
|
|
.clone() |
|
|
|
.into_iter() |
|
|
|
.iter_mut() |
|
|
|
.exactly_one() |
|
|
|
.expect("all spend transactions to have one input"); |
|
|
|
spent_descriptor.satisfy(&mut input, satisfier)?; |
|
|
|
|
|
|
|
let mut tx = tx; |
|
|
|
tx.input = vec![input]; |
|
|
|
spent_descriptor.satisfy(input, satisfier)?; |
|
|
|
|
|
|
|
Ok(tx) |
|
|
|
} |
|
|
|