mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-17 19:03:42 +01:00
elements: Fix transaction handling for elements transactions
Skipping coinbase transactions and ensuring that the transaction is serialized correctly when sending it onwards. Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
parent
436da7f231
commit
639713b547
@ -97,6 +97,9 @@ const u8 *bitcoin_tx_output_get_script(const tal_t *ctx,
|
||||
u8 *res;
|
||||
assert(outnum < tx->wtx->num_outputs);
|
||||
output = &tx->wtx->outputs[outnum];
|
||||
if (output->features & WALLY_TX_IS_COINBASE)
|
||||
return NULL;
|
||||
|
||||
res = tal_arr(ctx, u8, output->script_len);
|
||||
memcpy(res, output->script, output->script_len);
|
||||
return res;
|
||||
@ -220,7 +223,10 @@ static void push_tx(const struct bitcoin_tx *tx,
|
||||
if (bip144 && uses_witness(tx))
|
||||
flag |= WALLY_TX_FLAG_USE_WITNESS;
|
||||
|
||||
res = wally_tx_get_length(tx->wtx, flag, &len);
|
||||
if (is_elements)
|
||||
flag |= WALLY_TX_FLAG_USE_ELEMENTS;
|
||||
|
||||
res = wally_tx_get_length(tx->wtx, flag & WALLY_TX_FLAG_USE_WITNESS, &len);
|
||||
assert(res == WALLY_OK);
|
||||
serialized = tal_arr(tmpctx, u8, len);
|
||||
|
||||
|
@ -654,6 +654,9 @@ static void topo_add_utxos(struct chain_topology *topo, struct block *b)
|
||||
for (size_t i = 0; i < tal_count(b->full_txs); i++) {
|
||||
const struct bitcoin_tx *tx = b->full_txs[i];
|
||||
for (size_t j = 0; j < tx->wtx->num_outputs; j++) {
|
||||
if (tx->wtx->outputs[j].features & WALLY_TX_IS_COINBASE)
|
||||
continue;
|
||||
|
||||
const u8 *script = bitcoin_tx_output_get_script(tmpctx, tx, j);
|
||||
struct amount_sat amt = bitcoin_tx_output_get_amount(tx, j);
|
||||
|
||||
|
@ -103,6 +103,9 @@ bool txfilter_match(const struct txfilter *filter, const struct bitcoin_tx *tx)
|
||||
for (size_t i = 0; i < tx->wtx->num_outputs; i++) {
|
||||
const u8 *oscript = bitcoin_tx_output_get_script(tmpctx, tx, i);
|
||||
|
||||
if (!oscript)
|
||||
continue;
|
||||
|
||||
if (scriptpubkeyset_get(&filter->scriptpubkeyset, oscript))
|
||||
return true;
|
||||
}
|
||||
|
@ -1498,11 +1498,13 @@ int wallet_extract_owned_outputs(struct wallet *w, const struct bitcoin_tx *tx,
|
||||
struct utxo *utxo;
|
||||
u32 index;
|
||||
bool is_p2sh;
|
||||
const u8 *script = bitcoin_tx_output_get_script(tmpctx, tx, output);
|
||||
const u8 *script;
|
||||
|
||||
script = bitcoin_tx_output_get_script(tmpctx, tx, output);
|
||||
if (!script)
|
||||
continue;
|
||||
|
||||
if (!wallet_can_spend(w, script, &index,
|
||||
&is_p2sh))
|
||||
if (!wallet_can_spend(w, script, &index, &is_p2sh))
|
||||
continue;
|
||||
|
||||
utxo = tal(w, struct utxo);
|
||||
|
Loading…
Reference in New Issue
Block a user