mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 09:54:16 +01:00
Remove txid normalization.
Since any transaction with all segregated-witness inputs is non-malleable, and all our transactions are that, we can remove normalized txids. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
7ac29241ee
commit
f24b73124a
@ -414,23 +414,6 @@ void bitcoind_getblockhash_(struct lightningd_state *dstate,
|
||||
"getblockhash", str, NULL);
|
||||
}
|
||||
|
||||
/* FIXME: Seg witness removes need for this! */
|
||||
void normalized_txid(const struct bitcoin_tx *tx, struct sha256_double *txid)
|
||||
{
|
||||
size_t i;
|
||||
struct bitcoin_tx tx_copy = *tx;
|
||||
struct bitcoin_tx_input input_copy[tx->input_count];
|
||||
|
||||
/* Copy inputs, but scripts are 0 length. */
|
||||
for (i = 0; i < tx_copy.input_count; i++) {
|
||||
input_copy[i] = tx->input[i];
|
||||
input_copy[i].script_length = 0;
|
||||
}
|
||||
tx_copy.input = input_copy;
|
||||
|
||||
bitcoin_txid(&tx_copy, txid);
|
||||
}
|
||||
|
||||
/* Make testnet/regtest status matches us. */
|
||||
void check_bitcoind_config(struct lightningd_state *dstate)
|
||||
{
|
||||
|
@ -87,7 +87,5 @@ void bitcoind_getrawblock_(struct lightningd_state *dstate,
|
||||
struct bitcoin_block *), \
|
||||
(arg))
|
||||
|
||||
void normalized_txid(const struct bitcoin_tx *tx, struct sha256_double *txid);
|
||||
|
||||
void check_bitcoind_config(struct lightningd_state *dstate);
|
||||
#endif /* LIGHTNING_DAEMON_BITCOIND_H */
|
||||
|
@ -152,12 +152,8 @@ static void connect_blocks(struct lightningd_state *dstate, struct block *b)
|
||||
}
|
||||
|
||||
/* We do spends first, in case that tells us to watch tx. */
|
||||
normalized_txid(tx, &txid);
|
||||
bitcoin_txid(tx, &txid);
|
||||
w = txwatch_hash_get(&dstate->txwatches, &txid);
|
||||
if (!w) {
|
||||
bitcoin_txid(tx, &txid);
|
||||
w = txwatch_hash_get(&dstate->txwatches, &txid);
|
||||
}
|
||||
if (w) {
|
||||
add_tx_to_block(b, w);
|
||||
/* Fire if it's the first we've seen it: this might
|
||||
|
@ -876,7 +876,7 @@ static void watch_commit_outputs(struct peer *peer, const struct bitcoin_tx *tx)
|
||||
varint_t i;
|
||||
struct sha256_double txid;
|
||||
|
||||
normalized_txid(tx, &txid);
|
||||
bitcoin_txid(tx, &txid);
|
||||
for (i = 0; i < tx->output_count; i++) {
|
||||
watch_txo(peer, peer, &txid, i, our_commit_spent,
|
||||
peer->us.commit);
|
||||
|
@ -116,7 +116,7 @@ struct txwatch *watch_tx_(const tal_t *ctx,
|
||||
{
|
||||
struct sha256_double txid;
|
||||
|
||||
normalized_txid(tx, &txid);
|
||||
bitcoin_txid(tx, &txid);
|
||||
return watch_txid(ctx, peer, &txid, cb, cb_arg);
|
||||
}
|
||||
|
||||
|
@ -114,9 +114,6 @@ struct txowatch *watch_txo_(const tal_t *ctx,
|
||||
const struct bitcoin_tx *), \
|
||||
(cbdata))
|
||||
|
||||
/* FIXME: Seg witness removes need for this! */
|
||||
void normalized_txid(const struct bitcoin_tx *tx, struct sha256_double *txid);
|
||||
|
||||
void txwatch_fire(struct lightningd_state *dstate,
|
||||
struct txwatch *txw,
|
||||
unsigned int depth);
|
||||
|
Loading…
Reference in New Issue
Block a user