#include "config.h"
#include <assert.h>
#include <bitcoin/privkey.c>
#include <bitcoin/pubkey.c>
#include <bitcoin/script.c>
#include <bitcoin/shadouble.c>
#include <bitcoin/signature.c>
#include <bitcoin/tx.c>
#include <bitcoin/varint.c>
#include <ccan/str/hex/hex.h>
#include <common/setup.h>
#include <common/utils.h>
#include <stdio.h>

/* AUTOGENERATED MOCKS START */
/* AUTOGENERATED MOCKS END */

int main(int argc, const char *argv[])
{
	struct privkey p;
	struct pubkey pub;
	struct bitcoin_signature sig;
	struct sha256_double h;
	u8 **wit;
	size_t weight;

	common_setup(argv[0]);
	chainparams = chainparams_for_network("bitcoin");

	memset(&h, 0, sizeof(h));
	memset(&p, 1, sizeof(p));
	sign_hash(&p, &h, &sig.s);
	sig.sighash_type = SIGHASH_ALL;
	pubkey_from_privkey(&p, &pub);

	wit = bitcoin_witness_2of2(tmpctx, &sig, &sig, &pub, &pub);

	/* 1 byte for num witnesses, one per witness element */
	weight = 1;

	/* Two signatures, slightly overestimated to be 73 bytes each,
	 * while the actual witness will often be smaller.*/
        /* BOLT #03:
         * Signatures are 73 bytes long (the maximum length).
         */
	weight += 2 + 2;

	for (size_t i = 0; i < tal_count(wit); i++)
		weight += 1 + tal_bytelen(wit[i]);
	assert(bitcoin_tx_2of2_input_witness_weight() == weight);

	common_shutdown();
	return 0;
}
