diff --git a/lightningd/closing/closing.c b/lightningd/closing/closing.c index 8d11546e5..0671e598e 100644 --- a/lightningd/closing/closing.c +++ b/lightningd/closing/closing.c @@ -41,6 +41,9 @@ static struct bitcoin_tx *close_tx(const tal_t *ctx, fee, satoshi_out[LOCAL], satoshi_out[REMOTE]); + status_trace("Making close tx at = %"PRIu64"/%"PRIu64" fee %"PRIu64, + satoshi_out[LOCAL], satoshi_out[REMOTE], fee); + tx = create_close_tx(ctx, scriptpubkey[LOCAL], scriptpubkey[REMOTE], funding_txid, funding_txout, @@ -50,7 +53,17 @@ static struct bitcoin_tx *close_tx(const tal_t *ctx, dust_limit); if (!tx) status_failed(WIRE_CLOSING_NEGOTIATION_ERROR, - "Both outputs below dust limit"); + "Both outputs below dust limit:" + " funding = %"PRIu64 + " fee = %"PRIu64 + " dust_limit = %"PRIu64 + " LOCAL = %"PRIu64 + " REMOTE = %"PRIu64, + funding_satoshi, + fee, + dust_limit, + satoshi_out[LOCAL], + satoshi_out[REMOTE]); return tx; } @@ -185,6 +198,10 @@ int main(int argc, char *argv[]) status_failed(WIRE_CLOSING_PEER_BAD_MESSAGE, "Bad init message %s", tal_hex(ctx, msg)); } + status_trace("satoshi_out = %"PRIu64"/%"PRIu64, + satoshi_out[LOCAL], satoshi_out[REMOTE]); + status_trace("dustlimit = %"PRIu64, our_dust_limit); + status_trace("fee = %"PRIu64, sent_fee); derive_channel_id(&channel_id, &funding_txid, funding_txout); derive_basepoints(&seed, &funding_pubkey[LOCAL], NULL, &secrets, NULL); @@ -225,9 +242,6 @@ int main(int argc, char *argv[]) funding_txout, funding_satoshi, satoshi_out, funder, sent_fee, our_dust_limit); - if (!tx) - status_failed(WIRE_CLOSING_NEGOTIATION_ERROR, - "Both outputs below dust limit"); /* BOLT #2: * diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index e0d909a20..7e4bc8556 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -1551,12 +1551,16 @@ static bool peer_start_channeld(struct peer *peer, const u8 *shutdown_scriptpubkey; /* Now we can consider balance set. */ - peer->our_msatoshi = tal(peer, u64); - if (peer->funder == LOCAL) - *peer->our_msatoshi - = peer->funding_satoshi * 1000 - peer->push_msat; - else - *peer->our_msatoshi = peer->push_msat; + if (!reconnected) { + assert(!peer->our_msatoshi); + peer->our_msatoshi = tal(peer, u64); + if (peer->funder == LOCAL) + *peer->our_msatoshi + = peer->funding_satoshi * 1000 - peer->push_msat; + else + *peer->our_msatoshi = peer->push_msat; + } else + assert(peer->our_msatoshi); msg = towire_hsmctl_hsmfd_channeld(tmpctx, peer->unique_id); if (!wire_sync_write(peer->ld->hsm_fd, take(msg)))