funding: remove protobufs.

Use our own structure with the information we need about HTLCs,
and remove protobufs from the API.

The is_funder() helper goes inside gather_updates.h.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2016-01-22 06:41:47 +10:30
parent d95d8a99c2
commit 6d6abd57e7
13 changed files with 188 additions and 106 deletions

View File

@@ -15,6 +15,7 @@
#include "bitcoin/privkey.h"
#include "protobuf_convert.h"
#include "funding.h"
#include "gather_updates.h"
#include "version.h"
#include <unistd.h>
@@ -70,9 +71,14 @@ int main(int argc, char *argv[])
if (!proto_to_pubkey(o2->commit_key, &pubkey2))
errx(1, "Invalid o2 commit_key");
cstate = initial_funding(ctx, o1, o2, a, commit_fee(o1, o2));
if (is_funder(o1) == is_funder(o2))
errx(1, "Must be exactly one funder");
cstate = initial_funding(ctx, is_funder(o1), a->amount,
commit_fee(o1->commitment_fee,
o2->commitment_fee));
if (!cstate)
errx(1, "Invalid open combination (need 1 anchor offer)");
errx(1, "Invalid open combination (need to cover fees)");
/* Now create our commitment tx. */
proto_to_sha256(o1->revocation_hash, &rhash);