channel_state: encapsulate funding of channel in one place.

This shows where funds are going at any time (fees vs to each side).
funding.c is mainly rewritten, and should be clearer now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2015-08-07 12:45:30 +09:30
parent cf3433a0ad
commit a4dfe3ad72
16 changed files with 200 additions and 150 deletions

View File

@@ -35,7 +35,7 @@ int main(int argc, char *argv[])
u8 *redeemscript;
struct sha256 rhash;
size_t p2sh_out;
u64 fee = 10000, our_amount, their_amount;
u64 fee = 10000;
u32 locktime;
err_set_progname(argv[0]);
@@ -82,9 +82,8 @@ int main(int argc, char *argv[])
errx(1, "Invalid o2 final pubkey");
/* We use this simply to get final revocation hash. */
gather_updates(o1, o2, a, commit_fee(o1, o2), argv + 7,
&our_amount, &their_amount,
&rhash, NULL, NULL);
gather_updates(ctx, o1, o2, a, commit_fee(o1, o2), argv + 7,
NULL, &rhash, NULL, NULL);
/* Create redeem script */
redeemscript = bitcoin_redeem_secret_or_delay(ctx, &pubkey1, locktime,