Skip to content

Commit 8039cd6

Browse files
committed
Merge #17: listener: be less strict on duplicate Emergency signatures
550df3c listener: be less strict on duplicate Emergency signatures (Antoine Poinsot) Pull request description: This was neat, but in practice it's a pain. And i'd like to move to revault/practical-revault#109 ASAP anyways. ACKs for top commit: darosior: ACK 550df3c -- trivial and i need it for the revaultd integration :) Tree-SHA512: 1f1d4b2543aa48ef6405494c3959d3ce54137f7c7001267150f3dff5deac2a787b4501741d04262bdd2fe440b71b617293f0aa89776aa55e40b17a10cf235989
2 parents e887b05 + 550df3c commit 8039cd6

File tree

2 files changed

+13
-23
lines changed

2 files changed

+13
-23
lines changed

src/listener.rs

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,6 @@ fn process_sig_message<C: secp256k1::Verification>(
9898
let deposit_utxo = bitcoind
9999
.utxoinfo(&msg.deposit_outpoint)
100100
.ok_or(ListenerError::UnknownOutpoint(msg.deposit_outpoint))?;
101-
log::debug!(
102-
"Building tx chain with val {}, descriptors {} -- {} -- {} -- {}",
103-
deposit_utxo.value,
104-
scripts_config.deposit_descriptor,
105-
scripts_config.unvault_descriptor,
106-
scripts_config.cpfp_descriptor,
107-
&scripts_config.emergency_address
108-
);
109101
let (_, mut cancel_tx, mut emer_tx, mut unemer_tx) = transaction_chain(
110102
msg.deposit_outpoint,
111103
deposit_utxo.value,
@@ -119,10 +111,12 @@ fn process_sig_message<C: secp256k1::Verification>(
119111
)?;
120112

121113
if msg.txid == emer_tx.txid() {
122-
// Receiving the signatures of an Emergency tx means they just signed the revocation
123-
// transactions. The vault must not exist yet.
114+
// If we already have it, just acknowledge it.
124115
if db_vault(db_path, &msg.deposit_outpoint)?.is_some() {
125-
return Err(ListenerError::UnexpectedEmerSig(msg.deposit_outpoint));
116+
return Ok(SigResult {
117+
ack: true,
118+
txid: msg.txid,
119+
});
126120
}
127121

128122
// Check that the sig they gave us are valid, and enough to make the transaction valid.
@@ -675,7 +669,7 @@ mod tests {
675669
stakeholders.len()
676670
);
677671

678-
// We won't accept to process an Emergency for this vault anymore
672+
// We will re-ACK any Emergency for this vault
679673
let msg = Sig {
680674
signatures: BTreeMap::new(),
681675
txid: emer.txid(),
@@ -684,9 +678,8 @@ mod tests {
684678
};
685679
assert!(
686680
process_sig_message(&db_path, &scripts_config, &bitcoind, msg, &secp_ctx)
687-
.unwrap_err()
688-
.to_string()
689-
.contains("received an Emergency")
681+
.unwrap()
682+
.ack
690683
);
691684

692685
// We won't accept to process a Cancel just yet
@@ -830,7 +823,7 @@ mod tests {
830823
.contains("received an UnvaultEmergency")
831824
);
832825

833-
// We won't accept to process an Emergency either
826+
// We would still accept to process an Emergency, though
834827
let msg = Sig {
835828
signatures: BTreeMap::new(),
836829
txid: emer.txid(),
@@ -839,9 +832,8 @@ mod tests {
839832
};
840833
assert!(
841834
process_sig_message(&db_path, &scripts_config, &bitcoind, msg, &secp_ctx)
842-
.unwrap_err()
843-
.to_string()
844-
.contains("received an Emergency")
835+
.unwrap()
836+
.ack
845837
);
846838

847839
let sighash = cancel

tests/test_conn.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ def test_simple_client_server(miradord, bitcoind):
3636
txs["emer"]["sigs"], emer_txid, deposit_outpoint, DERIV_INDEX, noise_conn
3737
)
3838

39-
# It will refuse that we send it twice but will happily accept the other sigs
40-
assert not miradord.send_sigs(
41-
txs["emer"]["sigs"], emer_txid, deposit_outpoint, DERIV_INDEX, noise_conn
42-
)
39+
# And if we send the rest it'll start watching for this vault
4340
unemer_txid = bitcoind.rpc.decoderawtransaction(txs["unemer"]["tx"])["txid"]
4441
assert miradord.send_sigs(
4542
txs["unemer"]["sigs"], unemer_txid, deposit_outpoint, DERIV_INDEX, noise_conn
@@ -48,3 +45,4 @@ def test_simple_client_server(miradord, bitcoind):
4845
assert miradord.send_sigs(
4946
txs["cancel"]["sigs"], cancel_txid, deposit_outpoint, DERIV_INDEX, noise_conn
5047
)
48+
miradord.wait_for_log("Now watching for Unvault broadcast.")

0 commit comments

Comments
 (0)