@@ -1464,7 +1464,7 @@ impl CommitmentTransaction {
1464
1464
let keys = TxCreationKeys :: from_channel_static_keys ( per_commitment_point, channel_parameters. broadcaster_pubkeys ( ) , channel_parameters. countersignatory_pubkeys ( ) , secp_ctx) ;
1465
1465
1466
1466
// Sort outputs and populate output indices
1467
- let ( outputs, nondust_htlcs) = Self :: build_outputs_and_htlcs ( & keys, to_broadcaster_value_sat, to_countersignatory_value_sat, nondust_htlcs, channel_parameters) . unwrap ( ) ;
1467
+ let ( outputs, nondust_htlcs) = Self :: build_outputs_and_htlcs ( & keys, to_broadcaster_value_sat, to_countersignatory_value_sat, nondust_htlcs, channel_parameters) ;
1468
1468
1469
1469
let ( obscured_commitment_transaction_number, txins) = Self :: internal_build_inputs ( commitment_number, channel_parameters) ;
1470
1470
let transaction = Self :: make_transaction ( obscured_commitment_transaction_number, txins, outputs) ;
@@ -1499,10 +1499,10 @@ impl CommitmentTransaction {
1499
1499
// and as they'd appear on the commitment transaction.
1500
1500
// - Maps this vector to a `Vec<TxOut>`, keeping the original order of the outputs.
1501
1501
// - Then uses the vectors of inputs and outputs to build the commitment transaction.
1502
- fn internal_rebuild_transaction ( & self , keys : & TxCreationKeys , channel_parameters : & DirectedChannelTransactionParameters ) -> Result < BuiltCommitmentTransaction , ( ) > {
1502
+ fn internal_rebuild_transaction ( & self , keys : & TxCreationKeys , channel_parameters : & DirectedChannelTransactionParameters ) -> BuiltCommitmentTransaction {
1503
1503
let ( obscured_commitment_transaction_number, txins) = Self :: internal_build_inputs ( self . commitment_number , channel_parameters) ;
1504
1504
1505
- let txout_htlc_pairs = Self :: internal_build_outputs ( keys, self . to_broadcaster_value_sat , self . to_countersignatory_value_sat , self . htlcs ( ) . iter ( ) , channel_parameters) ? ;
1505
+ let txout_htlc_pairs = Self :: internal_build_outputs ( keys, self . to_broadcaster_value_sat , self . to_countersignatory_value_sat , self . htlcs ( ) . iter ( ) , channel_parameters) ;
1506
1506
let outputs = txout_htlc_pairs. into_iter ( ) . map ( |( output, _) | output) . collect ( ) ;
1507
1507
1508
1508
let transaction = Self :: make_transaction ( obscured_commitment_transaction_number, txins, outputs) ;
@@ -1511,7 +1511,7 @@ impl CommitmentTransaction {
1511
1511
transaction,
1512
1512
txid
1513
1513
} ;
1514
- Ok ( built_transaction)
1514
+ built_transaction
1515
1515
}
1516
1516
1517
1517
fn make_transaction ( obscured_commitment_transaction_number : u64 , txins : Vec < TxIn > , outputs : Vec < TxOut > ) -> Transaction {
@@ -1533,9 +1533,9 @@ impl CommitmentTransaction {
1533
1533
// - Returns the two vectors: the vector of `TxOut`, and the vector of `HTLCOutputInCommitment`:
1534
1534
// - `Vec<TxOut>` gets moved to the `Transaction` cached by `CommitmentTransaction`,
1535
1535
// - `Vec<HTLCOutputInCommitment>` gets moved to and cached by `CommitmentTransaction`.
1536
- fn build_outputs_and_htlcs ( keys : & TxCreationKeys , to_broadcaster_value_sat : Amount , to_countersignatory_value_sat : Amount , nondust_htlcs : Vec < & mut HTLCOutputInCommitment > , channel_parameters : & DirectedChannelTransactionParameters ) -> Result < ( Vec < TxOut > , Vec < HTLCOutputInCommitment > ) , ( ) > {
1536
+ fn build_outputs_and_htlcs ( keys : & TxCreationKeys , to_broadcaster_value_sat : Amount , to_countersignatory_value_sat : Amount , nondust_htlcs : Vec < & mut HTLCOutputInCommitment > , channel_parameters : & DirectedChannelTransactionParameters ) -> ( Vec < TxOut > , Vec < HTLCOutputInCommitment > ) {
1537
1537
let mut htlcs: Vec < HTLCOutputInCommitment > = Vec :: with_capacity ( nondust_htlcs. len ( ) ) ;
1538
- let mut txout_htlc_pairs: Vec < ( TxOut , Option < & mut HTLCOutputInCommitment > ) > = Self :: internal_build_outputs ( keys, to_broadcaster_value_sat, to_countersignatory_value_sat, nondust_htlcs. into_iter ( ) , channel_parameters) ? ;
1538
+ let mut txout_htlc_pairs: Vec < ( TxOut , Option < & mut HTLCOutputInCommitment > ) > = Self :: internal_build_outputs ( keys, to_broadcaster_value_sat, to_countersignatory_value_sat, nondust_htlcs. into_iter ( ) , channel_parameters) ;
1539
1539
let mut outputs: Vec < TxOut > = Vec :: with_capacity ( txout_htlc_pairs. len ( ) ) ;
1540
1540
for ( idx, out) in txout_htlc_pairs. drain ( ..) . enumerate ( ) {
1541
1541
if let Some ( htlc) = out. 1 {
@@ -1546,7 +1546,7 @@ impl CommitmentTransaction {
1546
1546
}
1547
1547
outputs. push ( out. 0 ) ;
1548
1548
}
1549
- Ok ( ( outputs, htlcs) )
1549
+ ( outputs, htlcs)
1550
1550
}
1551
1551
1552
1552
// This function
@@ -1556,7 +1556,7 @@ impl CommitmentTransaction {
1556
1556
// For the `Option` in the tuple, an HTLC output sets the option to `Some(T)`, and all the other outputs set the option to `None`.
1557
1557
// - Passes this vector to `sort_outputs` to sort all the tuples in the vector according to the LN specification.
1558
1558
// - Then returns this sorted vector to the caller.
1559
- fn internal_build_outputs < T : Borrow < HTLCOutputInCommitment > > ( keys : & TxCreationKeys , to_broadcaster_value_sat : Amount , to_countersignatory_value_sat : Amount , nondust_htlcs : impl Iterator < Item = T > , channel_parameters : & DirectedChannelTransactionParameters ) -> Result < Vec < ( TxOut , Option < T > ) > , ( ) > {
1559
+ fn internal_build_outputs < T : Borrow < HTLCOutputInCommitment > > ( keys : & TxCreationKeys , to_broadcaster_value_sat : Amount , to_countersignatory_value_sat : Amount , nondust_htlcs : impl Iterator < Item = T > , channel_parameters : & DirectedChannelTransactionParameters ) -> Vec < ( TxOut , Option < T > ) > {
1560
1560
let countersignatory_pubkeys = channel_parameters. countersignatory_pubkeys ( ) ;
1561
1561
let broadcaster_funding_key = & channel_parameters. broadcaster_pubkeys ( ) . funding_pubkey ;
1562
1562
let countersignatory_funding_key = & countersignatory_pubkeys. funding_pubkey ;
@@ -1646,7 +1646,7 @@ impl CommitmentTransaction {
1646
1646
} else { cmp:: Ordering :: Equal }
1647
1647
} ) ;
1648
1648
1649
- Ok ( txouts)
1649
+ txouts
1650
1650
}
1651
1651
1652
1652
fn internal_build_inputs ( commitment_number : u64 , channel_parameters : & DirectedChannelTransactionParameters ) -> ( u64 , Vec < TxIn > ) {
@@ -1732,7 +1732,7 @@ impl CommitmentTransaction {
1732
1732
if keys != self . keys {
1733
1733
return Err ( ( ) ) ;
1734
1734
}
1735
- let tx = self . internal_rebuild_transaction ( & keys, channel_parameters) ? ;
1735
+ let tx = self . internal_rebuild_transaction ( & keys, channel_parameters) ;
1736
1736
if self . built . transaction != tx. transaction || self . built . txid != tx. txid {
1737
1737
return Err ( ( ) ) ;
1738
1738
}
0 commit comments