onchaind: remove 'is_replay' logic

we used this originally to suppress duplicate issuance of coin-move
events; we're assuming that any plugin expects duplicate events though
(and knows how to de-dupe them), so we no longer need this logic.
This commit is contained in:
niftynei
2021-12-01 10:24:31 -06:00
committed by Rusty Russell
parent 27ff87c045
commit 8098a4cd21
10 changed files with 87 additions and 151 deletions

View File

@@ -52,21 +52,7 @@ static void onchaind_tell_fulfill(struct channel *channel)
if (!hin->preimage)
continue;
/* Sooo these are *probably* replays since they're coming
* from the database but it's hard to be sure since we update
* the database before notifying onchaind about them.
* There's a *very* rare chance that we'll not log them,
* only in that we only make ledger records as a result of this call
* iff the output isn't deemed 'trackable'. So if we do miss a
* ledger record as a result of this decision, it's guaranteed to be
* impreceptibly tiny *and* not show up anywhere else in the node's
* utxo set.
*
* Aka a reconciliator's nightmare.
* The alternative is to double-count *every* ignored htlc output
* It's easier to delete than find a missing, but I'm banking on
* the rarity of failure here. (hahaha) */
msg = towire_onchaind_known_preimage(channel, hin->preimage, false);
msg = towire_onchaind_known_preimage(channel, hin->preimage);
subd_send_msg(channel->owner, take(msg));
}
}
@@ -152,11 +138,10 @@ static void handle_onchain_init_reply(struct channel *channel, const u8 *msg)
*/
static void onchain_tx_depth(struct channel *channel,
const struct bitcoin_txid *txid,
unsigned int depth,
bool is_replay)
unsigned int depth)
{
u8 *msg;
msg = towire_onchaind_depth(channel, txid, depth, is_replay);
msg = towire_onchaind_depth(channel, txid, depth);
subd_send_msg(channel->owner, take(msg));
}
@@ -199,7 +184,7 @@ static enum watch_result onchain_tx_watched(struct lightningd *ld,
wallet_channeltxs_add(ld->wallet, channel,
WIRE_ONCHAIND_DEPTH, txid, 0, blockheight);
onchain_tx_depth(channel, txid, depth, false);
onchain_tx_depth(channel, txid, depth);
return KEEP_WATCHING;
}
@@ -209,7 +194,7 @@ static void watch_tx_and_outputs(struct channel *channel,
/**
* Notify onchaind that an output was spent and register new watches.
*/
static void onchain_txo_spent(struct channel *channel, const struct bitcoin_tx *tx, size_t input_num, u32 blockheight, bool is_replay)
static void onchain_txo_spent(struct channel *channel, const struct bitcoin_tx *tx, size_t input_num, u32 blockheight)
{
u8 *msg;
/* Onchaind needs all inputs, since it uses those to compare
@@ -219,7 +204,7 @@ static void onchain_txo_spent(struct channel *channel, const struct bitcoin_tx *
watch_tx_and_outputs(channel, tx);
msg = towire_onchaind_spent(channel, parts, input_num, blockheight, is_replay);
msg = towire_onchaind_spent(channel, parts, input_num, blockheight);
subd_send_msg(channel->owner, take(msg));
}
@@ -240,7 +225,7 @@ static enum watch_result onchain_txo_watched(struct channel *channel,
WIRE_ONCHAIND_SPENT, &txid, input_num,
block->height);
onchain_txo_spent(channel, tx, input_num, block->height, false);
onchain_txo_spent(channel, tx, input_num, block->height);
/* We don't need to keep watching: If this output is double-spent
* (reorg), we'll get a zero depth cb to onchain_tx_watched, and
@@ -590,8 +575,7 @@ static void onchain_error(struct channel *channel,
* onchaind (like any other owner), and restart */
enum watch_result onchaind_funding_spent(struct channel *channel,
const struct bitcoin_tx *tx,
u32 blockheight,
bool is_replay)
u32 blockheight)
{
u8 *msg;
struct bitcoin_txid our_last_txid;
@@ -727,7 +711,6 @@ enum watch_result onchaind_funding_spent(struct channel *channel,
channel->static_remotekey_start[LOCAL],
channel->static_remotekey_start[REMOTE],
channel_has(channel, OPT_ANCHOR_OUTPUTS),
is_replay,
feerate_min(ld, NULL));
subd_send_msg(channel->owner, take(msg));
@@ -757,18 +740,16 @@ void onchaind_replay_channels(struct lightningd *ld)
for (size_t j = 0; j < tal_count(txs); j++) {
if (txs[j].type == WIRE_ONCHAIND_INIT) {
onchaind_funding_spent(chan, txs[j].tx,
txs[j].blockheight,
true);
txs[j].blockheight);
} else if (txs[j].type == WIRE_ONCHAIND_SPENT) {
onchain_txo_spent(chan, txs[j].tx,
txs[j].input_num,
txs[j].blockheight,
true);
txs[j].blockheight);
} else if (txs[j].type == WIRE_ONCHAIND_DEPTH) {
onchain_tx_depth(chan, &txs[j].txid,
txs[j].depth, true);
txs[j].depth);
} else {
fatal("unknown message of type %d during "

View File

@@ -9,8 +9,7 @@ struct block;
enum watch_result onchaind_funding_spent(struct channel *channel,
const struct bitcoin_tx *tx,
u32 blockheight,
bool is_replay);
u32 blockheight);
void onchaind_replay_channels(struct lightningd *ld);

View File

@@ -1365,7 +1365,7 @@ static enum watch_result funding_spent(struct channel *channel,
wallet_channeltxs_add(channel->peer->ld->wallet, channel,
WIRE_ONCHAIND_INIT, &txid, 0, block->height);
return onchaind_funding_spent(channel, tx, block->height, false);
return onchaind_funding_spent(channel, tx, block->height);
}
void channel_watch_wrong_funding(struct lightningd *ld, struct channel *channel)

View File

@@ -431,7 +431,7 @@ void fulfill_htlc(struct htlc_in *hin, const struct preimage *preimage)
}
if (channel_on_chain(channel)) {
msg = towire_onchaind_known_preimage(hin, preimage, false);
msg = towire_onchaind_known_preimage(hin, preimage);
} else {
struct fulfilled_htlc fulfilled_htlc;
fulfilled_htlc.id = hin->key.id;

View File

@@ -476,8 +476,7 @@ void notify_invoice_payment(struct lightningd *ld UNNEEDED, struct amount_msat a
/* Generated stub for onchaind_funding_spent */
enum watch_result onchaind_funding_spent(struct channel *channel UNNEEDED,
const struct bitcoin_tx *tx UNNEEDED,
u32 blockheight UNNEEDED,
bool is_replay UNNEEDED)
u32 blockheight UNNEEDED)
{ fprintf(stderr, "onchaind_funding_spent called!\n"); abort(); }
/* Generated stub for param */
bool param(struct command *cmd UNNEEDED, const char *buffer UNNEEDED,

View File

@@ -1014,7 +1014,7 @@ static bool proposal_is_rbfable(const struct proposed_resolution *proposal)
* @desc precondition: the given output must have an
* rbfable proposal as per `proposal_is_rbfable`.
*/
static void proposal_should_rbf(struct tracked_output *out, bool is_replay)
static void proposal_should_rbf(struct tracked_output *out)
{
struct bitcoin_tx *tx = NULL;
u32 depth;
@@ -1095,7 +1095,7 @@ static void proposal_should_rbf(struct tracked_output *out, bool is_replay)
}
}
static void proposal_meets_depth(struct tracked_output *out, bool is_replay)
static void proposal_meets_depth(struct tracked_output *out)
{
bool is_rbf = false;
@@ -1139,8 +1139,7 @@ static void proposal_meets_depth(struct tracked_output *out, bool is_replay)
static void propose_resolution(struct tracked_output *out,
const struct bitcoin_tx *tx,
unsigned int depth_required,
enum tx_type tx_type,
bool is_replay)
enum tx_type tx_type)
{
status_debug("Propose handling %s/%s by %s (%s) after %u blocks",
tx_type_name(out->tx_type),
@@ -1155,14 +1154,13 @@ static void propose_resolution(struct tracked_output *out,
out->proposal->tx_type = tx_type;
if (depth_required == 0)
proposal_meets_depth(out, is_replay);
proposal_meets_depth(out);
}
static void propose_resolution_at_block(struct tracked_output *out,
const struct bitcoin_tx *tx,
unsigned int block_required,
enum tx_type tx_type,
bool is_replay)
enum tx_type tx_type)
{
u32 depth;
@@ -1171,7 +1169,7 @@ static void propose_resolution_at_block(struct tracked_output *out,
depth = 0;
else /* Note that out->tx_blockheight is already at depth 1 */
depth = block_required - out->tx_blockheight + 1;
propose_resolution(out, tx, depth, tx_type, is_replay);
propose_resolution(out, tx, depth, tx_type);
}
static bool is_valid_sig(const u8 *e)
@@ -1541,8 +1539,7 @@ static void resolve_htlc_tx(struct tracked_output ***outs,
size_t out_index,
const struct tx_parts *htlc_tx,
size_t input_num,
u32 tx_blockheight,
bool is_replay)
u32 tx_blockheight)
{
struct tracked_output *out;
struct bitcoin_tx *tx;
@@ -1591,8 +1588,7 @@ static void resolve_htlc_tx(struct tracked_output ***outs,
tx = tx_to_us(*outs, delayed_payment_to_us, out, to_self_delay[LOCAL],
0, NULL, 0, wscript, &tx_type, htlc_feerate);
propose_resolution(out, tx, to_self_delay[LOCAL], tx_type,
is_replay);
propose_resolution(out, tx, to_self_delay[LOCAL], tx_type);
}
/* BOLT #5:
@@ -1607,8 +1603,7 @@ static void steal_htlc_tx(struct tracked_output *out,
const struct tx_parts *htlc_tx,
u32 htlc_tx_blockheight,
enum tx_type htlc_tx_type,
const struct bitcoin_outpoint *htlc_outpoint,
bool is_replay)
const struct bitcoin_outpoint *htlc_outpoint)
{
struct bitcoin_tx *tx;
enum tx_type tx_type = OUR_PENALTY_TX;
@@ -1645,7 +1640,7 @@ static void steal_htlc_tx(struct tracked_output *out,
resolved_by_other(out, &htlc_tx->txid, htlc_tx_type);
/* annnd done! */
propose_resolution(htlc_out, tx, 0, tx_type, is_replay);
propose_resolution(htlc_out, tx, 0, tx_type);
}
static void onchain_annotate_txout(const struct bitcoin_outpoint *outpoint,
@@ -1666,8 +1661,7 @@ static void onchain_annotate_txin(const struct bitcoin_txid *txid, u32 innum,
static void output_spent(struct tracked_output ***outs,
const struct tx_parts *tx_parts,
u32 input_num,
u32 tx_blockheight,
bool is_replay)
u32 tx_blockheight)
{
for (size_t i = 0; i < tal_count(*outs); i++) {
struct tracked_output *out = (*outs)[i];
@@ -1686,7 +1680,7 @@ static void output_spent(struct tracked_output ***outs,
if (out->resolved->tx_type == OUR_HTLC_SUCCESS_TX
|| out->resolved->tx_type == OUR_HTLC_TIMEOUT_TX)
resolve_htlc_tx(outs, i, tx_parts, input_num,
tx_blockheight, is_replay);
tx_blockheight);
record_coin_movements(out, tx_blockheight,
out->proposal->tx,
@@ -1715,8 +1709,7 @@ static void output_spent(struct tracked_output ***outs,
steal_htlc_tx(out, outs, tx_parts,
tx_blockheight,
THEIR_HTLC_TIMEOUT_TO_THEM,
&htlc_outpoint,
is_replay);
&htlc_outpoint);
} else {
/* We ignore this timeout tx, since we should
* resolve by ignoring once we reach depth. */
@@ -1752,8 +1745,7 @@ static void output_spent(struct tracked_output ***outs,
steal_htlc_tx(out, outs, tx_parts,
tx_blockheight,
OUR_HTLC_FULFILL_TO_THEM,
&htlc_outpoint,
is_replay);
&htlc_outpoint);
} else {
/* BOLT #5:
*
@@ -1847,8 +1839,7 @@ static void update_resolution_depth(struct tracked_output *out, u32 depth)
}
static void tx_new_depth(struct tracked_output **outs,
const struct bitcoin_txid *txid, u32 depth,
bool is_replay)
const struct bitcoin_txid *txid, u32 depth)
{
size_t i;
@@ -1882,7 +1873,7 @@ static void tx_new_depth(struct tracked_output **outs,
if (outs[i]->proposal
&& bitcoin_txid_eq(&outs[i]->outpoint.txid, txid)
&& depth >= outs[i]->proposal->depth_required) {
proposal_meets_depth(outs[i], is_replay);
proposal_meets_depth(outs[i]);
}
/* Otherwise, is this an output whose proposed resolution
@@ -1890,7 +1881,7 @@ static void tx_new_depth(struct tracked_output **outs,
if (outs[i]->proposal
&& bitcoin_txid_eq(&outs[i]->outpoint.txid, txid)
&& proposal_is_rbfable(outs[i]->proposal))
proposal_should_rbf(outs[i], is_replay);
proposal_should_rbf(outs[i]);
}
}
@@ -1921,8 +1912,7 @@ static void tx_new_depth(struct tracked_output **outs,
*/
/* Master makes sure we only get told preimages once other node is committed. */
static void handle_preimage(struct tracked_output **outs,
const struct preimage *preimage,
bool is_replay)
const struct preimage *preimage)
{
size_t i;
struct sha256 sha;
@@ -1992,8 +1982,7 @@ static void handle_preimage(struct tracked_output **outs,
tx, &sig, outs[i]->remote_htlc_sig, preimage,
outs[i]->wscript);
bitcoin_tx_input_set_witness(tx, 0, take(witness));
propose_resolution(outs[i], tx, 0, OUR_HTLC_SUCCESS_TX,
is_replay);
propose_resolution(outs[i], tx, 0, OUR_HTLC_SUCCESS_TX);
} else {
enum tx_type tx_type = THEIR_HTLC_FULFILL_TO_US;
@@ -2015,8 +2004,7 @@ static void handle_preimage(struct tracked_output **outs,
0, preimage, sizeof(*preimage),
outs[i]->wscript, &tx_type,
htlc_feerate);
propose_resolution(outs[i], tx, 0, tx_type,
is_replay);
propose_resolution(outs[i], tx, 0, tx_type);
}
}
@@ -2080,7 +2068,6 @@ static void wait_for_resolved(struct tracked_output **outs)
struct bitcoin_txid txid;
u32 input_num, depth, tx_blockheight;
struct preimage preimage;
bool is_replay;
struct tx_parts *tx_parts;
if (tal_count(queued_msgs)) {
@@ -2092,13 +2079,13 @@ static void wait_for_resolved(struct tracked_output **outs)
status_debug("Got new message %s",
onchaind_wire_name(fromwire_peektype(msg)));
if (fromwire_onchaind_depth(msg, &txid, &depth, &is_replay))
tx_new_depth(outs, &txid, depth, is_replay);
if (fromwire_onchaind_depth(msg, &txid, &depth))
tx_new_depth(outs, &txid, depth);
else if (fromwire_onchaind_spent(msg, msg, &tx_parts, &input_num,
&tx_blockheight, &is_replay)) {
output_spent(&outs, tx_parts, input_num, tx_blockheight, is_replay);
} else if (fromwire_onchaind_known_preimage(msg, &preimage, &is_replay))
handle_preimage(outs, &preimage, is_replay);
&tx_blockheight)) {
output_spent(&outs, tx_parts, input_num, tx_blockheight);
} else if (fromwire_onchaind_known_preimage(msg, &preimage))
handle_preimage(outs, &preimage);
else if (!handle_dev_memleak(outs, msg))
master_badmsg(-1, msg);
@@ -2221,8 +2208,7 @@ static u8 **derive_htlc_scripts(const struct htlc_stub *htlcs, enum side side)
static size_t resolve_our_htlc_ourcommit(struct tracked_output *out,
const size_t *matches,
const struct htlc_stub *htlcs,
u8 **htlc_scripts,
bool is_replay)
u8 **htlc_scripts)
{
struct bitcoin_tx *tx = NULL;
struct bitcoin_signature localsig;
@@ -2311,7 +2297,7 @@ static size_t resolve_our_htlc_ourcommit(struct tracked_output *out,
/* Steals tx onto out */
propose_resolution_at_block(out, tx, htlcs[matches[i]].cltv_expiry,
OUR_HTLC_TIMEOUT_TX, is_replay);
OUR_HTLC_TIMEOUT_TX);
return matches[i];
}
@@ -2333,8 +2319,7 @@ static u32 matches_cltv(const size_t *matches,
static size_t resolve_our_htlc_theircommit(struct tracked_output *out,
const size_t *matches,
const struct htlc_stub *htlcs,
u8 **htlc_scripts,
bool is_replay)
u8 **htlc_scripts)
{
struct bitcoin_tx *tx;
enum tx_type tx_type = OUR_HTLC_TIMEOUT_TO_US;
@@ -2355,7 +2340,7 @@ static size_t resolve_our_htlc_theircommit(struct tracked_output *out,
cltv_expiry, NULL, 0,
htlc_scripts[matches[0]], &tx_type, htlc_feerate);
propose_resolution_at_block(out, tx, cltv_expiry, tx_type, is_replay);
propose_resolution_at_block(out, tx, cltv_expiry, tx_type);
/* They're all equivalent: might as well use first one. */
return matches[0];
@@ -2365,8 +2350,7 @@ static size_t resolve_our_htlc_theircommit(struct tracked_output *out,
static size_t resolve_their_htlc(struct tracked_output *out,
const size_t *matches,
const struct htlc_stub *htlcs,
u8 **htlc_scripts,
bool is_replay)
u8 **htlc_scripts)
{
size_t which_htlc;
@@ -2403,7 +2387,7 @@ static size_t resolve_their_htlc(struct tracked_output *out,
/* If we hit timeout depth, resolve by ignoring. */
propose_resolution_at_block(out, NULL, htlcs[which_htlc].cltv_expiry,
THEIR_HTLC_TIMEOUT_TO_THEM, is_replay);
THEIR_HTLC_TIMEOUT_TO_THEM);
return which_htlc;
}
@@ -2513,8 +2497,7 @@ static void our_unilateral_to_us(struct tracked_output ***outs,
struct amount_sat amt,
u16 sequence,
const u8 *local_scriptpubkey,
const u8 *local_wscript,
bool is_replay)
const u8 *local_wscript)
{
struct bitcoin_tx *to_us;
struct tracked_output *out;
@@ -2556,7 +2539,7 @@ static void our_unilateral_to_us(struct tracked_output ***outs,
* Note: if the output is spent (as recommended), the
* output is *resolved* by the spending transaction
*/
propose_resolution(out, to_us, sequence, tx_type, is_replay);
propose_resolution(out, to_us, sequence, tx_type);
}
static void handle_our_unilateral(const struct tx_parts *tx,
@@ -2564,8 +2547,7 @@ static void handle_our_unilateral(const struct tx_parts *tx,
const struct basepoints basepoints[NUM_SIDES],
const enum side opener,
const struct bitcoin_signature *remote_htlc_sigs,
struct tracked_output **outs,
bool is_replay)
struct tracked_output **outs)
{
u8 **htlc_scripts;
u8 *local_wscript, *script[NUM_SIDES], *anchor[NUM_SIDES];
@@ -2682,7 +2664,7 @@ static void handle_our_unilateral(const struct tx_parts *tx,
our_unilateral_to_us(&outs, &outpoint, tx_blockheight,
amt, to_self_delay[LOCAL],
script[LOCAL],
local_wscript, is_replay);
local_wscript);
script[LOCAL] = NULL;
continue;
@@ -2769,8 +2751,7 @@ static void handle_our_unilateral(const struct tx_parts *tx,
amt,
max_unsigned(to_self_delay[LOCAL], csv),
script[LOCAL],
local_wscript,
is_replay);
local_wscript);
script[LOCAL] = NULL;
found = true;
@@ -2846,8 +2827,7 @@ static void handle_our_unilateral(const struct tx_parts *tx,
/* Tells us which htlc to use */
which_htlc = resolve_our_htlc_ourcommit(out, matches,
htlcs_info->htlcs,
htlc_scripts,
is_replay);
htlc_scripts);
} else {
out = new_tracked_output(&outs, &outpoint,
tx_blockheight,
@@ -2865,8 +2845,7 @@ static void handle_our_unilateral(const struct tx_parts *tx,
/* Tells us which htlc to use */
which_htlc = resolve_their_htlc(out, matches,
htlcs_info->htlcs,
htlc_scripts,
is_replay);
htlc_scripts);
}
out->htlc = htlcs_info->htlcs[which_htlc];
out->wscript = tal_steal(out, htlc_scripts[which_htlc]);
@@ -2887,8 +2866,7 @@ static void handle_our_unilateral(const struct tx_parts *tx,
/* We produce individual penalty txs. It's less efficient, but avoids them
* using HTLC txs to block our penalties for long enough to pass the CSV
* delay */
static void steal_to_them_output(struct tracked_output *out,
u32 csv, bool is_replay)
static void steal_to_them_output(struct tracked_output *out, u32 csv)
{
u8 *wscript;
struct bitcoin_tx *tx;
@@ -2908,10 +2886,10 @@ static void steal_to_them_output(struct tracked_output *out,
tx = tx_to_us(tmpctx, penalty_to_us, out, BITCOIN_TX_RBF_SEQUENCE, 0,
&ONE, sizeof(ONE), wscript, &tx_type, penalty_feerate);
propose_resolution(out, tx, 0, tx_type, is_replay);
propose_resolution(out, tx, 0, tx_type);
}
static void steal_htlc(struct tracked_output *out, bool is_replay)
static void steal_htlc(struct tracked_output *out)
{
struct bitcoin_tx *tx;
enum tx_type tx_type = OUR_PENALTY_TX;
@@ -2929,7 +2907,7 @@ static void steal_htlc(struct tracked_output *out, bool is_replay)
der, sizeof(der), out->wscript, &tx_type,
penalty_feerate);
propose_resolution(out, tx, 0, tx_type, is_replay);
propose_resolution(out, tx, 0, tx_type);
}
/* Tell wallet that we have discovered a UTXO from a to-remote output,
@@ -2969,7 +2947,6 @@ static void their_unilateral_local(struct tracked_output ***outs,
struct amount_sat amt,
const u8 *local_scriptpubkey,
enum tx_type tx_type,
bool is_replay,
u32 csv_lock)
{
struct tracked_output *out;
@@ -3012,8 +2989,7 @@ static void handle_their_cheat(const struct tx_parts *tx,
const struct secret *revocation_preimage,
const struct basepoints basepoints[NUM_SIDES],
const enum side opener,
struct tracked_output **outs,
bool is_replay)
struct tracked_output **outs)
{
u8 **htlc_scripts;
u8 *remote_wscript, *script[NUM_SIDES], *anchor[NUM_SIDES];
@@ -3171,8 +3147,7 @@ static void handle_their_cheat(const struct tx_parts *tx,
their_unilateral_local(&outs, tx, &outpoint,
tx_blockheight,
amt, script[LOCAL],
THEIR_REVOKED_UNILATERAL,
is_replay, 1);
THEIR_REVOKED_UNILATERAL, 1);
script[LOCAL] = NULL;
continue;
}
@@ -3190,7 +3165,7 @@ static void handle_their_cheat(const struct tx_parts *tx,
amt,
DELAYED_CHEAT_OUTPUT_TO_THEM,
NULL, NULL, NULL);
steal_to_them_output(out, 1, is_replay);
steal_to_them_output(out, 1);
script[REMOTE] = NULL;
continue;
}
@@ -3249,7 +3224,6 @@ static void handle_their_cheat(const struct tx_parts *tx,
amt,
script[LOCAL],
THEIR_REVOKED_UNILATERAL,
is_replay,
csv);
script[LOCAL] = NULL;
found = true;
@@ -3280,8 +3254,7 @@ static void handle_their_cheat(const struct tx_parts *tx,
amt,
DELAYED_CHEAT_OUTPUT_TO_THEM,
NULL, NULL, NULL);
steal_to_them_output(out, csv,
is_replay);
steal_to_them_output(out, csv);
script[REMOTE] = NULL;
found = true;
break;
@@ -3318,7 +3291,7 @@ static void handle_their_cheat(const struct tx_parts *tx,
&htlcs_info->htlcs[which_htlc],
htlc_scripts[which_htlc],
NULL);
steal_htlc(out, is_replay);
steal_htlc(out);
} else {
out = new_tracked_output(&outs, &outpoint,
tx_blockheight,
@@ -3335,7 +3308,7 @@ static void handle_their_cheat(const struct tx_parts *tx,
* * spend the *commitment tx* using the payment preimage (if known).
* * spend the *HTLC-timeout tx*, if the remote node has published it.
*/
steal_htlc(out, is_replay);
steal_htlc(out);
}
htlc_scripts[which_htlc] = NULL;
}
@@ -3351,8 +3324,7 @@ static void handle_their_unilateral(const struct tx_parts *tx,
const struct pubkey *this_remote_per_commitment_point,
const struct basepoints basepoints[NUM_SIDES],
const enum side opener,
struct tracked_output **outs,
bool is_replay)
struct tracked_output **outs)
{
u8 **htlc_scripts;
u8 *remote_wscript, *script[NUM_SIDES], *anchor[NUM_SIDES];
@@ -3496,8 +3468,7 @@ static void handle_their_unilateral(const struct tx_parts *tx,
their_unilateral_local(&outs, tx, &outpoint,
tx_blockheight,
amt, script[LOCAL],
THEIR_UNILATERAL,
is_replay, 1);
THEIR_UNILATERAL, 1);
script[LOCAL] = NULL;
continue;
@@ -3581,7 +3552,7 @@ static void handle_their_unilateral(const struct tx_parts *tx,
amt,
script[LOCAL],
THEIR_UNILATERAL,
is_replay, csv);
csv);
script[LOCAL] = NULL;
found = true;
break;
@@ -3649,8 +3620,7 @@ static void handle_their_unilateral(const struct tx_parts *tx,
which_htlc = resolve_our_htlc_theircommit(out,
matches,
htlcs_info->htlcs,
htlc_scripts,
is_replay);
htlc_scripts);
} else {
out = new_tracked_output(&outs, &outpoint,
tx_blockheight,
@@ -3667,7 +3637,7 @@ static void handle_their_unilateral(const struct tx_parts *tx,
*/
which_htlc = resolve_their_htlc(out, matches,
htlcs_info->htlcs,
htlc_scripts, is_replay);
htlc_scripts);
}
out->htlc = htlcs_info->htlcs[which_htlc];
out->wscript = tal_steal(out, htlc_scripts[which_htlc]);
@@ -3684,8 +3654,7 @@ static void handle_unknown_commitment(const struct tx_parts *tx,
u32 tx_blockheight,
const struct pubkey *possible_remote_per_commitment_point,
const struct basepoints basepoints[NUM_SIDES],
struct tracked_output **outs,
bool is_replay)
struct tracked_output **outs)
{
int to_us_output = -1;
/* We have two possible local scripts, depending on options */
@@ -3829,7 +3798,6 @@ int main(int argc, char *argv[])
u8 *scriptpubkey[NUM_SIDES];
u32 locktime, tx_blockheight;
struct pubkey *possible_remote_per_commitment_point;
bool open_is_replay;
subdaemon_setup(argc, argv);
@@ -3872,7 +3840,6 @@ int main(int argc, char *argv[])
&static_remotekey_start[LOCAL],
&static_remotekey_start[REMOTE],
&option_anchor_outputs,
&open_is_replay,
&min_relay_feerate)) {
master_badmsg(WIRE_ONCHAIND_INIT, msg);
}
@@ -3941,8 +3908,7 @@ int main(int argc, char *argv[])
basepoints,
opener,
remote_htlc_sigs,
outs,
open_is_replay);
outs);
/* BOLT #5:
*
* 3. The ugly way (*revoked transaction close*): one of the
@@ -3957,8 +3923,7 @@ int main(int argc, char *argv[])
&revocation_preimage,
basepoints,
opener,
outs,
open_is_replay);
outs);
/* BOLT #5:
*
* There may be more than one valid, *unrevoked* commitment
@@ -3974,22 +3939,19 @@ int main(int argc, char *argv[])
&old_remote_per_commit_point,
basepoints,
opener,
outs,
open_is_replay);
outs);
} else if (commit_num == revocations_received(&shachain) + 1) {
status_debug("Their unilateral tx, new commit point");
handle_their_unilateral(tx, tx_blockheight,
&remote_per_commit_point,
basepoints,
opener,
outs,
open_is_replay);
outs);
} else {
handle_unknown_commitment(tx, tx_blockheight,
possible_remote_per_commitment_point,
basepoints,
outs,
open_is_replay);
outs);
}
}

View File

@@ -48,7 +48,6 @@ msgdata,onchaind_init,remote_funding_pubkey,pubkey,
msgdata,onchaind_init,local_static_remotekey_start,u64,
msgdata,onchaind_init,remote_static_remotekey_start,u64,
msgdata,onchaind_init,option_anchor_outputs,bool,
msgdata,onchaind_init,is_replay,bool,
# We need this for BIP125 rule 4
msgdata,onchaind_init,min_relay_feerate,u32,
@@ -78,13 +77,11 @@ msgtype,onchaind_spent,5004
msgdata,onchaind_spent,tx,tx_parts,
msgdata,onchaind_spent,input_num,u32,
msgdata,onchaind_spent,blockheight,u32,
msgdata,onchaind_spent,is_replay,bool,
# master->onchaind: We will receive more than one of these, as depth changes.
msgtype,onchaind_depth,5005
msgdata,onchaind_depth,txid,bitcoin_txid,
msgdata,onchaind_depth,depth,u32,
msgdata,onchaind_depth,is_replay,bool,
# onchaind->master: We don't want to watch this tx, or its outputs
msgtype,onchaind_unwatch_tx,5006
@@ -93,7 +90,6 @@ msgdata,onchaind_unwatch_tx,txid,bitcoin_txid,
# master->onchaind: We know HTLC preimage
msgtype,onchaind_known_preimage,5007
msgdata,onchaind_known_preimage,preimage,preimage,
msgdata,onchaind_known_preimage,is_replay,bool,
# onchaind->master: We discovered HTLC preimage
msgtype,onchaind_extracted_preimage,5008
1 #include <bitcoin/tx_parts.h>
48 msgdata,onchaind_init,remote_static_remotekey_start,u64,
49 msgdata,onchaind_init,option_anchor_outputs,bool,
50 msgdata,onchaind_init,is_replay,bool, # We need this for BIP125 rule 4
# We need this for BIP125 rule 4
51 msgdata,onchaind_init,min_relay_feerate,u32,
52 # This says we're ready; give us htlcs and preimages.
53 msgtype,onchaind_init_reply,5101
77 msgtype,onchaind_depth,5005 msgdata,onchaind_depth,txid,bitcoin_txid,
78 msgdata,onchaind_depth,txid,bitcoin_txid, msgdata,onchaind_depth,depth,u32,
79 msgdata,onchaind_depth,depth,u32, # onchaind->master: We don't want to watch this tx, or its outputs
msgdata,onchaind_depth,is_replay,bool,
80 # onchaind->master: We don't want to watch this tx, or its outputs msgtype,onchaind_unwatch_tx,5006
81 msgtype,onchaind_unwatch_tx,5006 msgdata,onchaind_unwatch_tx,txid,bitcoin_txid,
82 msgdata,onchaind_unwatch_tx,txid,bitcoin_txid, # master->onchaind: We know HTLC preimage
83 # master->onchaind: We know HTLC preimage msgtype,onchaind_known_preimage,5007
84 msgtype,onchaind_known_preimage,5007 msgdata,onchaind_known_preimage,preimage,preimage,
msgdata,onchaind_known_preimage,preimage,preimage,
85 msgdata,onchaind_known_preimage,is_replay,bool, # onchaind->master: We discovered HTLC preimage
86 # onchaind->master: We discovered HTLC preimage msgtype,onchaind_extracted_preimage,5008
87 msgtype,onchaind_extracted_preimage,5008 msgdata,onchaind_extracted_preimage,preimage,preimage,
90 msgtype,onchaind_missing_htlc_output,5009 msgdata,onchaind_missing_htlc_output,htlc,htlc_stub,
91 msgdata,onchaind_missing_htlc_output,htlc,htlc_stub, # onchaind->master: this HTLC has timed out (after reasonable_depth)
92 # onchaind->master: this HTLC has timed out (after reasonable_depth) msgtype,onchaind_htlc_timeout,5010
msgtype,onchaind_htlc_timeout,5010
93 msgdata,onchaind_htlc_timeout,htlc,htlc_stub,
94 # onchaind->master: this peer can be forgotten
95 msgtype,onchaind_all_irrevocably_resolved,5011

View File

@@ -40,7 +40,7 @@ void *fromwire_fail(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
bool fromwire_hsmd_get_per_commitment_point_reply(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct pubkey *per_commitment_point UNNEEDED, struct secret **old_commitment_secret UNNEEDED)
{ fprintf(stderr, "fromwire_hsmd_get_per_commitment_point_reply called!\n"); abort(); }
/* Generated stub for fromwire_onchaind_depth */
bool fromwire_onchaind_depth(const void *p UNNEEDED, struct bitcoin_txid *txid UNNEEDED, u32 *depth UNNEEDED, bool *is_replay UNNEEDED)
bool fromwire_onchaind_depth(const void *p UNNEEDED, struct bitcoin_txid *txid UNNEEDED, u32 *depth UNNEEDED)
{ fprintf(stderr, "fromwire_onchaind_depth called!\n"); abort(); }
/* Generated stub for fromwire_onchaind_dev_memleak */
bool fromwire_onchaind_dev_memleak(const void *p UNNEEDED)
@@ -49,13 +49,13 @@ bool fromwire_onchaind_dev_memleak(const void *p UNNEEDED)
bool fromwire_onchaind_htlcs(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct htlc_stub **htlc UNNEEDED, bool **tell_if_missing UNNEEDED, bool **tell_immediately UNNEEDED)
{ fprintf(stderr, "fromwire_onchaind_htlcs called!\n"); abort(); }
/* Generated stub for fromwire_onchaind_init */
bool fromwire_onchaind_init(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct shachain *shachain UNNEEDED, const struct chainparams **chainparams UNNEEDED, struct amount_sat *funding_amount_satoshi UNNEEDED, struct amount_msat *our_msat UNNEEDED, struct pubkey *old_remote_per_commitment_point UNNEEDED, struct pubkey *remote_per_commitment_point UNNEEDED, u32 *local_to_self_delay UNNEEDED, u32 *remote_to_self_delay UNNEEDED, u32 *delayed_to_us_feerate UNNEEDED, u32 *htlc_feerate UNNEEDED, u32 *penalty_feerate UNNEEDED, struct amount_sat *local_dust_limit_satoshi UNNEEDED, struct bitcoin_txid *our_broadcast_txid UNNEEDED, u8 **local_scriptpubkey UNNEEDED, u8 **remote_scriptpubkey UNNEEDED, struct pubkey *ourwallet_pubkey UNNEEDED, enum side *opener UNNEEDED, struct basepoints *local_basepoints UNNEEDED, struct basepoints *remote_basepoints UNNEEDED, struct tx_parts **tx_parts UNNEEDED, u32 *locktime UNNEEDED, u32 *tx_blockheight UNNEEDED, u32 *reasonable_depth UNNEEDED, struct bitcoin_signature **htlc_signature UNNEEDED, u32 *min_possible_feerate UNNEEDED, u32 *max_possible_feerate UNNEEDED, struct pubkey **possible_remote_per_commit_point UNNEEDED, struct pubkey *local_funding_pubkey UNNEEDED, struct pubkey *remote_funding_pubkey UNNEEDED, u64 *local_static_remotekey_start UNNEEDED, u64 *remote_static_remotekey_start UNNEEDED, bool *option_anchor_outputs UNNEEDED, bool *is_replay UNNEEDED, u32 *min_relay_feerate UNNEEDED)
bool fromwire_onchaind_init(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct shachain *shachain UNNEEDED, const struct chainparams **chainparams UNNEEDED, struct amount_sat *funding_amount_satoshi UNNEEDED, struct amount_msat *our_msat UNNEEDED, struct pubkey *old_remote_per_commitment_point UNNEEDED, struct pubkey *remote_per_commitment_point UNNEEDED, u32 *local_to_self_delay UNNEEDED, u32 *remote_to_self_delay UNNEEDED, u32 *delayed_to_us_feerate UNNEEDED, u32 *htlc_feerate UNNEEDED, u32 *penalty_feerate UNNEEDED, struct amount_sat *local_dust_limit_satoshi UNNEEDED, struct bitcoin_txid *our_broadcast_txid UNNEEDED, u8 **local_scriptpubkey UNNEEDED, u8 **remote_scriptpubkey UNNEEDED, struct pubkey *ourwallet_pubkey UNNEEDED, enum side *opener UNNEEDED, struct basepoints *local_basepoints UNNEEDED, struct basepoints *remote_basepoints UNNEEDED, struct tx_parts **tx_parts UNNEEDED, u32 *locktime UNNEEDED, u32 *tx_blockheight UNNEEDED, u32 *reasonable_depth UNNEEDED, struct bitcoin_signature **htlc_signature UNNEEDED, u32 *min_possible_feerate UNNEEDED, u32 *max_possible_feerate UNNEEDED, struct pubkey **possible_remote_per_commit_point UNNEEDED, struct pubkey *local_funding_pubkey UNNEEDED, struct pubkey *remote_funding_pubkey UNNEEDED, u64 *local_static_remotekey_start UNNEEDED, u64 *remote_static_remotekey_start UNNEEDED, bool *option_anchor_outputs UNNEEDED, u32 *min_relay_feerate UNNEEDED)
{ fprintf(stderr, "fromwire_onchaind_init called!\n"); abort(); }
/* Generated stub for fromwire_onchaind_known_preimage */
bool fromwire_onchaind_known_preimage(const void *p UNNEEDED, struct preimage *preimage UNNEEDED, bool *is_replay UNNEEDED)
bool fromwire_onchaind_known_preimage(const void *p UNNEEDED, struct preimage *preimage UNNEEDED)
{ fprintf(stderr, "fromwire_onchaind_known_preimage called!\n"); abort(); }
/* Generated stub for fromwire_onchaind_spent */
bool fromwire_onchaind_spent(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct tx_parts **tx UNNEEDED, u32 *input_num UNNEEDED, u32 *blockheight UNNEEDED, bool *is_replay UNNEEDED)
bool fromwire_onchaind_spent(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct tx_parts **tx UNNEEDED, u32 *input_num UNNEEDED, u32 *blockheight UNNEEDED)
{ fprintf(stderr, "fromwire_onchaind_spent called!\n"); abort(); }
/* Generated stub for fromwire_peektype */
int fromwire_peektype(const u8 *cursor UNNEEDED)
@@ -424,8 +424,8 @@ int main(int argc, char *argv[])
size_t ret = resolve_our_htlc_ourcommit(out,
matches,
htlcs,
htlc_scripts,
false);
htlc_scripts);
assert(ret == 2);
common_shutdown();
}

View File

@@ -45,7 +45,7 @@ bool fromwire_hsmd_get_per_commitment_point_reply(const tal_t *ctx UNNEEDED, con
bool fromwire_hsmd_sign_tx_reply(const void *p UNNEEDED, struct bitcoin_signature *sig UNNEEDED)
{ fprintf(stderr, "fromwire_hsmd_sign_tx_reply called!\n"); abort(); }
/* Generated stub for fromwire_onchaind_depth */
bool fromwire_onchaind_depth(const void *p UNNEEDED, struct bitcoin_txid *txid UNNEEDED, u32 *depth UNNEEDED, bool *is_replay UNNEEDED)
bool fromwire_onchaind_depth(const void *p UNNEEDED, struct bitcoin_txid *txid UNNEEDED, u32 *depth UNNEEDED)
{ fprintf(stderr, "fromwire_onchaind_depth called!\n"); abort(); }
/* Generated stub for fromwire_onchaind_dev_memleak */
bool fromwire_onchaind_dev_memleak(const void *p UNNEEDED)
@@ -54,13 +54,13 @@ bool fromwire_onchaind_dev_memleak(const void *p UNNEEDED)
bool fromwire_onchaind_htlcs(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct htlc_stub **htlc UNNEEDED, bool **tell_if_missing UNNEEDED, bool **tell_immediately UNNEEDED)
{ fprintf(stderr, "fromwire_onchaind_htlcs called!\n"); abort(); }
/* Generated stub for fromwire_onchaind_init */
bool fromwire_onchaind_init(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct shachain *shachain UNNEEDED, const struct chainparams **chainparams UNNEEDED, struct amount_sat *funding_amount_satoshi UNNEEDED, struct amount_msat *our_msat UNNEEDED, struct pubkey *old_remote_per_commitment_point UNNEEDED, struct pubkey *remote_per_commitment_point UNNEEDED, u32 *local_to_self_delay UNNEEDED, u32 *remote_to_self_delay UNNEEDED, u32 *delayed_to_us_feerate UNNEEDED, u32 *htlc_feerate UNNEEDED, u32 *penalty_feerate UNNEEDED, struct amount_sat *local_dust_limit_satoshi UNNEEDED, struct bitcoin_txid *our_broadcast_txid UNNEEDED, u8 **local_scriptpubkey UNNEEDED, u8 **remote_scriptpubkey UNNEEDED, struct pubkey *ourwallet_pubkey UNNEEDED, enum side *opener UNNEEDED, struct basepoints *local_basepoints UNNEEDED, struct basepoints *remote_basepoints UNNEEDED, struct tx_parts **tx_parts UNNEEDED, u32 *locktime UNNEEDED, u32 *tx_blockheight UNNEEDED, u32 *reasonable_depth UNNEEDED, struct bitcoin_signature **htlc_signature UNNEEDED, u32 *min_possible_feerate UNNEEDED, u32 *max_possible_feerate UNNEEDED, struct pubkey **possible_remote_per_commit_point UNNEEDED, struct pubkey *local_funding_pubkey UNNEEDED, struct pubkey *remote_funding_pubkey UNNEEDED, u64 *local_static_remotekey_start UNNEEDED, u64 *remote_static_remotekey_start UNNEEDED, bool *option_anchor_outputs UNNEEDED, bool *is_replay UNNEEDED, u32 *min_relay_feerate UNNEEDED)
bool fromwire_onchaind_init(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct shachain *shachain UNNEEDED, const struct chainparams **chainparams UNNEEDED, struct amount_sat *funding_amount_satoshi UNNEEDED, struct amount_msat *our_msat UNNEEDED, struct pubkey *old_remote_per_commitment_point UNNEEDED, struct pubkey *remote_per_commitment_point UNNEEDED, u32 *local_to_self_delay UNNEEDED, u32 *remote_to_self_delay UNNEEDED, u32 *delayed_to_us_feerate UNNEEDED, u32 *htlc_feerate UNNEEDED, u32 *penalty_feerate UNNEEDED, struct amount_sat *local_dust_limit_satoshi UNNEEDED, struct bitcoin_txid *our_broadcast_txid UNNEEDED, u8 **local_scriptpubkey UNNEEDED, u8 **remote_scriptpubkey UNNEEDED, struct pubkey *ourwallet_pubkey UNNEEDED, enum side *opener UNNEEDED, struct basepoints *local_basepoints UNNEEDED, struct basepoints *remote_basepoints UNNEEDED, struct tx_parts **tx_parts UNNEEDED, u32 *locktime UNNEEDED, u32 *tx_blockheight UNNEEDED, u32 *reasonable_depth UNNEEDED, struct bitcoin_signature **htlc_signature UNNEEDED, u32 *min_possible_feerate UNNEEDED, u32 *max_possible_feerate UNNEEDED, struct pubkey **possible_remote_per_commit_point UNNEEDED, struct pubkey *local_funding_pubkey UNNEEDED, struct pubkey *remote_funding_pubkey UNNEEDED, u64 *local_static_remotekey_start UNNEEDED, u64 *remote_static_remotekey_start UNNEEDED, bool *option_anchor_outputs UNNEEDED, u32 *min_relay_feerate UNNEEDED)
{ fprintf(stderr, "fromwire_onchaind_init called!\n"); abort(); }
/* Generated stub for fromwire_onchaind_known_preimage */
bool fromwire_onchaind_known_preimage(const void *p UNNEEDED, struct preimage *preimage UNNEEDED, bool *is_replay UNNEEDED)
bool fromwire_onchaind_known_preimage(const void *p UNNEEDED, struct preimage *preimage UNNEEDED)
{ fprintf(stderr, "fromwire_onchaind_known_preimage called!\n"); abort(); }
/* Generated stub for fromwire_onchaind_spent */
bool fromwire_onchaind_spent(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct tx_parts **tx UNNEEDED, u32 *input_num UNNEEDED, u32 *blockheight UNNEEDED, bool *is_replay UNNEEDED)
bool fromwire_onchaind_spent(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct tx_parts **tx UNNEEDED, u32 *input_num UNNEEDED, u32 *blockheight UNNEEDED)
{ fprintf(stderr, "fromwire_onchaind_spent called!\n"); abort(); }
/* Generated stub for fromwire_secp256k1_ecdsa_signature */
void fromwire_secp256k1_ecdsa_signature(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,

View File

@@ -492,8 +492,7 @@ void notify_forward_event(struct lightningd *ld UNNEEDED,
/* Generated stub for onchaind_funding_spent */
enum watch_result onchaind_funding_spent(struct channel *channel UNNEEDED,
const struct bitcoin_tx *tx UNNEEDED,
u32 blockheight UNNEEDED,
bool is_replay UNNEEDED)
u32 blockheight UNNEEDED)
{ fprintf(stderr, "onchaind_funding_spent called!\n"); abort(); }
/* Generated stub for onion_decode */
struct onion_payload *onion_decode(const tal_t *ctx UNNEEDED,
@@ -770,7 +769,7 @@ u8 *towire_invalid_realm(const tal_t *ctx UNNEEDED)
u8 *towire_onchaind_dev_memleak(const tal_t *ctx UNNEEDED)
{ fprintf(stderr, "towire_onchaind_dev_memleak called!\n"); abort(); }
/* Generated stub for towire_onchaind_known_preimage */
u8 *towire_onchaind_known_preimage(const tal_t *ctx UNNEEDED, const struct preimage *preimage UNNEEDED, bool is_replay UNNEEDED)
u8 *towire_onchaind_known_preimage(const tal_t *ctx UNNEEDED, const struct preimage *preimage UNNEEDED)
{ fprintf(stderr, "towire_onchaind_known_preimage called!\n"); abort(); }
/* Generated stub for towire_permanent_channel_failure */
u8 *towire_permanent_channel_failure(const tal_t *ctx UNNEEDED)