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>
This commit is contained in:
Rusty Russell 2018-02-23 16:23:47 +10:30 committed by Christian Decker
parent 8640a5c329
commit c57aa628e3
2 changed files with 28 additions and 0 deletions

View File

@ -6,6 +6,7 @@
#include <common/crypto_sync.h> #include <common/crypto_sync.h>
#include <common/derive_basepoints.h> #include <common/derive_basepoints.h>
#include <common/htlc.h> #include <common/htlc.h>
#include <common/peer_billboard.h>
#include <common/peer_failed.h> #include <common/peer_failed.h>
#include <common/read_peer_msg.h> #include <common/read_peer_msg.h>
#include <common/status.h> #include <common/status.h>
@ -497,6 +498,10 @@ int main(int argc, char *argv[])
do_reconnect(&cs, gossip_index, &channel_id, do_reconnect(&cs, gossip_index, &channel_id,
next_index, revocations_received); 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: /* BOLT #2:
* *
* The funding node: * The funding node:
@ -514,6 +519,14 @@ int main(int argc, char *argv[])
funding_satoshi, satoshi_out, funder, funding_satoshi, satoshi_out, funder,
our_dust_limit, &secrets, offer[LOCAL]); our_dust_limit, &secrets, offer[LOCAL]);
} else { } 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] offer[REMOTE]
= receive_offer(&cs, gossip_index, = receive_offer(&cs, gossip_index,
&channel_id, funding_pubkey, &channel_id, funding_pubkey,
@ -554,6 +567,11 @@ int main(int argc, char *argv[])
funding_satoshi, satoshi_out, funder, funding_satoshi, satoshi_out, funder,
our_dust_limit, &secrets, offer[LOCAL]); our_dust_limit, &secrets, offer[LOCAL]);
} else { } else {
peer_billboard(false, "Waiting for another"
" closing fee offer:"
" ours was %"PRIu64" satoshi,"
" theirs was %"PRIu64" satoshi,",
offer[LOCAL], offer[REMOTE]);
offer[REMOTE] offer[REMOTE]
= receive_offer(&cs, gossip_index, &channel_id, = receive_offer(&cs, gossip_index, &channel_id,
funding_pubkey, 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! */ /* We're done! */
wire_sync_write(REQ_FD, wire_sync_write(REQ_FD,
take(towire_closing_complete(ctx, gossip_index))); take(towire_closing_complete(ctx, gossip_index)));

View File

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