reward: fix reward modulus calculation.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
pettycoin-generate: seperate out make_shard_pkt function for easier testing.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
inputhash: fix use-after-free which allowed doublespend (Fixes #34)

When we freed a pending tx, we freed the hash entries for the input
hash.  We manage those hash entries manually, since they're shared by
any number of txs (on separate chains).

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