The previous code was very tied to the old daemon, so this copies a large part of it. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>