Add fee of 3/1024ths of total amount of tx.

You can opt out of the fee, but miners may not accept it (see next patch).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Implement --require-fees and --require-gateway-fees.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Don't assert() if an input is too close to horizon.

When resolving inputs, we don't care about how old the transaction is:
this is done by create_refs().  So it can fail, and we have to handle it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Define reward period, and ban 0-satoshi transactions.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Add two missing files.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Unify creation of tx_in_block packets.

And fix two bugs:
1) We sent the wrong packet for send_tx_in_block_to_peers.
2) We derefed a NULL pointer calling tal_packet_append_pos() in recv_get_tx_in_block() if we didn't know block.

And rename block_pkt to pkt_block to match naming convention.

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

After several false starts, I settled on the simplest solution: a new
transaction which has a special input to reflect the "randomly" selected
transaction within a block which is the basis for the reward.

The next patch will implement support for complaints when a TX_CLAIM
transaction is invalid.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Complaint handling for TX_CLAIM.

We need to know the location of the reward tx (claim input), not just
its contents, so this is slightly different to the various normal tx
complaints.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Move complaint reception out to separate file.

And simplify packet functions.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
PROTOCOL_PKT_PEERS support, and peer_cache cleanup.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
netaddr: fix subtle bug in get_fd_addr.

Interestingly, getsockname doesn't *fail* if len is too short.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
PROTOCOL_PKT_GET_PEERS: get peers from network.

We currently only do this when we first connect, but we should probably
be more regular.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Add JSON parsing from stdin.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Add --rpc option to allow connection to JSON-RPC.

socat works well for this on Unix:
	socat - UNIX-CONNECT:/tmp/rpc

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
pettycoin_query: tool to query a running pettycoin.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Neaten up JSON support.

Share code between pettycoin's JSON RPC and pettycoin_query.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rename --rpc to --rpc-file, make default pettycoin-rpc, full async.

Also do some pretty-printing of results.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
More json-rpc shuffling.

Expose structure to callbacks, since they'll need it if they want to
do notifications or tal() off it.

Allow injection of new outputs (required for notification).

Rename 'echo' to 'dev-echo'.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Allow base58 decode on unterminated strings.

Required for handling json tokens.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
tal_arr: helpers for managing arrays of pointers.

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