@@ -87,24 +87,29 @@ impl From<revault_net::Error> for CommunicationError {
87
87
}
88
88
}
89
89
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 )
91
91
// message to a watchtower.
92
- fn send_wt_sig_msg (
92
+ fn send_wt_sigs_msg (
93
93
transport : & mut KKTransport ,
94
94
deposit_outpoint : OutPoint ,
95
95
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 ,
98
99
) -> 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 {
100
106
signatures,
101
- txid,
102
107
deposit_outpoint,
103
108
derivation_index,
104
109
} ;
105
110
106
111
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 ( ) ) ?;
108
113
log:: debug!(
109
114
"Got response to signatures for '{}' from watchtower: '{:?}'" ,
110
115
deposit_outpoint,
@@ -149,63 +154,26 @@ pub fn send_coord_sig_msg(
149
154
Ok ( ( ) )
150
155
}
151
156
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 (
159
159
noise_secret : & revault_net:: noise:: SecretKey ,
160
160
watchtowers : & [ ( std:: net:: SocketAddr , revault_net:: noise:: PublicKey ) ] ,
161
161
deposit_outpoint : OutPoint ,
162
162
derivation_index : ChildNumber ,
163
163
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 ,
189
164
cancel_tx : & DbTransaction ,
190
- unvault_emer_tx : & DbTransaction ,
165
+ unemer_tx : & DbTransaction ,
191
166
) -> Result < ( ) , CommunicationError > {
192
167
for ( wt_host, wt_noisekey) in watchtowers {
193
168
let mut transport = KKTransport :: connect ( * wt_host, noise_secret, wt_noisekey) ?;
194
169
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 (
204
171
& mut transport,
205
172
deposit_outpoint,
206
173
derivation_index,
207
- cancel_tx. psbt . txid ( ) ,
208
- cancel_tx. psbt . signatures ( ) ,
174
+ emer_tx,
175
+ cancel_tx,
176
+ unemer_tx,
209
177
) ?;
210
178
}
211
179
0 commit comments