@@ -97,30 +97,36 @@ pub(crate) struct RevokedOutput {
97
97
weight : u64 ,
98
98
amount : u64 ,
99
99
on_counterparty_tx_csv : u16 ,
100
+ opt_anchors : Option < ( ) > ,
101
+ is_counterparty_balance_or_non_anchors : Option < ( ) > ,
100
102
}
101
103
102
104
impl RevokedOutput {
103
- pub ( crate ) fn build ( per_commitment_point : PublicKey , counterparty_delayed_payment_base_key : PublicKey , counterparty_htlc_base_key : PublicKey , per_commitment_key : SecretKey , amount : u64 , on_counterparty_tx_csv : u16 ) -> Self {
105
+ pub ( crate ) fn build ( per_commitment_point : PublicKey , counterparty_delayed_payment_base_key : PublicKey , counterparty_htlc_base_key : PublicKey , per_commitment_key : SecretKey , amount : u64 , on_counterparty_tx_csv : u16 , opt_anchors : bool , is_counterparty_balance : bool ) -> Self {
104
106
RevokedOutput {
105
107
per_commitment_point,
106
108
counterparty_delayed_payment_base_key,
107
109
counterparty_htlc_base_key,
108
110
per_commitment_key,
109
111
weight : WEIGHT_REVOKED_OUTPUT ,
110
112
amount,
111
- on_counterparty_tx_csv
113
+ on_counterparty_tx_csv,
114
+ opt_anchors : if opt_anchors { Some ( ( ) ) } else { None } ,
115
+ is_counterparty_balance_or_non_anchors : if is_counterparty_balance { Some ( ( ) ) } else { None } ,
112
116
}
113
117
}
114
118
}
115
119
116
120
impl_writeable_tlv_based ! ( RevokedOutput , {
117
121
( 0 , per_commitment_point, required) ,
122
+ ( 1 , is_counterparty_balance_or_non_anchors, option) ,
118
123
( 2 , counterparty_delayed_payment_base_key, required) ,
119
124
( 4 , counterparty_htlc_base_key, required) ,
120
125
( 6 , per_commitment_key, required) ,
121
126
( 8 , weight, required) ,
122
127
( 10 , amount, required) ,
123
128
( 12 , on_counterparty_tx_csv, required) ,
129
+ ( 14 , opt_anchors, option) ,
124
130
} ) ;
125
131
126
132
/// A struct to describe a revoked offered output and corresponding information to generate a
@@ -750,14 +756,7 @@ impl PackageTemplate {
750
756
}
751
757
752
758
pub ( crate ) fn build_package ( txid : Txid , vout : u32 , input_solving_data : PackageSolvingData , soonest_conf_deadline : u32 , aggregable : bool , height_original : u32 ) -> Self {
753
- let malleability = match input_solving_data {
754
- PackageSolvingData :: RevokedOutput ( ..) => PackageMalleability :: Malleable ,
755
- PackageSolvingData :: RevokedHTLCOutput ( ..) => PackageMalleability :: Malleable ,
756
- PackageSolvingData :: CounterpartyOfferedHTLCOutput ( ..) => PackageMalleability :: Malleable ,
757
- PackageSolvingData :: CounterpartyReceivedHTLCOutput ( ..) => PackageMalleability :: Malleable ,
758
- PackageSolvingData :: HolderHTLCOutput ( ..) => PackageMalleability :: Untractable ,
759
- PackageSolvingData :: HolderFundingOutput ( ..) => PackageMalleability :: Untractable ,
760
- } ;
759
+ let ( malleability, aggregable) = Self :: map_output_type_flags ( & input_solving_data) ;
761
760
let mut inputs = Vec :: with_capacity ( 1 ) ;
762
761
inputs. push ( ( BitcoinOutPoint { txid, vout } , input_solving_data) ) ;
763
762
PackageTemplate {
@@ -770,6 +769,20 @@ impl PackageTemplate {
770
769
height_original,
771
770
}
772
771
}
772
+
773
+ fn map_output_type_flags ( input_solving_data : & PackageSolvingData ) -> ( PackageMalleability , bool ) {
774
+ let ( malleability, aggregable) = match input_solving_data {
775
+ PackageSolvingData :: RevokedOutput ( RevokedOutput { is_counterparty_balance_or_non_anchors : None , .. } ) => { ( PackageMalleability :: Malleable , true ) } ,
776
+ PackageSolvingData :: RevokedOutput ( RevokedOutput { opt_anchors : Some ( ..) , .. } ) => { ( PackageMalleability :: Malleable , false ) } ,
777
+ PackageSolvingData :: RevokedOutput ( RevokedOutput { opt_anchors : None , .. } ) => { ( PackageMalleability :: Malleable , true ) } ,
778
+ PackageSolvingData :: RevokedHTLCOutput ( ..) => { ( PackageMalleability :: Malleable , true ) } ,
779
+ PackageSolvingData :: CounterpartyOfferedHTLCOutput ( ..) => { ( PackageMalleability :: Malleable , true ) } ,
780
+ PackageSolvingData :: CounterpartyReceivedHTLCOutput ( ..) => { ( PackageMalleability :: Malleable , false ) } ,
781
+ PackageSolvingData :: HolderHTLCOutput ( ..) => { ( PackageMalleability :: Untractable , false ) } ,
782
+ PackageSolvingData :: HolderFundingOutput ( ..) => { ( PackageMalleability :: Untractable , false ) } ,
783
+ } ;
784
+ ( malleability, aggregable)
785
+ }
773
786
}
774
787
775
788
impl Writeable for PackageTemplate {
@@ -799,14 +812,7 @@ impl Readable for PackageTemplate {
799
812
inputs. push ( ( outpoint, rev_outp) ) ;
800
813
}
801
814
let ( malleability, aggregable) = if let Some ( ( _, lead_input) ) = inputs. first ( ) {
802
- match lead_input {
803
- PackageSolvingData :: RevokedOutput ( ..) => { ( PackageMalleability :: Malleable , true ) } ,
804
- PackageSolvingData :: RevokedHTLCOutput ( ..) => { ( PackageMalleability :: Malleable , true ) } ,
805
- PackageSolvingData :: CounterpartyOfferedHTLCOutput ( ..) => { ( PackageMalleability :: Malleable , true ) } ,
806
- PackageSolvingData :: CounterpartyReceivedHTLCOutput ( ..) => { ( PackageMalleability :: Malleable , false ) } ,
807
- PackageSolvingData :: HolderHTLCOutput ( ..) => { ( PackageMalleability :: Untractable , false ) } ,
808
- PackageSolvingData :: HolderFundingOutput ( ..) => { ( PackageMalleability :: Untractable , false ) } ,
809
- }
815
+ Self :: map_output_type_flags ( & lead_input)
810
816
} else { return Err ( DecodeError :: InvalidValue ) ; } ;
811
817
let mut soonest_conf_deadline = 0 ;
812
818
let mut feerate_previous = 0 ;
@@ -930,7 +936,7 @@ mod tests {
930
936
{
931
937
let dumb_scalar = SecretKey :: from_slice( & hex:: decode( "0101010101010101010101010101010101010101010101010101010101010101" ) . unwrap( ) [ ..] ) . unwrap( ) ;
932
938
let dumb_point = PublicKey :: from_secret_key( & $secp_ctx, & dumb_scalar) ;
933
- PackageSolvingData :: RevokedOutput ( RevokedOutput :: build( dumb_point, dumb_point, dumb_point, dumb_scalar, 0 , 0 ) )
939
+ PackageSolvingData :: RevokedOutput ( RevokedOutput :: build( dumb_point, dumb_point, dumb_point, dumb_scalar, 0 , 0 , false , false ) )
934
940
}
935
941
}
936
942
}
0 commit comments