@ -23,14 +23,6 @@ pub struct StartMonitoring {
pub params : MonitorParams ,
}
#[ derive(Clone) ]
pub struct Cet {
txid : Txid ,
script : Script ,
range : RangeInclusive < u64 > ,
n_bits : usize ,
}
#[ derive(Clone) ]
pub struct MonitorParams {
lock : ( Txid , Descriptor < PublicKey > ) ,
@ -111,7 +103,7 @@ where
actor . monitor_refund_finality ( & params , cfd . order . id ) ;
}
CetStatus ::OracleSigned ( attestation ) = > {
actor . monitor_cet_finality ( map_cets ( dlc . cets , dlc . maker_address . script_pubkey ( ) ) , attestation . into ( ) , cfd . order . id ) ? ;
actor . monitor_cet_finality ( map_cets ( dlc . cets ) , attestation . into ( ) , cfd . order . id ) ? ;
actor . monitor_commit_cet_timelock ( & params , cfd . order . id ) ;
actor . monitor_commit_refund_timelock ( & params , cfd . order . id ) ;
actor . monitor_refund_finality ( & params , cfd . order . id ) ;
@ -121,7 +113,7 @@ where
actor . monitor_refund_finality ( & params , cfd . order . id ) ;
}
CetStatus ::Ready ( attestation ) = > {
actor . monitor_cet_finality ( map_cets ( dlc . cets , dlc . maker_address . script_pubkey ( ) ) , attestation . into ( ) , cfd . order . id ) ? ;
actor . monitor_cet_finality ( map_cets ( dlc . cets ) , attestation . into ( ) , cfd . order . id ) ? ;
actor . monitor_commit_refund_timelock ( & params , cfd . order . id ) ;
actor . monitor_refund_finality ( & params , cfd . order . id ) ;
}
@ -547,7 +539,7 @@ impl MonitorParams {
MonitorParams {
lock : ( dlc . lock . 0. txid ( ) , dlc . lock . 1 ) ,
commit : ( dlc . commit . 0. txid ( ) , dlc . commit . 2 ) ,
cets : map_cets ( dlc . cets , script_pubkey . clone ( ) ) ,
cets : map_cets ( dlc . cets ) ,
refund : (
dlc . refund . 0. txid ( ) ,
script_pubkey ,
@ -562,26 +554,33 @@ impl MonitorParams {
}
}
#[ derive(Clone) ]
struct Cet {
txid : Txid ,
script : Script ,
range : RangeInclusive < u64 > ,
n_bits : usize ,
}
impl From < model ::cfd ::Cet > for Cet {
fn from ( cet : model ::cfd ::Cet ) -> Self {
Cet {
txid : cet . tx . txid ( ) ,
script : cet . tx . output [ 0 ] . script_pubkey . clone ( ) ,
range : cet . range . clone ( ) ,
n_bits : cet . n_bits ,
}
}
}
fn map_cets (
cets : HashMap < OracleEventId , Vec < model ::cfd ::Cet > > ,
script_pubkey : Script ,
) -> HashMap < OracleEventId , Vec < Cet > > {
cets . iter ( )
cets . into_i ter ( )
. map ( | ( event_id , cets ) | {
(
event_id . clone ( ) ,
cets . iter ( )
. map (
| model ::cfd ::Cet {
tx , range , n_bits , . .
} | Cet {
txid : tx . txid ( ) ,
script : script_pubkey . clone ( ) ,
range : range . clone ( ) ,
n_bits : * n_bits ,
} ,
)
. collect ::< Vec < _ > > ( ) ,
event_id ,
cets . into_iter ( ) . map ( Cet ::from ) . collect ::< Vec < _ > > ( ) ,
)
} )
. collect ( )