Skip to content

Commit d0f512d

Browse files
committed
update clementine.proto
1 parent 350321d commit d0f512d

File tree

2 files changed

+93
-26
lines changed

2 files changed

+93
-26
lines changed

proto/clementine.proto

Lines changed: 72 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ message Outpoint {
1212
uint32 vout = 2;
1313
}
1414

15-
message XonlyPublicKey {
16-
bytes xonly_pk = 1;
17-
}
18-
1915
message NofnResponse {
2016
bytes nofn_xonly_pk = 1;
2117
uint32 num_verifiers = 2;
@@ -278,14 +274,14 @@ message EntityError {
278274

279275
message EntityStatus {
280276
bool automation = 1;
281-
string wallet_balance = 2;
282-
uint32 tx_sender_synced_height = 3;
283-
uint32 finalized_synced_height = 4;
284-
uint32 hcp_last_proven_height = 5;
277+
optional string wallet_balance = 2;
278+
optional uint32 tx_sender_synced_height = 3;
279+
optional uint32 finalized_synced_height = 4;
280+
optional uint32 hcp_last_proven_height = 5;
285281
StoppedTasks stopped_tasks = 6;
286-
uint32 rpc_tip_height = 7;
287-
uint32 bitcoin_syncer_synced_height = 8;
288-
uint32 state_manager_next_height = 9;
282+
optional uint32 rpc_tip_height = 7;
283+
optional uint32 bitcoin_syncer_synced_height = 8;
284+
optional uint32 state_manager_next_height = 9;
289285
}
290286

291287
enum EntityType {
@@ -356,11 +352,31 @@ service ClementineOperator {
356352
// Restarts the background tasks for the operator.
357353
rpc RestartBackgroundTasks(Empty) returns (Empty) {}
358354

359-
// Prepares a withdrawal if it's profitable and the withdrawal is correct and registered in Citrea bridge contract/
355+
// Prepares a withdrawal if it's profitable and the withdrawal is correct and registered in Citrea bridge contract.
360356
// If withdrawal is accepted, the payout tx will be added to the TxSender and success is returned, otherwise an error is returned.
361357
// If automation is disabled, the withdrawal will not be accepted and an error will be returned.
362-
rpc Withdraw(WithdrawParams)
363-
returns (Empty) {}
358+
// Note: This is intended for operator's own use, so it doesn't include a signature from aggregator.
359+
rpc InternalWithdraw(WithdrawParams)
360+
returns (RawSignedTx) {}
361+
362+
363+
// First, if verification address in operator's config is set, the signature in rpc is checked to see if it was signed by the verification address.
364+
// Then prepares a withdrawal if it's profitable and the withdrawal is correct and registered in Citrea bridge contract.
365+
// If withdrawal is accepted, the payout tx will be added to the TxSender and success is returned, otherwise an error is returned.
366+
// If automation is disabled, the withdrawal will not be accepted and an error will be returned.
367+
rpc Withdraw(WithdrawParamsWithSig)
368+
returns (RawSignedTx) {}
369+
370+
// For a given deposit outpoint, determines the next step in the kickoff process the operator is in,
371+
// and returns the raw signed txs that the operator needs to send next, for enabling reimbursement process
372+
// without automation.
373+
//
374+
// # Parameters
375+
// - deposit_outpoint: Deposit outpoint to create the kickoff for
376+
//
377+
// # Returns
378+
// - Raw signed txs that the operator needs to send next
379+
rpc GetReimbursementTxs(Outpoint) returns (SignedTxsWithType) {}
364380

365381
// Signs all tx's it can according to given transaction type (use it with AllNeededForDeposit to get almost all tx's)
366382
// Creates the transactions denoted by the deposit and operator_idx, round_idx, and kickoff_idx.
@@ -411,7 +427,8 @@ message NonceGenRequest {
411427

412428
message NonceGenFirstResponse {
413429
// ID of the nonce session (used to store nonces in verifier's memory)
414-
uint32 id = 1;
430+
// The id is string representation of a u128 number
431+
string id = 1;
415432
// Number of nonces to generate
416433
uint32 num_nonces = 2;
417434
}
@@ -422,8 +439,34 @@ message NonceGenResponse {
422439
}
423440
}
424441

425-
message OptimisticPayoutParams {
442+
message OptimisticWithdrawParams {
426443
WithdrawParams withdrawal = 1;
444+
// An ECDSA signature (of citrea/aggregator) over the withdrawal params
445+
// to authenticate the withdrawal params. This will be signed manually by citrea
446+
// after manual verification of the optimistic payout.
447+
optional string verification_signature = 2;
448+
}
449+
450+
message WithdrawParamsWithSig {
451+
WithdrawParams withdrawal = 1;
452+
// An ECDSA signature (of citrea/aggregator) over the withdrawal params
453+
// to authenticate the withdrawal params. This will be signed manually by citrea
454+
// after manual verification of the optimistic payout.
455+
// This message contains same data as the one in Optimistic Payout signature, but with a different message name,
456+
// so that the same signature can't be used for both optimistic payout and normal withdrawal.
457+
optional string verification_signature = 2;
458+
}
459+
460+
// Input of the aggregator's withdraw function.
461+
// It contains the withdrawal params along with the verification signature that signs the withdrawal params.
462+
// It also contains the operator's xonly public keys that the withdrawal request should be sent to. If the list is empty, the withdrawal will be sent to all operators.
463+
message AggregatorWithdrawalInput {
464+
WithdrawParamsWithSig withdrawal = 1;
465+
repeated XOnlyPublicKeyRpc operator_xonly_pks = 2;
466+
}
467+
468+
message OptimisticPayoutParams {
469+
OptimisticWithdrawParams opt_withdrawal = 1;
427470
NonceGenFirstResponse nonce_gen = 2;
428471
bytes agg_nonce = 3;
429472
}
@@ -473,7 +516,7 @@ message TxMetadata {
473516
// Optional outpoint of the deposit transaction
474517
Outpoint deposit_outpoint = 1;
475518
// Deposit identification
476-
XonlyPublicKey operator_xonly_pk = 2;
519+
XOnlyPublicKeyRpc operator_xonly_pk = 2;
477520
uint32 round_idx = 4;
478521
uint32 kickoff_idx = 5;
479522
// Transaction ID
@@ -616,9 +659,13 @@ message AggregatorWithdrawResponse {
616659
repeated string withdraw_responses = 1;
617660
}
618661

619-
message CreateEmergencyStopTxRequest {
662+
message GetEmergencyStopTxRequest {
663+
repeated Txid txids = 1;
664+
}
665+
666+
message GetEmergencyStopTxResponse {
620667
repeated Txid txids = 1;
621-
bool add_anchor = 2;
668+
repeated bytes encrypted_emergency_stop_txs = 2;
622669
}
623670

624671
message SendMoveTxRequest {
@@ -655,11 +702,13 @@ service ClementineAggregator {
655702

656703
// Call's withdraw on all operators
657704
// Used by the clementine-backend service to initiate a withdrawal
658-
rpc Withdraw(WithdrawParams)
705+
// If the operator's xonly public keys list is empty, the withdrawal will be sent to all operators.
706+
// If not, only the operators in the list will be sent the withdrawal request.
707+
rpc Withdraw(AggregatorWithdrawalInput)
659708
returns (AggregatorWithdrawResponse) {}
660709

661710
// Perform an optimistic payout to reimburse a peg-out from Citrea
662-
rpc OptimisticPayout(WithdrawParams) returns (RawSignedTx) {}
711+
rpc OptimisticPayout(OptimisticWithdrawParams) returns (RawSignedTx) {}
663712

664713
// Send a pre-signed tx to the network
665714
rpc InternalSendTx(SendTxRequest) returns (Empty) {}
@@ -673,7 +722,7 @@ service ClementineAggregator {
673722
// Creates an emergency stop tx that won't be broadcasted.
674723
// Tx will have around 3 sats/vbyte fee.
675724
// Set add_anchor to true to add an anchor output for cpfp..
676-
rpc InternalCreateEmergencyStopTx(CreateEmergencyStopTxRequest) returns (SignedTxWithType) {}
725+
rpc InternalGetEmergencyStopTx(GetEmergencyStopTxRequest) returns (GetEmergencyStopTxResponse) {}
677726

678727
rpc Vergen(Empty) returns (VergenResponse) {}
679-
}
728+
}

src/clementine/client.rs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ impl ClementineAggregatorTestClient {
8282
Ok(Self { client })
8383
}
8484

85+
pub fn inner_mut(&mut self) -> &mut ClementineAggregatorClient<Channel> {
86+
&mut self.client
87+
}
88+
8589
pub async fn new_deposit(&mut self, deposit: Deposit) -> Result<RawSignedTx> {
8690
let request = Request::new(deposit);
8791
let response = self
@@ -92,7 +96,10 @@ impl ClementineAggregatorTestClient {
9296
Ok(response.into_inner())
9397
}
9498

95-
pub async fn withdraw(&mut self, params: WithdrawParams) -> Result<AggregatorWithdrawResponse> {
99+
pub async fn withdraw(
100+
&mut self,
101+
params: AggregatorWithdrawalInput,
102+
) -> Result<AggregatorWithdrawResponse> {
96103
let request = Request::new(params);
97104
let response = self
98105
.client
@@ -102,7 +109,10 @@ impl ClementineAggregatorTestClient {
102109
Ok(response.into_inner())
103110
}
104111

105-
pub async fn optimistic_payout(&mut self, params: WithdrawParams) -> Result<RawSignedTx> {
112+
pub async fn optimistic_payout(
113+
&mut self,
114+
params: OptimisticWithdrawParams,
115+
) -> Result<RawSignedTx> {
106116
let request = Request::new(params);
107117
let response = self
108118
.client
@@ -155,6 +165,10 @@ impl ClementineOperatorTestClient {
155165
Ok(Self { client })
156166
}
157167

168+
pub fn inner_mut(&mut self) -> &mut ClementineOperatorClient<Channel> {
169+
&mut self.client
170+
}
171+
158172
pub async fn get_x_only_public_key(&mut self) -> Result<XOnlyPublicKeyRpc> {
159173
let request = Request::new(Empty {});
160174
let response = self
@@ -185,7 +199,7 @@ impl ClementineOperatorTestClient {
185199
Ok(response.into_inner())
186200
}
187201

188-
pub async fn withdraw(&mut self, params: WithdrawParams) -> Result<()> {
202+
pub async fn withdraw(&mut self, params: WithdrawParamsWithSig) -> Result<()> {
189203
let request = Request::new(params);
190204
self.client
191205
.withdraw(request)
@@ -216,6 +230,10 @@ impl ClementineVerifierTestClient {
216230
Ok(Self { client })
217231
}
218232

233+
pub fn inner_mut(&mut self) -> &mut ClementineVerifierClient<Channel> {
234+
&mut self.client
235+
}
236+
219237
pub async fn get_params(&mut self) -> Result<VerifierParams> {
220238
let request = Request::new(Empty {});
221239
let response = self

0 commit comments

Comments
 (0)