Skip to content

Commit 553db0f

Browse files
committed
splice: Reestablish when commit or sig sends fail
Adds tests for when the connection fails during 1) splice tx_signature 2) splice commitment_signed Fleshed out the reestablish flow for these two cases and implemented the fixes to make these reestablish flows work. Part of this work required changing commit process for splices: Now we send a single commit_part for the splice where previously we sent all commits, and accordingly, we no longer revoke in response. Changelog-Fixed: Implemented splicing restart logic for tx_signature and commitment_signed. Splice commitments are reworked in a manner incompatible with the last version.
1 parent b135ba2 commit 553db0f

19 files changed

+800
-338
lines changed

bitcoin/psbt.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,27 @@ bool psbt_input_set_signature(struct wally_psbt *psbt, size_t in,
290290
return ok;
291291
}
292292

293+
bool psbt_input_have_signature(const struct wally_psbt *psbt,
294+
size_t in,
295+
const struct pubkey *pubkey,
296+
bool *signature_found)
297+
{
298+
u8 pk_der[PUBKEY_CMPR_LEN];
299+
size_t index_plus_one;
300+
bool ok;
301+
302+
assert(in < psbt->num_inputs);
303+
304+
pubkey_to_der(pk_der, pubkey);
305+
306+
ok = wally_psbt_input_find_signature(&psbt->inputs[in], pk_der,
307+
sizeof(pk_der),
308+
&index_plus_one) == WALLY_OK;
309+
if (ok)
310+
*signature_found = index_plus_one > 0;
311+
return ok;
312+
}
313+
293314
void psbt_input_set_wit_utxo(struct wally_psbt *psbt, size_t in,
294315
const u8 *scriptPubkey, struct amount_sat amt)
295316
{

bitcoin/psbt.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,14 @@ WARN_UNUSED_RESULT bool psbt_input_set_signature(struct wally_psbt *psbt, size_t
178178
const struct pubkey *pubkey,
179179
const struct bitcoin_signature *sig);
180180

181+
/* Returns false on error. On success, *signature_found is set to true if the
182+
* input has a signature present for `pubkey` and false if if one was not found.
183+
* Only ignature presence is checked, is not validated. */
184+
WARN_UNUSED_RESULT bool psbt_input_have_signature(const struct wally_psbt *psbt,
185+
size_t in,
186+
const struct pubkey *pubkey,
187+
bool *signature_found);
188+
181189
void psbt_input_set_witscript(struct wally_psbt *psbt, size_t in, const u8 *wscript);
182190

183191
/* psbt_input_set_unknown - Set the given Key-Value in the psbt's input keymap

0 commit comments

Comments
 (0)