Skip to content

Commit 5634012

Browse files
committed
Remove some unneeded Result's in CommitmentTransaction
1 parent 09dc44d commit 5634012

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lightning/src/ln/chan_utils.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,7 +1508,7 @@ impl CommitmentTransaction {
15081508
let keys = TxCreationKeys::from_channel_static_keys(per_commitment_point, channel_parameters.broadcaster_pubkeys(), channel_parameters.countersignatory_pubkeys(), secp_ctx);
15091509

15101510
// Sort outputs and populate output indices while keeping track of the auxiliary data
1511-
let (outputs, htlcs) = Self::internal_build_outputs(&keys, to_broadcaster_value_sat, to_countersignatory_value_sat, htlcs_with_aux, channel_parameters).unwrap();
1511+
let (outputs, htlcs) = Self::internal_build_outputs(&keys, to_broadcaster_value_sat, to_countersignatory_value_sat, htlcs_with_aux, channel_parameters);
15121512

15131513
let (obscured_commitment_transaction_number, txins) = Self::internal_build_inputs(commitment_number, channel_parameters);
15141514
let transaction = Self::make_transaction(obscured_commitment_transaction_number, txins, outputs);
@@ -1537,19 +1537,19 @@ impl CommitmentTransaction {
15371537
self
15381538
}
15391539

1540-
fn internal_rebuild_transaction(&self, keys: &TxCreationKeys, channel_parameters: &DirectedChannelTransactionParameters) -> Result<BuiltCommitmentTransaction, ()> {
1540+
fn internal_rebuild_transaction(&self, keys: &TxCreationKeys, channel_parameters: &DirectedChannelTransactionParameters) -> BuiltCommitmentTransaction {
15411541
let (obscured_commitment_transaction_number, txins) = Self::internal_build_inputs(self.commitment_number, channel_parameters);
15421542

15431543
let mut htlcs_with_aux = self.htlcs.iter().map(|h| (h.clone(), ())).collect();
1544-
let (outputs, _) = Self::internal_build_outputs(keys, self.to_broadcaster_value_sat, self.to_countersignatory_value_sat, &mut htlcs_with_aux, channel_parameters)?;
1544+
let (outputs, _) = Self::internal_build_outputs(keys, self.to_broadcaster_value_sat, self.to_countersignatory_value_sat, &mut htlcs_with_aux, channel_parameters);
15451545

15461546
let transaction = Self::make_transaction(obscured_commitment_transaction_number, txins, outputs);
15471547
let txid = transaction.compute_txid();
15481548
let built_transaction = BuiltCommitmentTransaction {
15491549
transaction,
15501550
txid
15511551
};
1552-
Ok(built_transaction)
1552+
built_transaction
15531553
}
15541554

15551555
fn make_transaction(obscured_commitment_transaction_number: u64, txins: Vec<TxIn>, outputs: Vec<TxOut>) -> Transaction {
@@ -1565,7 +1565,7 @@ impl CommitmentTransaction {
15651565
// - initial sorting of outputs / HTLCs in the constructor, in which case T is auxiliary data the
15661566
// caller needs to have sorted together with the HTLCs so it can keep track of the output index
15671567
// - building of a bitcoin transaction during a verify() call, in which case T is just ()
1568-
fn internal_build_outputs<T>(keys: &TxCreationKeys, to_broadcaster_value_sat: Amount, to_countersignatory_value_sat: Amount, htlcs_with_aux: &mut Vec<(HTLCOutputInCommitment, T)>, channel_parameters: &DirectedChannelTransactionParameters) -> Result<(Vec<TxOut>, Vec<HTLCOutputInCommitment>), ()> {
1568+
fn internal_build_outputs<T>(keys: &TxCreationKeys, to_broadcaster_value_sat: Amount, to_countersignatory_value_sat: Amount, htlcs_with_aux: &mut Vec<(HTLCOutputInCommitment, T)>, channel_parameters: &DirectedChannelTransactionParameters) -> (Vec<TxOut>, Vec<HTLCOutputInCommitment>) {
15691569
let countersignatory_payment_point = &channel_parameters.countersignatory_pubkeys().payment_point;
15701570
let countersignatory_funding_key = &channel_parameters.countersignatory_pubkeys().funding_pubkey;
15711571
let broadcaster_funding_key = &channel_parameters.broadcaster_pubkeys().funding_pubkey;
@@ -1662,7 +1662,7 @@ impl CommitmentTransaction {
16621662
}
16631663
outputs.push(out.0);
16641664
}
1665-
Ok((outputs, htlcs))
1665+
(outputs, htlcs)
16661666
}
16671667

16681668
fn internal_build_inputs(commitment_number: u64, channel_parameters: &DirectedChannelTransactionParameters) -> (u64, Vec<TxIn>) {
@@ -1748,7 +1748,7 @@ impl CommitmentTransaction {
17481748
if keys != self.keys {
17491749
return Err(());
17501750
}
1751-
let tx = self.internal_rebuild_transaction(&keys, channel_parameters)?;
1751+
let tx = self.internal_rebuild_transaction(&keys, channel_parameters);
17521752
if self.built.transaction != tx.transaction || self.built.txid != tx.txid {
17531753
return Err(());
17541754
}

0 commit comments

Comments
 (0)