Skip to content

splice: Script for complex splices #6980

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
b5801fd
mac: build warning about unused result
ddustin Nov 11, 2024
3e30cc3
splice: Script for complex splices
ddustin Nov 11, 2024
d9dfb00
splice: A splice-script test that tests complex corner cases
ddustin Nov 11, 2024
87dea60
psbt: Add ability to extract signature
ddustin Nov 11, 2024
4814c53
psbt: Add ability to set global PSBT values
ddustin Nov 11, 2024
4953abd
psbt: Add ability to set channel_ids in psbt globals
ddustin Nov 11, 2024
981d070
splice: Modify splice_signed to work with multiple channels
ddustin Nov 11, 2024
bd2923b
psbt: comment typo fix
ddustin Nov 11, 2024
1479387
splice: Allow splice_update to return signatures
ddustin Nov 11, 2024
344de67
splice: Extract remote sig from psbt if needed
ddustin Nov 11, 2024
bed4f41
splice: Bulk channel `stfu` and `abort` RPC
ddustin Nov 11, 2024
49580ea
addpsbtinput: New RPC command to add funds to a psbt
ddustin Nov 11, 2024
4c9d099
addpsbtoutput: Add serial_id flag
ddustin Nov 11, 2024
5ebe8d0
splice: Add plugin for magic “splice all” command
ddustin Nov 11, 2024
f3c4331
splice: Documentation for the “splice” command
ddustin Nov 11, 2024
9bef7b0
peer_control: Don’t report removed inflights
ddustin Nov 11, 2024
24d5321
splice: Update splice fee maximums
ddustin Nov 11, 2024
bf09184
splice: Add test of “splice” script command
ddustin Nov 11, 2024
d7f84ab
splice: Abort on insufficent funds
ddustin Nov 11, 2024
07a4655
splice: Add more verbose reestablish debug logging
ddustin Nov 11, 2024
fd25a60
splice: reestablish should only assume stfu in one case
ddustin Nov 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .msggen.json
Original file line number Diff line number Diff line change
Expand Up @@ -3137,6 +3137,7 @@
},
"Splice_signedResponse": {
"Splice_Signed.outnum": 3,
"Splice_Signed.psbt": 4,
"Splice_Signed.tx": 1,
"Splice_Signed.txid": 2
},
Expand All @@ -3146,7 +3147,8 @@
},
"Splice_updateResponse": {
"Splice_Update.commitments_secured": 2,
"Splice_Update.psbt": 1
"Splice_Update.psbt": 1,
"Splice_Update.signatures_secured": 3
},
"StaticbackupResponse": {
"StaticBackup.scb[]": 1
Expand Down Expand Up @@ -10928,6 +10930,10 @@
"added": "pre-v0.10.1",
"deprecated": null
},
"Splice_Update.signatures_secured": {
"added": "v24.11",
"deprecated": null
},
"StaticBackup": {
"added": "pre-v0.10.1",
"deprecated": null
Expand Down
41 changes: 41 additions & 0 deletions bitcoin/psbt.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,36 @@ bool psbt_input_have_signature(const struct wally_psbt *psbt,
return ok;
}

bool psbt_input_get_ecdsa_sig(const tal_t *ctx,
const struct wally_psbt *psbt,
size_t in,
const struct pubkey *pubkey,
struct bitcoin_signature **sig)
{
u8 pk_der[PUBKEY_CMPR_LEN];
size_t index_plus_one;
struct wally_map_item *item;
bool ok;

assert(in < psbt->num_inputs);

pubkey_to_der(pk_der, pubkey);
*sig = NULL;

ok = wally_psbt_input_find_signature(&psbt->inputs[in], pk_der,
sizeof(pk_der),
&index_plus_one) == WALLY_OK;
if (ok) {
item = &psbt->inputs[in].signatures.items[index_plus_one - 1];
*sig = tal(ctx, struct bitcoin_signature);
if (!signature_from_der(item->value, item->value_len, *sig)) {
*sig = tal_free(*sig);
return false;
}
}
return ok;
}

void psbt_input_set_wit_utxo(struct wally_psbt *psbt, size_t in,
const u8 *scriptPubkey, struct amount_sat amt)
{
Expand Down Expand Up @@ -611,6 +641,17 @@ void *psbt_get_lightning(const struct wally_map *map,
return item->value;
}

void psbt_set_lightning(const tal_t *ctx,
struct wally_map *map,
const u8 proprietary_type,
const void *value,
size_t val_len)
{
u8 *key = psbt_make_key(NULL, proprietary_type, NULL);
map_replace(ctx, map, key, value, val_len);
tal_free(key);
}

void psbt_output_set_unknown(const tal_t *ctx,
struct wally_psbt_output *out,
const u8 *key,
Expand Down
23 changes: 22 additions & 1 deletion bitcoin/psbt.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,20 @@ WARN_UNUSED_RESULT bool psbt_input_set_signature(struct wally_psbt *psbt, size_t

/* 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. */
* Only signature presence is checked, it 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);

/* Returns false on error. On success *sig is set to the signature otherwise
* *sig is set to NULL. */
WARN_UNUSED_RESULT bool psbt_input_get_ecdsa_sig(const tal_t *ctx,
const struct wally_psbt *psbt,
size_t in,
const struct pubkey *pubkey,
struct bitcoin_signature **sig);

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 All @@ -212,6 +220,19 @@ void *psbt_get_lightning(const struct wally_map *map,
const u8 proprietary_type,
size_t *val_len);

/* psbt_set_lightning - Set a propreitary lightning value on the given map
*
* @map - map of unknowns to set the value
* @proprietary_type - type no. to set
* @value - the value to be set
* @val_len - length of value
*/
void psbt_set_lightning(const tal_t *ctx,
struct wally_map *map,
const u8 proprietary_type,
const void *value,
size_t val_len);

/* psbt_output_set_unknown - Set the given Key-Value in the psbt's output keymap
*
* @ctx - tal context for allocations
Expand Down
3 changes: 3 additions & 0 deletions bitcoin/test/run-psbt-from-tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ void sha256_double(struct sha256_double *shadouble UNNEEDED, const void *p UNNEE
/* Generated stub for signature_to_der */
size_t signature_to_der(u8 der[73] UNNEEDED, const struct bitcoin_signature *sig UNNEEDED)
{ fprintf(stderr, "signature_to_der called!\n"); abort(); }
/* Generated stub for signature_to_der */
bool signature_from_der(const u8 *der UNNEEDED, size_t len UNNEEDED, struct bitcoin_signature *sig UNNEEDED)
{ fprintf(stderr, "signature_from_der called!\n"); abort(); }
/* Generated stub for towire_sha256_double */
void towire_sha256_double(u8 **pptr UNNEEDED, const struct sha256_double *sha256d UNNEEDED)
{ fprintf(stderr, "towire_sha256_double called!\n"); abort(); }
Expand Down
2 changes: 1 addition & 1 deletion ccan/ccan/mem/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,6 @@ void memtaint(void *data, size_t len)
memcpy(p, tainter, len);

#if HAVE_VALGRIND_MEMCHECK_H
VALGRIND_MAKE_MEM_UNDEFINED(data, len);
(void)VALGRIND_MAKE_MEM_UNDEFINED(data, len);
#endif
}
2 changes: 1 addition & 1 deletion ccan/ccan/mem/mem.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ void memswap(void *a, void *b, size_t n);
#include <valgrind/memcheck.h>
static inline void *memcheck_(const void *data, size_t len)
{
VALGRIND_CHECK_MEM_IS_DEFINED(data, len);
(void)VALGRIND_CHECK_MEM_IS_DEFINED(data, len);
return (void *)data;
}
#else
Expand Down
Loading
Loading