mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 22:45:27 +01:00
onchaind: remove chainparams args in favor of global.
Otherwise this creates noise for the next patch which switches the initial `struct bitcoin_tx` into a `struct tx_parts`. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
48f397ee19
commit
abba59057c
2 changed files with 42 additions and 71 deletions
|
@ -120,8 +120,6 @@ struct tracked_output {
|
||||||
/* If it is resolved. */
|
/* If it is resolved. */
|
||||||
struct resolution *resolved;
|
struct resolution *resolved;
|
||||||
|
|
||||||
const struct chainparams *chainparams;
|
|
||||||
|
|
||||||
/* stashed so we can pass it along to the coin ledger */
|
/* stashed so we can pass it along to the coin ledger */
|
||||||
struct sha256 payment_hash;
|
struct sha256 payment_hash;
|
||||||
};
|
};
|
||||||
|
@ -606,7 +604,7 @@ static struct bitcoin_tx *tx_to_us(const tal_t *ctx,
|
||||||
u8 *msg;
|
u8 *msg;
|
||||||
u8 **witness;
|
u8 **witness;
|
||||||
|
|
||||||
tx = bitcoin_tx(ctx, out->chainparams, 1, 1, locktime);
|
tx = bitcoin_tx(ctx, chainparams, 1, 1, locktime);
|
||||||
bitcoin_tx_add_input(tx, &out->txid, out->outnum, to_self_delay,
|
bitcoin_tx_add_input(tx, &out->txid, out->outnum, to_self_delay,
|
||||||
out->sat, NULL);
|
out->sat, NULL);
|
||||||
|
|
||||||
|
@ -701,8 +699,7 @@ static void hsm_get_per_commitment_point(struct pubkey *per_commitment_point)
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct tracked_output *
|
static struct tracked_output *
|
||||||
new_tracked_output(const struct chainparams *chainparams,
|
new_tracked_output(struct tracked_output ***outs,
|
||||||
struct tracked_output ***outs,
|
|
||||||
const struct bitcoin_txid *txid,
|
const struct bitcoin_txid *txid,
|
||||||
u32 tx_blockheight,
|
u32 tx_blockheight,
|
||||||
enum tx_type tx_type,
|
enum tx_type tx_type,
|
||||||
|
@ -730,7 +727,6 @@ new_tracked_output(const struct chainparams *chainparams,
|
||||||
out->output_type = output_type;
|
out->output_type = output_type;
|
||||||
out->proposal = NULL;
|
out->proposal = NULL;
|
||||||
out->resolved = NULL;
|
out->resolved = NULL;
|
||||||
out->chainparams = chainparams;
|
|
||||||
if (htlc)
|
if (htlc)
|
||||||
out->htlc = *htlc;
|
out->htlc = *htlc;
|
||||||
out->wscript = tal_steal(out, wscript);
|
out->wscript = tal_steal(out, wscript);
|
||||||
|
@ -1239,8 +1235,7 @@ static void handle_htlc_onchain_fulfill(struct tracked_output *out,
|
||||||
&preimage)));
|
&preimage)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void resolve_htlc_tx(const struct chainparams *chainparams,
|
static void resolve_htlc_tx(struct tracked_output ***outs,
|
||||||
struct tracked_output ***outs,
|
|
||||||
size_t out_index,
|
size_t out_index,
|
||||||
const struct tx_parts *htlc_tx,
|
const struct tx_parts *htlc_tx,
|
||||||
u32 tx_blockheight,
|
u32 tx_blockheight,
|
||||||
|
@ -1268,7 +1263,7 @@ static void resolve_htlc_tx(const struct chainparams *chainparams,
|
||||||
asset = wally_tx_output_get_amount(htlc_tx->outputs[0]);
|
asset = wally_tx_output_get_amount(htlc_tx->outputs[0]);
|
||||||
assert(amount_asset_is_main(&asset));
|
assert(amount_asset_is_main(&asset));
|
||||||
amt = amount_asset_to_sat(&asset);
|
amt = amount_asset_to_sat(&asset);
|
||||||
out = new_tracked_output(chainparams, outs, &htlc_tx->txid,
|
out = new_tracked_output(outs, &htlc_tx->txid,
|
||||||
tx_blockheight,
|
tx_blockheight,
|
||||||
(*outs)[out_index]->resolved->tx_type,
|
(*outs)[out_index]->resolved->tx_type,
|
||||||
0, amt,
|
0, amt,
|
||||||
|
@ -1300,8 +1295,7 @@ static void resolve_htlc_tx(const struct chainparams *chainparams,
|
||||||
* - MUST *resolve* the _remote node's HTLC-success transaction_ by spending it
|
* - MUST *resolve* the _remote node's HTLC-success transaction_ by spending it
|
||||||
* using the revocation private key.
|
* using the revocation private key.
|
||||||
*/
|
*/
|
||||||
static void steal_htlc_tx(const struct chainparams *chainparams,
|
static void steal_htlc_tx(struct tracked_output *out,
|
||||||
struct tracked_output *out,
|
|
||||||
struct tracked_output ***outs,
|
struct tracked_output ***outs,
|
||||||
const struct tx_parts *htlc_tx,
|
const struct tx_parts *htlc_tx,
|
||||||
u32 htlc_tx_blockheight,
|
u32 htlc_tx_blockheight,
|
||||||
|
@ -1322,7 +1316,7 @@ static void steal_htlc_tx(const struct chainparams *chainparams,
|
||||||
assert(amount_asset_is_main(&asset));
|
assert(amount_asset_is_main(&asset));
|
||||||
htlc_out_amt = amount_asset_to_sat(&asset);
|
htlc_out_amt = amount_asset_to_sat(&asset);
|
||||||
|
|
||||||
htlc_out = new_tracked_output(chainparams, outs,
|
htlc_out = new_tracked_output(outs,
|
||||||
&htlc_tx->txid, htlc_tx_blockheight,
|
&htlc_tx->txid, htlc_tx_blockheight,
|
||||||
htlc_tx_type,
|
htlc_tx_type,
|
||||||
/* htlc tx's only have 1 output */
|
/* htlc tx's only have 1 output */
|
||||||
|
@ -1380,8 +1374,7 @@ static void onchain_annotate_txin(const struct bitcoin_txid *txid, u32 innum,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* An output has been spent: see if it resolves something we care about. */
|
/* An output has been spent: see if it resolves something we care about. */
|
||||||
static void output_spent(const struct chainparams *chainparams,
|
static void output_spent(struct tracked_output ***outs,
|
||||||
struct tracked_output ***outs,
|
|
||||||
const struct tx_parts *tx_parts,
|
const struct tx_parts *tx_parts,
|
||||||
u32 input_num,
|
u32 input_num,
|
||||||
u32 tx_blockheight,
|
u32 tx_blockheight,
|
||||||
|
@ -1401,7 +1394,7 @@ static void output_spent(const struct chainparams *chainparams,
|
||||||
/* If it's our htlc tx, we need to resolve that, too. */
|
/* If it's our htlc tx, we need to resolve that, too. */
|
||||||
if (out->resolved->tx_type == OUR_HTLC_SUCCESS_TX
|
if (out->resolved->tx_type == OUR_HTLC_SUCCESS_TX
|
||||||
|| out->resolved->tx_type == OUR_HTLC_TIMEOUT_TX)
|
|| out->resolved->tx_type == OUR_HTLC_TIMEOUT_TX)
|
||||||
resolve_htlc_tx(chainparams, outs, i, tx_parts,
|
resolve_htlc_tx(outs, i, tx_parts,
|
||||||
tx_blockheight, is_replay);
|
tx_blockheight, is_replay);
|
||||||
|
|
||||||
if (!is_replay)
|
if (!is_replay)
|
||||||
|
@ -1423,7 +1416,7 @@ static void output_spent(const struct chainparams *chainparams,
|
||||||
case THEIR_HTLC:
|
case THEIR_HTLC:
|
||||||
if (out->tx_type == THEIR_REVOKED_UNILATERAL) {
|
if (out->tx_type == THEIR_REVOKED_UNILATERAL) {
|
||||||
/* we've actually got a 'new' output here */
|
/* we've actually got a 'new' output here */
|
||||||
steal_htlc_tx(chainparams, out, outs, tx_parts,
|
steal_htlc_tx(out, outs, tx_parts,
|
||||||
tx_blockheight, THEIR_HTLC_TIMEOUT_TO_THEM,
|
tx_blockheight, THEIR_HTLC_TIMEOUT_TO_THEM,
|
||||||
is_replay);
|
is_replay);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1452,7 +1445,7 @@ static void output_spent(const struct chainparams *chainparams,
|
||||||
*/
|
*/
|
||||||
handle_htlc_onchain_fulfill(out, tx_parts);
|
handle_htlc_onchain_fulfill(out, tx_parts);
|
||||||
if (out->tx_type == THEIR_REVOKED_UNILATERAL) {
|
if (out->tx_type == THEIR_REVOKED_UNILATERAL) {
|
||||||
steal_htlc_tx(chainparams, out, outs, tx_parts,
|
steal_htlc_tx(out, outs, tx_parts,
|
||||||
tx_blockheight, OUR_HTLC_FULFILL_TO_THEM,
|
tx_blockheight, OUR_HTLC_FULFILL_TO_THEM,
|
||||||
is_replay);
|
is_replay);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1617,8 +1610,7 @@ static void tx_new_depth(struct tracked_output **outs,
|
||||||
* - MUST NOT *resolve* the output by spending it.
|
* - MUST NOT *resolve* the output by spending it.
|
||||||
*/
|
*/
|
||||||
/* Master makes sure we only get told preimages once other node is committed. */
|
/* Master makes sure we only get told preimages once other node is committed. */
|
||||||
static void handle_preimage(const struct chainparams *chainparams,
|
static void handle_preimage(struct tracked_output **outs,
|
||||||
struct tracked_output **outs,
|
|
||||||
const struct preimage *preimage,
|
const struct preimage *preimage,
|
||||||
bool is_replay)
|
bool is_replay)
|
||||||
{
|
{
|
||||||
|
@ -1676,8 +1668,7 @@ static void handle_preimage(const struct chainparams *chainparams,
|
||||||
type_to_string(tmpctx,
|
type_to_string(tmpctx,
|
||||||
struct amount_sat,
|
struct amount_sat,
|
||||||
&outs[i]->sat));
|
&outs[i]->sat));
|
||||||
tx = htlc_success_tx(outs[i],
|
tx = htlc_success_tx(outs[i], chainparams,
|
||||||
chainparams,
|
|
||||||
&outs[i]->txid,
|
&outs[i]->txid,
|
||||||
outs[i]->outnum,
|
outs[i]->outnum,
|
||||||
htlc_amount,
|
htlc_amount,
|
||||||
|
@ -1783,8 +1774,7 @@ static bool handle_dev_memleak(struct tracked_output **outs, const u8 *msg)
|
||||||
* - MUST monitor the blockchain for transactions that spend any output that
|
* - MUST monitor the blockchain for transactions that spend any output that
|
||||||
* is NOT *irrevocably resolved*.
|
* is NOT *irrevocably resolved*.
|
||||||
*/
|
*/
|
||||||
static void wait_for_resolved(const struct chainparams *chainparams,
|
static void wait_for_resolved(struct tracked_output **outs)
|
||||||
struct tracked_output **outs)
|
|
||||||
{
|
{
|
||||||
billboard_update(outs);
|
billboard_update(outs);
|
||||||
|
|
||||||
|
@ -1803,9 +1793,9 @@ static void wait_for_resolved(const struct chainparams *chainparams,
|
||||||
tx_new_depth(outs, &txid, depth, is_replay);
|
tx_new_depth(outs, &txid, depth, is_replay);
|
||||||
else if (fromwire_onchain_spent(msg, msg, &tx_parts, &input_num,
|
else if (fromwire_onchain_spent(msg, msg, &tx_parts, &input_num,
|
||||||
&tx_blockheight, &is_replay)) {
|
&tx_blockheight, &is_replay)) {
|
||||||
output_spent(chainparams, &outs, tx_parts, input_num, tx_blockheight, is_replay);
|
output_spent(&outs, tx_parts, input_num, tx_blockheight, is_replay);
|
||||||
} else if (fromwire_onchain_known_preimage(msg, &preimage, &is_replay))
|
} else if (fromwire_onchain_known_preimage(msg, &preimage, &is_replay))
|
||||||
handle_preimage(chainparams, outs, &preimage, is_replay);
|
handle_preimage(outs, &preimage, is_replay);
|
||||||
else if (!handle_dev_memleak(outs, msg))
|
else if (!handle_dev_memleak(outs, msg))
|
||||||
master_badmsg(-1, msg);
|
master_badmsg(-1, msg);
|
||||||
|
|
||||||
|
@ -1825,8 +1815,7 @@ static void init_reply(const char *what)
|
||||||
peer_billboard(true, what);
|
peer_billboard(true, what);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_mutual_close(const struct chainparams *chainparams,
|
static void handle_mutual_close(const struct bitcoin_txid *txid,
|
||||||
const struct bitcoin_txid *txid,
|
|
||||||
struct tracked_output **outs,
|
struct tracked_output **outs,
|
||||||
const struct bitcoin_tx *tx,
|
const struct bitcoin_tx *tx,
|
||||||
u32 tx_blockheight,
|
u32 tx_blockheight,
|
||||||
|
@ -1863,7 +1852,7 @@ static void handle_mutual_close(const struct chainparams *chainparams,
|
||||||
our_out, our_outnum);
|
our_out, our_outnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
wait_for_resolved(chainparams, outs);
|
wait_for_resolved(outs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static u8 **derive_htlc_scripts(const struct htlc_stub *htlcs, enum side side)
|
static u8 **derive_htlc_scripts(const struct htlc_stub *htlcs, enum side side)
|
||||||
|
@ -1893,8 +1882,7 @@ static u8 **derive_htlc_scripts(const struct htlc_stub *htlcs, enum side side)
|
||||||
return htlc_scripts;
|
return htlc_scripts;
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t resolve_our_htlc_ourcommit(const struct chainparams *chainparams,
|
static size_t resolve_our_htlc_ourcommit(struct tracked_output *out,
|
||||||
struct tracked_output *out,
|
|
||||||
const size_t *matches,
|
const size_t *matches,
|
||||||
const struct htlc_stub *htlcs,
|
const struct htlc_stub *htlcs,
|
||||||
u8 **htlc_scripts,
|
u8 **htlc_scripts,
|
||||||
|
@ -2239,7 +2227,7 @@ static void handle_our_unilateral(const struct bitcoin_tx *tx,
|
||||||
status_debug("OUTPUT %zu is a fee output", i);
|
status_debug("OUTPUT %zu is a fee output", i);
|
||||||
/* An empty script simply means that that this is a
|
/* An empty script simply means that that this is a
|
||||||
* fee output. */
|
* fee output. */
|
||||||
out = new_tracked_output(tx->chainparams, &outs,
|
out = new_tracked_output(&outs,
|
||||||
txid, tx_blockheight,
|
txid, tx_blockheight,
|
||||||
OUR_UNILATERAL, i,
|
OUR_UNILATERAL, i,
|
||||||
amt,
|
amt,
|
||||||
|
@ -2264,8 +2252,7 @@ static void handle_our_unilateral(const struct bitcoin_tx *tx,
|
||||||
* node's `to_self_delay` field) before spending
|
* node's `to_self_delay` field) before spending
|
||||||
* the output.
|
* the output.
|
||||||
*/
|
*/
|
||||||
out = new_tracked_output(tx->chainparams,
|
out = new_tracked_output(&outs, txid, tx_blockheight,
|
||||||
&outs, txid, tx_blockheight,
|
|
||||||
OUR_UNILATERAL, i,
|
OUR_UNILATERAL, i,
|
||||||
amt,
|
amt,
|
||||||
DELAYED_OUTPUT_TO_US,
|
DELAYED_OUTPUT_TO_US,
|
||||||
|
@ -2305,8 +2292,7 @@ static void handle_our_unilateral(const struct bitcoin_tx *tx,
|
||||||
* node, as `to_remote` is considered *resolved*
|
* node, as `to_remote` is considered *resolved*
|
||||||
* by the commitment transaction itself.
|
* by the commitment transaction itself.
|
||||||
*/
|
*/
|
||||||
out = new_tracked_output(tx->chainparams,
|
out = new_tracked_output(&outs, txid, tx_blockheight,
|
||||||
&outs, txid, tx_blockheight,
|
|
||||||
OUR_UNILATERAL, i,
|
OUR_UNILATERAL, i,
|
||||||
amt,
|
amt,
|
||||||
OUTPUT_TO_THEM,
|
OUTPUT_TO_THEM,
|
||||||
|
@ -2333,8 +2319,7 @@ static void handle_our_unilateral(const struct bitcoin_tx *tx,
|
||||||
* in [HTLC Output Handling: Local Commitment,
|
* in [HTLC Output Handling: Local Commitment,
|
||||||
* Local Offers]
|
* Local Offers]
|
||||||
*/
|
*/
|
||||||
out = new_tracked_output(tx->chainparams,
|
out = new_tracked_output(&outs, txid,
|
||||||
&outs, txid,
|
|
||||||
tx_blockheight,
|
tx_blockheight,
|
||||||
OUR_UNILATERAL, i,
|
OUR_UNILATERAL, i,
|
||||||
amt,
|
amt,
|
||||||
|
@ -2342,15 +2327,13 @@ static void handle_our_unilateral(const struct bitcoin_tx *tx,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
remote_htlc_sigs);
|
remote_htlc_sigs);
|
||||||
/* Tells us which htlc to use */
|
/* Tells us which htlc to use */
|
||||||
which_htlc = resolve_our_htlc_ourcommit(tx->chainparams,
|
which_htlc = resolve_our_htlc_ourcommit(out, matches,
|
||||||
out, matches,
|
|
||||||
htlcs,
|
htlcs,
|
||||||
htlc_scripts,
|
htlc_scripts,
|
||||||
is_replay);
|
is_replay);
|
||||||
add_amt(&our_outs, amt);
|
add_amt(&our_outs, amt);
|
||||||
} else {
|
} else {
|
||||||
out = new_tracked_output(tx->chainparams,
|
out = new_tracked_output(&outs, txid,
|
||||||
&outs, txid,
|
|
||||||
tx_blockheight,
|
tx_blockheight,
|
||||||
OUR_UNILATERAL, i,
|
OUR_UNILATERAL, i,
|
||||||
amt,
|
amt,
|
||||||
|
@ -2386,7 +2369,7 @@ static void handle_our_unilateral(const struct bitcoin_tx *tx,
|
||||||
outs[0]->sat,
|
outs[0]->sat,
|
||||||
their_outs, our_outs);
|
their_outs, our_outs);
|
||||||
|
|
||||||
wait_for_resolved(tx->chainparams, outs);
|
wait_for_resolved(outs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We produce individual penalty txs. It's less efficient, but avoids them
|
/* We produce individual penalty txs. It's less efficient, but avoids them
|
||||||
|
@ -2648,8 +2631,7 @@ static void handle_their_cheat(const struct bitcoin_tx *tx,
|
||||||
(oscript == NULL || tal_bytelen(oscript) == 0)) {
|
(oscript == NULL || tal_bytelen(oscript) == 0)) {
|
||||||
/* An empty script simply means that that this is a
|
/* An empty script simply means that that this is a
|
||||||
* fee output. */
|
* fee output. */
|
||||||
out = new_tracked_output(tx->chainparams,
|
out = new_tracked_output(&outs, txid, tx_blockheight,
|
||||||
&outs, txid, tx_blockheight,
|
|
||||||
THEIR_REVOKED_UNILATERAL, i,
|
THEIR_REVOKED_UNILATERAL, i,
|
||||||
amt,
|
amt,
|
||||||
ELEMENTS_FEE,
|
ELEMENTS_FEE,
|
||||||
|
@ -2668,8 +2650,7 @@ static void handle_their_cheat(const struct bitcoin_tx *tx,
|
||||||
* - Note: this output is considered *resolved* by
|
* - Note: this output is considered *resolved* by
|
||||||
* the commitment transaction itself.
|
* the commitment transaction itself.
|
||||||
*/
|
*/
|
||||||
out = new_tracked_output(tx->chainparams,
|
out = new_tracked_output(&outs, txid, tx_blockheight,
|
||||||
&outs, txid, tx_blockheight,
|
|
||||||
THEIR_REVOKED_UNILATERAL,
|
THEIR_REVOKED_UNILATERAL,
|
||||||
i, amt,
|
i, amt,
|
||||||
OUTPUT_TO_US, NULL, NULL, NULL);
|
OUTPUT_TO_US, NULL, NULL, NULL);
|
||||||
|
@ -2694,8 +2675,7 @@ static void handle_their_cheat(const struct bitcoin_tx *tx,
|
||||||
* - MUST *resolve* the _remote node's main output_ by
|
* - MUST *resolve* the _remote node's main output_ by
|
||||||
* spending it using the revocation private key.
|
* spending it using the revocation private key.
|
||||||
*/
|
*/
|
||||||
out = new_tracked_output(tx->chainparams,
|
out = new_tracked_output(&outs, txid, tx_blockheight,
|
||||||
&outs, txid, tx_blockheight,
|
|
||||||
THEIR_REVOKED_UNILATERAL, i,
|
THEIR_REVOKED_UNILATERAL, i,
|
||||||
amt,
|
amt,
|
||||||
DELAYED_CHEAT_OUTPUT_TO_THEM,
|
DELAYED_CHEAT_OUTPUT_TO_THEM,
|
||||||
|
@ -2723,8 +2703,7 @@ static void handle_their_cheat(const struct bitcoin_tx *tx,
|
||||||
* * spend the *commitment tx* once the HTLC timeout has passed.
|
* * spend the *commitment tx* once the HTLC timeout has passed.
|
||||||
* * spend the *HTLC-success tx*, if the remote node has published it.
|
* * spend the *HTLC-success tx*, if the remote node has published it.
|
||||||
*/
|
*/
|
||||||
out = new_tracked_output(tx->chainparams,
|
out = new_tracked_output(&outs, txid,
|
||||||
&outs, txid,
|
|
||||||
tx_blockheight,
|
tx_blockheight,
|
||||||
THEIR_REVOKED_UNILATERAL, i,
|
THEIR_REVOKED_UNILATERAL, i,
|
||||||
amt,
|
amt,
|
||||||
|
@ -2735,8 +2714,7 @@ static void handle_their_cheat(const struct bitcoin_tx *tx,
|
||||||
steal_htlc(out, is_replay);
|
steal_htlc(out, is_replay);
|
||||||
add_amt(&total_outs, amt);
|
add_amt(&total_outs, amt);
|
||||||
} else {
|
} else {
|
||||||
out = new_tracked_output(tx->chainparams,
|
out = new_tracked_output(&outs, txid,
|
||||||
&outs, txid,
|
|
||||||
tx_blockheight,
|
tx_blockheight,
|
||||||
THEIR_REVOKED_UNILATERAL, i,
|
THEIR_REVOKED_UNILATERAL, i,
|
||||||
amt,
|
amt,
|
||||||
|
@ -2769,7 +2747,7 @@ static void handle_their_cheat(const struct bitcoin_tx *tx,
|
||||||
if (!is_replay)
|
if (!is_replay)
|
||||||
update_ledger_chain_fees(txid, tx_blockheight, fee_cost);
|
update_ledger_chain_fees(txid, tx_blockheight, fee_cost);
|
||||||
|
|
||||||
wait_for_resolved(tx->chainparams, outs);
|
wait_for_resolved(outs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_their_unilateral(const struct bitcoin_tx *tx,
|
static void handle_their_unilateral(const struct bitcoin_tx *tx,
|
||||||
|
@ -2904,8 +2882,7 @@ static void handle_their_unilateral(const struct bitcoin_tx *tx,
|
||||||
(oscript == NULL || tal_bytelen(oscript) == 0)) {
|
(oscript == NULL || tal_bytelen(oscript) == 0)) {
|
||||||
/* An empty script simply means that that this is a
|
/* An empty script simply means that that this is a
|
||||||
* fee output. */
|
* fee output. */
|
||||||
out = new_tracked_output(tx->chainparams,
|
out = new_tracked_output(&outs, txid, tx_blockheight,
|
||||||
&outs, txid, tx_blockheight,
|
|
||||||
THEIR_UNILATERAL, i,
|
THEIR_UNILATERAL, i,
|
||||||
amt,
|
amt,
|
||||||
ELEMENTS_FEE,
|
ELEMENTS_FEE,
|
||||||
|
@ -2921,8 +2898,7 @@ static void handle_their_unilateral(const struct bitcoin_tx *tx,
|
||||||
* - Note: `to_remote` is considered *resolved* by the
|
* - Note: `to_remote` is considered *resolved* by the
|
||||||
* commitment transaction itself.
|
* commitment transaction itself.
|
||||||
*/
|
*/
|
||||||
out = new_tracked_output(tx->chainparams,
|
out = new_tracked_output(&outs, txid, tx_blockheight,
|
||||||
&outs, txid, tx_blockheight,
|
|
||||||
THEIR_UNILATERAL,
|
THEIR_UNILATERAL,
|
||||||
i, amt,
|
i, amt,
|
||||||
OUTPUT_TO_US, NULL, NULL, NULL);
|
OUTPUT_TO_US, NULL, NULL, NULL);
|
||||||
|
@ -2950,8 +2926,7 @@ static void handle_their_unilateral(const struct bitcoin_tx *tx,
|
||||||
* - Note: `to_local` is considered *resolved* by the
|
* - Note: `to_local` is considered *resolved* by the
|
||||||
* commitment transaction itself.
|
* commitment transaction itself.
|
||||||
*/
|
*/
|
||||||
out = new_tracked_output(tx->chainparams,
|
out = new_tracked_output(&outs, txid, tx_blockheight,
|
||||||
&outs, txid, tx_blockheight,
|
|
||||||
THEIR_UNILATERAL, i,
|
THEIR_UNILATERAL, i,
|
||||||
amt,
|
amt,
|
||||||
DELAYED_OUTPUT_TO_THEM,
|
DELAYED_OUTPUT_TO_THEM,
|
||||||
|
@ -2974,8 +2949,7 @@ static void handle_their_unilateral(const struct bitcoin_tx *tx,
|
||||||
* [HTLC Output Handling: Remote Commitment,
|
* [HTLC Output Handling: Remote Commitment,
|
||||||
* Local Offers]
|
* Local Offers]
|
||||||
*/
|
*/
|
||||||
out = new_tracked_output(tx->chainparams,
|
out = new_tracked_output(&outs, txid,
|
||||||
&outs, txid,
|
|
||||||
tx_blockheight,
|
tx_blockheight,
|
||||||
THEIR_UNILATERAL, i,
|
THEIR_UNILATERAL, i,
|
||||||
amt,
|
amt,
|
||||||
|
@ -2989,8 +2963,7 @@ static void handle_their_unilateral(const struct bitcoin_tx *tx,
|
||||||
is_replay);
|
is_replay);
|
||||||
add_amt(&our_outs, amt);
|
add_amt(&our_outs, amt);
|
||||||
} else {
|
} else {
|
||||||
out = new_tracked_output(tx->chainparams,
|
out = new_tracked_output(&outs, txid,
|
||||||
&outs, txid,
|
|
||||||
tx_blockheight,
|
tx_blockheight,
|
||||||
THEIR_UNILATERAL, i,
|
THEIR_UNILATERAL, i,
|
||||||
amt,
|
amt,
|
||||||
|
@ -3020,7 +2993,7 @@ static void handle_their_unilateral(const struct bitcoin_tx *tx,
|
||||||
outs[0]->sat,
|
outs[0]->sat,
|
||||||
their_outs, our_outs);
|
their_outs, our_outs);
|
||||||
|
|
||||||
wait_for_resolved(tx->chainparams, outs);
|
wait_for_resolved(outs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update_ledger_unknown(const struct bitcoin_txid *txid,
|
static void update_ledger_unknown(const struct bitcoin_txid *txid,
|
||||||
|
@ -3131,8 +3104,7 @@ static void handle_unknown_commitment(const struct bitcoin_tx *tx,
|
||||||
* - Note: `to_remote` is considered *resolved* by the
|
* - Note: `to_remote` is considered *resolved* by the
|
||||||
* commitment transaction itself.
|
* commitment transaction itself.
|
||||||
*/
|
*/
|
||||||
out = new_tracked_output(tx->chainparams,
|
out = new_tracked_output(&outs, txid, tx_blockheight,
|
||||||
&outs, txid, tx_blockheight,
|
|
||||||
UNKNOWN_UNILATERAL,
|
UNKNOWN_UNILATERAL,
|
||||||
i, amt,
|
i, amt,
|
||||||
OUTPUT_TO_US, NULL, NULL, NULL);
|
OUTPUT_TO_US, NULL, NULL, NULL);
|
||||||
|
@ -3181,7 +3153,7 @@ search_done:
|
||||||
wire_sync_write(REQ_FD, take(msg));
|
wire_sync_write(REQ_FD, take(msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
wait_for_resolved(tx->chainparams, outs);
|
wait_for_resolved(outs);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
@ -3275,7 +3247,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
outs = tal_arr(ctx, struct tracked_output *, 0);
|
outs = tal_arr(ctx, struct tracked_output *, 0);
|
||||||
bitcoin_tx_input_get_txid(tx, 0, &tmptxid);
|
bitcoin_tx_input_get_txid(tx, 0, &tmptxid);
|
||||||
new_tracked_output(tx->chainparams, &outs, &tmptxid,
|
new_tracked_output(&outs, &tmptxid,
|
||||||
0, /* We don't care about funding blockheight */
|
0, /* We don't care about funding blockheight */
|
||||||
FUNDING_TRANSACTION,
|
FUNDING_TRANSACTION,
|
||||||
tx->wtx->inputs[0].index,
|
tx->wtx->inputs[0].index,
|
||||||
|
@ -3300,7 +3272,7 @@ int main(int argc, char *argv[])
|
||||||
* [BOLT #2: Channel Close](02-peer-protocol.md#channel-close)).
|
* [BOLT #2: Channel Close](02-peer-protocol.md#channel-close)).
|
||||||
*/
|
*/
|
||||||
if (is_mutual_close(tx, scriptpubkey[LOCAL], scriptpubkey[REMOTE], &mutual_outnum))
|
if (is_mutual_close(tx, scriptpubkey[LOCAL], scriptpubkey[REMOTE], &mutual_outnum))
|
||||||
handle_mutual_close(tx->chainparams, &txid, outs, tx,
|
handle_mutual_close(&txid, outs, tx,
|
||||||
tx_blockheight, mutual_outnum, open_is_replay);
|
tx_blockheight, mutual_outnum, open_is_replay);
|
||||||
else {
|
else {
|
||||||
/* BOLT #5:
|
/* BOLT #5:
|
||||||
|
|
|
@ -405,8 +405,7 @@ int main(int argc, char *argv[])
|
||||||
min_possible_feerate = 10992;
|
min_possible_feerate = 10992;
|
||||||
max_possible_feerate = 15370;
|
max_possible_feerate = 15370;
|
||||||
|
|
||||||
size_t ret = resolve_our_htlc_ourcommit(chainparams_by_bip173("bc"),
|
size_t ret = resolve_our_htlc_ourcommit(out,
|
||||||
out,
|
|
||||||
matches,
|
matches,
|
||||||
htlcs,
|
htlcs,
|
||||||
htlc_scripts,
|
htlc_scripts,
|
||||||
|
|
Loading…
Add table
Reference in a new issue