Browse Source

closingd: update billboard as negotiation proceeds.

We use the permanent slot to indicate our overall negotiation range,
and the transient slot to say what we're waiting for.

On success, we update the permanent slot to indicate the final value.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
committed by Christian Decker
parent
commit
c57aa628e3
  1. 21
      closingd/closing.c
  2. 7
      onchaind/onchain.c

21
closingd/closing.c

@ -6,6 +6,7 @@
#include <common/crypto_sync.h>
#include <common/derive_basepoints.h>
#include <common/htlc.h>
#include <common/peer_billboard.h>
#include <common/peer_failed.h>
#include <common/read_peer_msg.h>
#include <common/status.h>
@ -497,6 +498,10 @@ int main(int argc, char *argv[])
do_reconnect(&cs, gossip_index, &channel_id,
next_index, revocations_received);
peer_billboard(true, "Negotiating closing fee between %"PRIu64
" and %"PRIu64" satoshi (ideal %"PRIu64")",
min_fee_to_accept, commitment_fee, offer[LOCAL]);
/* BOLT #2:
*
* The funding node:
@ -514,6 +519,14 @@ int main(int argc, char *argv[])
funding_satoshi, satoshi_out, funder,
our_dust_limit, &secrets, offer[LOCAL]);
} else {
if (i == 0)
peer_billboard(false, "Waiting for their initial"
" closing fee offer");
else
peer_billboard(false, "Waiting for their initial"
" closing fee offer:"
" ours was %"PRIu64" satoshi",
offer[LOCAL]);
offer[REMOTE]
= receive_offer(&cs, gossip_index,
&channel_id, funding_pubkey,
@ -554,6 +567,11 @@ int main(int argc, char *argv[])
funding_satoshi, satoshi_out, funder,
our_dust_limit, &secrets, offer[LOCAL]);
} else {
peer_billboard(false, "Waiting for another"
" closing fee offer:"
" ours was %"PRIu64" satoshi,"
" theirs was %"PRIu64" satoshi,",
offer[LOCAL], offer[REMOTE]);
offer[REMOTE]
= receive_offer(&cs, gossip_index, &channel_id,
funding_pubkey,
@ -566,6 +584,9 @@ int main(int argc, char *argv[])
}
}
peer_billboard(true, "We agreed on a closing fee of %"PRIu64" satoshi",
offer[LOCAL]);
/* We're done! */
wire_sync_write(REQ_FD,
take(towire_closing_complete(ctx, gossip_index)));

7
onchaind/onchain.c

@ -76,6 +76,8 @@ struct tracked_output {
enum tx_type tx_type;
struct bitcoin_txid txid;
u32 tx_blockheight;
/* FIXME: Convert all depths to blocknums, then just get new blk msgs */
u32 depth;
u32 outnum;
u64 satoshi;
enum output_type output_type;
@ -278,6 +280,7 @@ static struct tracked_output *
out->tx_type = tx_type;
out->txid = *txid;
out->tx_blockheight = tx_blockheight;
out->depth = 0;
out->outnum = outnum;
out->satoshi = satoshi;
out->output_type = output_type;
@ -810,6 +813,10 @@ static void tx_new_depth(struct tracked_output **outs,
}
for (i = 0; i < tal_count(outs); i++) {
/* Update output depth. */
if (structeq(&outs[i]->txid, txid))
outs[i]->depth = depth;
/* Is this tx resolving an output? */
if (outs[i]->resolved) {
if (structeq(&outs[i]->resolved->txid, txid)) {

Loading…
Cancel
Save