This is the most complex one. It gets its own commit. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>