@@ -87,24 +87,29 @@ impl From<revault_net::Error> for CommunicationError {
8787 }
8888}
8989
90- // Send a `sig ` (https://github.com/revault/practical-revault/blob/master/messages.md#sig )
90+ // Send a `sigs ` (https://github.com/revault/practical-revault/blob/master/messages.md#sigs )
9191// message to a watchtower.
92- fn send_wt_sig_msg (
92+ fn send_wt_sigs_msg (
9393 transport : & mut KKTransport ,
9494 deposit_outpoint : OutPoint ,
9595 derivation_index : ChildNumber ,
96- txid : Txid ,
97- signatures : BTreeMap < secp256k1:: PublicKey , secp256k1:: Signature > ,
96+ emer_tx : & DbTransaction ,
97+ cancel_tx : & DbTransaction ,
98+ unemer_tx : & DbTransaction ,
9899) -> Result < ( ) , CommunicationError > {
99- let sig_msg = watchtower:: Sig {
100+ let signatures = watchtower:: Signatures {
101+ emergency : emer_tx. psbt . signatures ( ) ,
102+ cancel : cancel_tx. psbt . signatures ( ) ,
103+ unvault_emergency : unemer_tx. psbt . signatures ( ) ,
104+ } ;
105+ let sig_msg = watchtower:: Sigs {
100106 signatures,
101- txid,
102107 deposit_outpoint,
103108 derivation_index,
104109 } ;
105110
106111 log:: debug!( "Sending signatures to watchtower: '{:?}'" , sig_msg) ;
107- let sig_result: watchtower:: SigResult = transport. send_req ( & sig_msg. into ( ) ) ?;
112+ let sig_result: watchtower:: SigsResult = transport. send_req ( & sig_msg. into ( ) ) ?;
108113 log:: debug!(
109114 "Got response to signatures for '{}' from watchtower: '{:?}'" ,
110115 deposit_outpoint,
@@ -149,63 +154,26 @@ pub fn send_coord_sig_msg(
149154 Ok ( ( ) )
150155}
151156
152- /// Send the signatures for the Emergency transaction to the Watchtower.
153- /// Only sharing the Emergency signature tells the watchtower to be aware of, but
154- /// not watch, the vault. Later sharing the UnvaultEmergency and Cancel signatures
155- /// will trigger it to watch it.
156- // FIXME: better to share all signatures early and to then have another message
157- // asking permission before delegating.
158- pub fn wts_share_emer_signatures (
157+ /// Share the revocation transactions' signatures with all our watchtowers.
158+ pub fn wts_share_rev_signatures (
159159 noise_secret : & revault_net:: noise:: SecretKey ,
160160 watchtowers : & [ ( std:: net:: SocketAddr , revault_net:: noise:: PublicKey ) ] ,
161161 deposit_outpoint : OutPoint ,
162162 derivation_index : ChildNumber ,
163163 emer_tx : & DbTransaction ,
164- ) -> Result < ( ) , CommunicationError > {
165- for ( wt_host, wt_noisekey) in watchtowers {
166- let mut transport = KKTransport :: connect ( * wt_host, noise_secret, wt_noisekey) ?;
167-
168- send_wt_sig_msg (
169- & mut transport,
170- deposit_outpoint,
171- derivation_index,
172- emer_tx. psbt . txid ( ) ,
173- emer_tx. psbt . signatures ( ) ,
174- ) ?;
175- }
176-
177- Ok ( ( ) )
178- }
179-
180- /// Send the signatures for the UnvaultEmergency and Cancel transactions to all
181- /// our watchtowers. This serves as a signal for watchtowers to start watching for
182- /// this vault and they may therefore NACK that we delegate it (eg if they don't
183- /// have enough fee reserve).
184- pub fn wts_share_second_stage_signatures (
185- noise_secret : & revault_net:: noise:: SecretKey ,
186- watchtowers : & [ ( std:: net:: SocketAddr , revault_net:: noise:: PublicKey ) ] ,
187- deposit_outpoint : OutPoint ,
188- derivation_index : ChildNumber ,
189164 cancel_tx : & DbTransaction ,
190- unvault_emer_tx : & DbTransaction ,
165+ unemer_tx : & DbTransaction ,
191166) -> Result < ( ) , CommunicationError > {
192167 for ( wt_host, wt_noisekey) in watchtowers {
193168 let mut transport = KKTransport :: connect ( * wt_host, noise_secret, wt_noisekey) ?;
194169
195- // The watchtower enforces a specific sequence in which to exchange transactions
196- send_wt_sig_msg (
197- & mut transport,
198- deposit_outpoint,
199- derivation_index,
200- unvault_emer_tx. psbt . txid ( ) ,
201- unvault_emer_tx. psbt . signatures ( ) ,
202- ) ?;
203- send_wt_sig_msg (
170+ send_wt_sigs_msg (
204171 & mut transport,
205172 deposit_outpoint,
206173 derivation_index,
207- cancel_tx. psbt . txid ( ) ,
208- cancel_tx. psbt . signatures ( ) ,
174+ emer_tx,
175+ cancel_tx,
176+ unemer_tx,
209177 ) ?;
210178 }
211179
0 commit comments