Update README to refer to pages/blog.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Require that unused transaction input field be 0.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Transaction comparison should be done by input, not output.

It's something of an arbitrary choice, but I'm thinking of allowing
multiple different inputs from the same shard (with multiple outputs,
this would allow coinjoin), so change this now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Note that genesis generation is stupid.

It should be just a block, with nonce set to "lower bytes of SHA of
bitcoin block N".

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
PROTOCOL_ERROR_UNKNOWN_PREV is a private error.

We can't return this error over the wire, so rename it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Move error codes to their own header.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rename unmarshall_block to unmarshall_block_into.

marshall_block creates a packet, whereas marshall_block_into marshalls
in-place.  I wrote a test expected unmarshall_block to be the reverse
of marshall_block, not marshall_block_into.

Create unmarshall_block which takes a packet (which is what almost
everyone wants), and rename the current one to unmarshall_block_into.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
create_refs()

Haul this out of pending.c: we want it for testing. 

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Express shards as an order, not a number.

This lets us have up to 2^16 shards, and simplifies things a little.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Add depth field to header.

Since we're about to tear apart the header, fix this FIXME now.

Otherwise we can fake our SPV-style skip proofs to make the horizon seem
further (ie. insert our own blocks in the middle of the real chain).

Mainly done using this patch.cocci:

@ rule1 @
struct block *b;
@@

- b->blocknum
+ le32_to_cpu(b->hdr->depth)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Major rework: group transactions explicitly by shards, not batches.

We currently group transactions into 256-tx batches; each batch is
merkled together into a top-level hash.

Now we have up to 255 transactions in each shard, and each shard is
merkled into a top-level hash.  In fact, the term "batch" goes away.

So, to begin with, there are 4 transaction hashes in each block header
(they're there even if a shard is empty).  When the network grows
this will double, etc.  There's also an 8 bit counter for the number
of transactions in each shard.

This should make network transmission simpler: you know that you need
the transactions in shard N of a batch if you're interested in an
address in N.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
patch enhance-sizes.patch
Remove unused create_proof.c

This was from when we were going to create proofs of a transactions'
entire history.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Separate packet allocation functions from packet io functions.

Makes unit testing easier by untangling dependencies.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Make minimal log do minimal helpers too.

Makes unit testing easier by untangling dependencies.  inject.c
needs to manually printf the hash now, but it should have anyway.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Inline shard_full(), block_get_tx(), block_preceeds(), block_ancestor()

More dependency untangling, though I hate inlines.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Fix shard_of()

If we want them to sort correctly with a simple memcmp, the most
obvious thing is to use the upper bits of an address as the shard.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Make mkpriv generate by name.

For regenerating test/helper_key.c.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Compile ccan/err/err.c

This is a noop if you have <err.h>, but let's not break weird platforms
deliberately.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Refresh tests.

After so much churn, they're basically being rewritten.  Since I
broke everything with my recent rewrite, that was sufficient
motivation to blow the cobwebs off.

I also added one.  Many more to go!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>