Skip to content

Commit

Permalink
splice: Reestablish when commit or sig sends fail
Browse files Browse the repository at this point in the history
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.

Changelog-Fixed: Implemented splicing restart logic for tx_signature and commitment_signed.
  • Loading branch information
ddustin committed Nov 3, 2023
1 parent b135ba2 commit da8aa04
Show file tree
Hide file tree
Showing 16 changed files with 606 additions and 215 deletions.
21 changes: 21 additions & 0 deletions bitcoin/psbt.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,27 @@ bool psbt_input_set_signature(struct wally_psbt *psbt, size_t in,
return ok;
}

bool psbt_input_have_signature(const struct wally_psbt *psbt,
size_t in,
const struct pubkey *pubkey,
bool *signature_found)
{
u8 pk_der[PUBKEY_CMPR_LEN];
size_t index_plus_one;
bool ok;

assert(in < psbt->num_inputs);

pubkey_to_der(pk_der, pubkey);

ok = wally_psbt_input_find_signature(&psbt->inputs[in], pk_der,
sizeof(pk_der),
&index_plus_one) == WALLY_OK;
if (ok)
*signature_found = index_plus_one > 0;
return ok;
}

void psbt_input_set_wit_utxo(struct wally_psbt *psbt, size_t in,
const u8 *scriptPubkey, struct amount_sat amt)
{
Expand Down
8 changes: 8 additions & 0 deletions bitcoin/psbt.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,14 @@ WARN_UNUSED_RESULT bool psbt_input_set_signature(struct wally_psbt *psbt, size_t
const struct pubkey *pubkey,
const struct bitcoin_signature *sig);

/* Returns false on error. On success, *signature_found is set to true if the
* input has a signature present for `pubkey` and false if if one was not found.
* Only ignature presence is checked, is not validated. */
WARN_UNUSED_RESULT bool psbt_input_have_signature(const struct wally_psbt *psbt,
size_t in,
const struct pubkey *pubkey,
bool *signature_found);

void psbt_input_set_witscript(struct wally_psbt *psbt, size_t in, const u8 *wscript);

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

0 comments on commit da8aa04

Please sign in to comment.