mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-22 00:24:19 +01:00
lightningd: don't reset balance when we reconnect!
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -41,6 +41,9 @@ static struct bitcoin_tx *close_tx(const tal_t *ctx,
|
|||||||
fee, satoshi_out[LOCAL],
|
fee, satoshi_out[LOCAL],
|
||||||
satoshi_out[REMOTE]);
|
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],
|
tx = create_close_tx(ctx, scriptpubkey[LOCAL], scriptpubkey[REMOTE],
|
||||||
funding_txid,
|
funding_txid,
|
||||||
funding_txout,
|
funding_txout,
|
||||||
@@ -50,7 +53,17 @@ static struct bitcoin_tx *close_tx(const tal_t *ctx,
|
|||||||
dust_limit);
|
dust_limit);
|
||||||
if (!tx)
|
if (!tx)
|
||||||
status_failed(WIRE_CLOSING_NEGOTIATION_ERROR,
|
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;
|
return tx;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,6 +198,10 @@ int main(int argc, char *argv[])
|
|||||||
status_failed(WIRE_CLOSING_PEER_BAD_MESSAGE,
|
status_failed(WIRE_CLOSING_PEER_BAD_MESSAGE,
|
||||||
"Bad init message %s", tal_hex(ctx, msg));
|
"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_channel_id(&channel_id, &funding_txid, funding_txout);
|
||||||
derive_basepoints(&seed, &funding_pubkey[LOCAL], NULL,
|
derive_basepoints(&seed, &funding_pubkey[LOCAL], NULL,
|
||||||
&secrets, NULL);
|
&secrets, NULL);
|
||||||
@@ -225,9 +242,6 @@ int main(int argc, char *argv[])
|
|||||||
funding_txout,
|
funding_txout,
|
||||||
funding_satoshi,
|
funding_satoshi,
|
||||||
satoshi_out, funder, sent_fee, our_dust_limit);
|
satoshi_out, funder, sent_fee, our_dust_limit);
|
||||||
if (!tx)
|
|
||||||
status_failed(WIRE_CLOSING_NEGOTIATION_ERROR,
|
|
||||||
"Both outputs below dust limit");
|
|
||||||
|
|
||||||
/* BOLT #2:
|
/* BOLT #2:
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1551,12 +1551,16 @@ static bool peer_start_channeld(struct peer *peer,
|
|||||||
const u8 *shutdown_scriptpubkey;
|
const u8 *shutdown_scriptpubkey;
|
||||||
|
|
||||||
/* Now we can consider balance set. */
|
/* Now we can consider balance set. */
|
||||||
|
if (!reconnected) {
|
||||||
|
assert(!peer->our_msatoshi);
|
||||||
peer->our_msatoshi = tal(peer, u64);
|
peer->our_msatoshi = tal(peer, u64);
|
||||||
if (peer->funder == LOCAL)
|
if (peer->funder == LOCAL)
|
||||||
*peer->our_msatoshi
|
*peer->our_msatoshi
|
||||||
= peer->funding_satoshi * 1000 - peer->push_msat;
|
= peer->funding_satoshi * 1000 - peer->push_msat;
|
||||||
else
|
else
|
||||||
*peer->our_msatoshi = peer->push_msat;
|
*peer->our_msatoshi = peer->push_msat;
|
||||||
|
} else
|
||||||
|
assert(peer->our_msatoshi);
|
||||||
|
|
||||||
msg = towire_hsmctl_hsmfd_channeld(tmpctx, peer->unique_id);
|
msg = towire_hsmctl_hsmfd_channeld(tmpctx, peer->unique_id);
|
||||||
if (!wire_sync_write(peer->ld->hsm_fd, take(msg)))
|
if (!wire_sync_write(peer->ld->hsm_fd, take(msg)))
|
||||||
|
|||||||
Reference in New Issue
Block a user