mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
Make an explicit bitcoin_txid() call.
Neater than open-coding it. We still need the raw version for signatures though. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
07c7214edb
commit
393400fa39
5
anchor.c
5
anchor.c
@ -97,7 +97,6 @@ void anchor_txid(struct bitcoin_tx *anchor,
|
||||
Pkt *p1, *p2;
|
||||
LeakAnchorSigsAndPretendWeDidnt *leak1, *leak2;
|
||||
size_t i;
|
||||
struct sha256_ctx shactx;
|
||||
|
||||
p1 = pkt_from_file(leakfile1, PKT__PKT_OMG_FAIL);
|
||||
p2 = pkt_from_file(leakfile2, PKT__PKT_OMG_FAIL);
|
||||
@ -121,9 +120,7 @@ void anchor_txid(struct bitcoin_tx *anchor,
|
||||
= leak2->sigs->script[i].len;
|
||||
}
|
||||
|
||||
sha256_init(&shactx);
|
||||
sha256_tx(&shactx, anchor);
|
||||
sha256_double_done(&shactx, txid);
|
||||
bitcoin_txid(anchor, txid);
|
||||
|
||||
pkt__free_unpacked(p1, NULL);
|
||||
pkt__free_unpacked(p2, NULL);
|
||||
|
@ -64,6 +64,14 @@ void sha256_tx(struct sha256_ctx *ctx, const struct bitcoin_tx *tx)
|
||||
sha256_le32(ctx, tx->lock_time);
|
||||
}
|
||||
|
||||
void bitcoin_txid(const struct bitcoin_tx *tx, struct sha256_double *txid)
|
||||
{
|
||||
struct sha256_ctx ctx = SHA256_INIT;
|
||||
|
||||
sha256_tx(&ctx, tx);
|
||||
sha256_double_done(&ctx, txid);
|
||||
}
|
||||
|
||||
struct bitcoin_tx *bitcoin_tx(const tal_t *ctx, varint_t input_count,
|
||||
varint_t output_count)
|
||||
{
|
||||
|
@ -32,9 +32,12 @@ struct bitcoin_tx_input {
|
||||
u32 sequence_number;
|
||||
};
|
||||
|
||||
/* Linearize the tx. This is good for deriving the txid, as well as the
|
||||
* signature. */
|
||||
void sha256_tx(struct sha256_ctx *shactx, const struct bitcoin_tx *tx);
|
||||
|
||||
/* SHA256^2 the tx: simpler than sha256_tx */
|
||||
void bitcoin_txid(const struct bitcoin_tx *tx, struct sha256_double *txid);
|
||||
|
||||
/* Useful for signature code. */
|
||||
void sha256_tx(struct sha256_ctx *ctx, const struct bitcoin_tx *tx);
|
||||
|
||||
/* Allocate a tx: you just need to fill in inputs and outputs (they're
|
||||
* zeroed with inputs' sequence_number set to FFFFFFFF) */
|
||||
|
Loading…
Reference in New Issue
Block a user