Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
@ -8,6 +8,11 @@
#include "pkt.h"
#include "protobuf_convert.h"
size_t pkt_totlen(const struct pkt *pkt)
{
return sizeof(pkt->len) + le32_to_cpu(pkt->len);
}
static struct pkt *to_pkt(const tal_t *ctx, Pkt__PktCase type, void *msg)
struct pkt *ret;
@ -20,6 +20,9 @@ struct pkt {
Pkt *pkt_from_file(const char *filename, Pkt__PktCase expect);
Pkt *any_pkt_from_file(const char *filename);
/* Total length of packet, including header. */
size_t pkt_totlen(const struct pkt *pkt);
struct sha256;
struct bitcoin_compressed_pubkey;
struct signature;
@ -98,8 +98,7 @@ int main(int argc, char *argv[])
pkt = close_channel_complete_pkt(ctx, &sig);
else
pkt = close_channel_pkt(ctx, &sig);
if (!write_all(STDOUT_FILENO, pkt,
sizeof(pkt->len) + le32_to_cpu(pkt->len)))
if (!write_all(STDOUT_FILENO, pkt, pkt_totlen(pkt)))
err(1, "Writing out packet");
tal_free(ctx);
@ -28,8 +28,7 @@ int main(int argc, char *argv[])
->open_anchor_scriptsigs;
pkt = leak_anchor_sigs_and_pretend_we_didnt_pkt(ctx, s);
@ -95,8 +95,7 @@ int main(int argc, char *argv[])
pkt = open_anchor_sig_pkt(ctx, sigs, o1->anchor->n_inputs);
@ -174,8 +174,7 @@ int main(int argc, char *argv[])
pkt = openchannel_pkt(ctx, weak_random64(), &revocation_hash, &outkey,
commit_tx_fee, locktime_seconds, &anchor);
@ -88,8 +88,7 @@ int main(int argc, char *argv[])
privkey, &pubkey1, &sig);
pkt = open_commit_sig_pkt(ctx, &sig);
@ -106,8 +106,7 @@ int main(int argc, char *argv[])
privkey, &pubkey1, &sig.sig);
pkt = update_accept_pkt(ctx, &sig.sig, &revocation_hash);
@ -121,8 +121,7 @@ int main(int argc, char *argv[])
/* Hand over our preimage for previous tx. */
shachain_from_seed(&seed, num_updates, &preimage);
pkt = update_complete_pkt(ctx, &preimage);
@ -124,8 +124,7 @@ int main(int argc, char *argv[])
pkt = update_signature_pkt(ctx, &sig.sig, &preimage);
@ -63,8 +63,7 @@ int main(int argc, char *argv[])
revocation_hash.u.u8, sizeof(revocation_hash.u.u8));
pkt = update_pkt(ctx, &revocation_hash, this_delta);