mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
elements: Tell onchaind it may ignore fee outputs
We'd get upset otherwise since we can't grab those. Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
parent
bb76d6daa6
commit
84144bcef6
@ -64,6 +64,9 @@ enum output_type {
|
|||||||
/* HTLC outputs: their offers and our offers */
|
/* HTLC outputs: their offers and our offers */
|
||||||
THEIR_HTLC,
|
THEIR_HTLC,
|
||||||
OUR_HTLC,
|
OUR_HTLC,
|
||||||
|
|
||||||
|
/* For elements we need a fee output type */
|
||||||
|
ELEMENTS_FEE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -723,7 +723,10 @@ static bool is_mutual_close(const struct bitcoin_tx *tx,
|
|||||||
for (i = 0; i < tx->wtx->num_outputs; i++) {
|
for (i = 0; i < tx->wtx->num_outputs; i++) {
|
||||||
const u8 *script = bitcoin_tx_output_get_script(tmpctx, tx, i);
|
const u8 *script = bitcoin_tx_output_get_script(tmpctx, tx, i);
|
||||||
/* To be paranoid, we only let each one match once. */
|
/* To be paranoid, we only let each one match once. */
|
||||||
if (scripteq(script, local_scriptpubkey)
|
if (is_elements && tal_bytelen(script) == 0) {
|
||||||
|
/* This is a fee output, ignore please */
|
||||||
|
continue;
|
||||||
|
} else if (scripteq(script, local_scriptpubkey)
|
||||||
&& !local_matched)
|
&& !local_matched)
|
||||||
local_matched = true;
|
local_matched = true;
|
||||||
else if (scripteq(script, remote_scriptpubkey)
|
else if (scripteq(script, remote_scriptpubkey)
|
||||||
@ -1093,6 +1096,7 @@ static void output_spent(const struct chainparams *chainparams,
|
|||||||
/* Um, we don't track these! */
|
/* Um, we don't track these! */
|
||||||
case OUTPUT_TO_THEM:
|
case OUTPUT_TO_THEM:
|
||||||
case DELAYED_OUTPUT_TO_THEM:
|
case DELAYED_OUTPUT_TO_THEM:
|
||||||
|
case ELEMENTS_FEE:
|
||||||
status_failed(STATUS_FAIL_INTERNAL_ERROR,
|
status_failed(STATUS_FAIL_INTERNAL_ERROR,
|
||||||
"Tracked spend of %s/%s?",
|
"Tracked spend of %s/%s?",
|
||||||
tx_type_name(out->tx_type),
|
tx_type_name(out->tx_type),
|
||||||
@ -1787,7 +1791,19 @@ static void handle_our_unilateral(const struct bitcoin_tx *tx,
|
|||||||
const u8 *oscript = bitcoin_tx_output_get_script(tmpctx, tx, i);
|
const u8 *oscript = bitcoin_tx_output_get_script(tmpctx, tx, i);
|
||||||
struct amount_sat amt = bitcoin_tx_output_get_amount(tx, i);
|
struct amount_sat amt = bitcoin_tx_output_get_amount(tx, i);
|
||||||
|
|
||||||
if (script[LOCAL]
|
if (is_elements && tal_bytelen(oscript) == 0) {
|
||||||
|
status_debug("OUTPUT %zu is a fee output", i);
|
||||||
|
/* An empty script simply means that that this is a
|
||||||
|
* fee output. */
|
||||||
|
out = new_tracked_output(tx->chainparams, &outs,
|
||||||
|
txid, tx_blockheight,
|
||||||
|
OUR_UNILATERAL, i,
|
||||||
|
amt,
|
||||||
|
ELEMENTS_FEE,
|
||||||
|
NULL, NULL, NULL);
|
||||||
|
ignore_output(out);
|
||||||
|
continue;
|
||||||
|
}else if (script[LOCAL]
|
||||||
&& scripteq(oscript, script[LOCAL])) {
|
&& scripteq(oscript, script[LOCAL])) {
|
||||||
struct bitcoin_tx *to_us;
|
struct bitcoin_tx *to_us;
|
||||||
enum tx_type tx_type = OUR_DELAYED_RETURN_TO_WALLET;
|
enum tx_type tx_type = OUR_DELAYED_RETURN_TO_WALLET;
|
||||||
@ -2134,6 +2150,19 @@ static void handle_their_cheat(const struct bitcoin_tx *tx,
|
|||||||
const u8 *oscript = bitcoin_tx_output_get_script(tmpctx, tx, i);
|
const u8 *oscript = bitcoin_tx_output_get_script(tmpctx, tx, i);
|
||||||
struct amount_sat amt = bitcoin_tx_output_get_amount(tx, i);
|
struct amount_sat amt = bitcoin_tx_output_get_amount(tx, i);
|
||||||
|
|
||||||
|
if (is_elements && tal_bytelen(oscript) == 0) {
|
||||||
|
/* An empty script simply means that that this is a
|
||||||
|
* fee output. */
|
||||||
|
out = new_tracked_output(tx->chainparams,
|
||||||
|
&outs, txid, tx_blockheight,
|
||||||
|
OUR_UNILATERAL, i,
|
||||||
|
amt,
|
||||||
|
ELEMENTS_FEE,
|
||||||
|
NULL, NULL, NULL);
|
||||||
|
ignore_output(out);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (script[LOCAL]
|
if (script[LOCAL]
|
||||||
&& scripteq(oscript, script[LOCAL])) {
|
&& scripteq(oscript, script[LOCAL])) {
|
||||||
/* BOLT #5:
|
/* BOLT #5:
|
||||||
@ -2353,7 +2382,18 @@ static void handle_their_unilateral(const struct bitcoin_tx *tx,
|
|||||||
const u8 *oscript = bitcoin_tx_output_get_script(tmpctx, tx, i);
|
const u8 *oscript = bitcoin_tx_output_get_script(tmpctx, tx, i);
|
||||||
struct amount_sat amt = bitcoin_tx_output_get_amount(tx, i);
|
struct amount_sat amt = bitcoin_tx_output_get_amount(tx, i);
|
||||||
|
|
||||||
if (script[LOCAL] && scripteq(oscript, script[LOCAL])) {
|
if (is_elements && tal_bytelen(oscript) == 0) {
|
||||||
|
/* An empty script simply means that that this is a
|
||||||
|
* fee output. */
|
||||||
|
out = new_tracked_output(tx->chainparams,
|
||||||
|
&outs, txid, tx_blockheight,
|
||||||
|
OUR_UNILATERAL, i,
|
||||||
|
amt,
|
||||||
|
ELEMENTS_FEE,
|
||||||
|
NULL, NULL, NULL);
|
||||||
|
ignore_output(out);
|
||||||
|
continue;
|
||||||
|
} else if (script[LOCAL] && scripteq(oscript, script[LOCAL])) {
|
||||||
/* BOLT #5:
|
/* BOLT #5:
|
||||||
*
|
*
|
||||||
* - MAY take no action in regard to the associated
|
* - MAY take no action in regard to the associated
|
||||||
|
Loading…
Reference in New Issue
Block a user