mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
lightningd/peer_control.c: rename peer->balance.
I made the mistake of thinking it was a [NUM_SIDES] array, but it's actually our balance, and it's in millisatoshi. Rename for clarity. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
4223a91842
commit
c1f21b9fce
@ -451,7 +451,7 @@ void add_peer(struct lightningd *ld, u64 unique_id,
|
|||||||
peer->remote_funding_locked = false;
|
peer->remote_funding_locked = false;
|
||||||
peer->scid = NULL;
|
peer->scid = NULL;
|
||||||
peer->seed = NULL;
|
peer->seed = NULL;
|
||||||
peer->balance = NULL;
|
peer->our_msatoshi = NULL;
|
||||||
peer->state = UNINITIALIZED;
|
peer->state = UNINITIALIZED;
|
||||||
peer->channel_info = NULL;
|
peer->channel_info = NULL;
|
||||||
peer->last_was_revoke = false;
|
peer->last_was_revoke = false;
|
||||||
@ -749,8 +749,9 @@ static void json_getpeers(struct command *cmd,
|
|||||||
json_add_string(response, "owner", p->owner->name);
|
json_add_string(response, "owner", p->owner->name);
|
||||||
if (p->scid)
|
if (p->scid)
|
||||||
json_add_short_channel_id(response, "channel", p->scid);
|
json_add_short_channel_id(response, "channel", p->scid);
|
||||||
if (p->balance) {
|
if (p->our_msatoshi) {
|
||||||
json_add_u64(response, "msatoshi_to_us", *p->balance);
|
json_add_u64(response, "msatoshi_to_us",
|
||||||
|
*p->our_msatoshi);
|
||||||
json_add_u64(response, "msatoshi_total",
|
json_add_u64(response, "msatoshi_total",
|
||||||
p->funding_satoshi * 1000);
|
p->funding_satoshi * 1000);
|
||||||
}
|
}
|
||||||
@ -1258,8 +1259,8 @@ static int peer_closing_complete(struct peer *peer, const u8 *msg)
|
|||||||
*
|
*
|
||||||
* The amounts for each output MUST BE rounded down to whole satoshis.
|
* The amounts for each output MUST BE rounded down to whole satoshis.
|
||||||
*/
|
*/
|
||||||
out_amounts[LOCAL] = *peer->balance / 1000;
|
out_amounts[LOCAL] = *peer->our_msatoshi / 1000;
|
||||||
out_amounts[REMOTE] = peer->funding_satoshi - *peer->balance / 1000;
|
out_amounts[REMOTE] = peer->funding_satoshi - *peer->our_msatoshi / 1000;
|
||||||
out_amounts[peer->funder] -= peer->closing_fee_received;
|
out_amounts[peer->funder] -= peer->closing_fee_received;
|
||||||
|
|
||||||
derive_basepoints(peer->seed, &local_funding_pubkey, NULL, NULL, NULL);
|
derive_basepoints(peer->seed, &local_funding_pubkey, NULL, NULL, NULL);
|
||||||
@ -1391,9 +1392,9 @@ static void peer_start_closingd(struct peer *peer,
|
|||||||
peer->funding_satoshi,
|
peer->funding_satoshi,
|
||||||
&peer->channel_info->remote_fundingkey,
|
&peer->channel_info->remote_fundingkey,
|
||||||
peer->funder,
|
peer->funder,
|
||||||
*peer->balance / 1000,
|
*peer->our_msatoshi / 1000,
|
||||||
peer->funding_satoshi
|
peer->funding_satoshi
|
||||||
- *peer->balance / 1000,
|
- *peer->our_msatoshi / 1000,
|
||||||
peer->our_config.dust_limit_satoshis,
|
peer->our_config.dust_limit_satoshis,
|
||||||
minfee, maxfee, startfee,
|
minfee, maxfee, startfee,
|
||||||
local_scriptpubkey,
|
local_scriptpubkey,
|
||||||
@ -1510,11 +1511,12 @@ 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. */
|
||||||
peer->balance = tal(peer, u64);
|
peer->our_msatoshi = tal(peer, u64);
|
||||||
if (peer->funder == LOCAL)
|
if (peer->funder == LOCAL)
|
||||||
*peer->balance = peer->funding_satoshi * 1000 - peer->push_msat;
|
*peer->our_msatoshi
|
||||||
|
= peer->funding_satoshi * 1000 - peer->push_msat;
|
||||||
else
|
else
|
||||||
*peer->balance = peer->push_msat;
|
*peer->our_msatoshi = peer->push_msat;
|
||||||
|
|
||||||
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)))
|
||||||
@ -1580,7 +1582,7 @@ static bool peer_start_channeld(struct peer *peer,
|
|||||||
peer->funder,
|
peer->funder,
|
||||||
cfg->fee_base,
|
cfg->fee_base,
|
||||||
cfg->fee_per_satoshi,
|
cfg->fee_per_satoshi,
|
||||||
*peer->balance,
|
*peer->our_msatoshi,
|
||||||
peer->seed,
|
peer->seed,
|
||||||
&peer->ld->dstate.id,
|
&peer->ld->dstate.id,
|
||||||
&peer->id,
|
&peer->id,
|
||||||
|
@ -73,7 +73,7 @@ struct peer {
|
|||||||
struct short_channel_id *scid;
|
struct short_channel_id *scid;
|
||||||
|
|
||||||
/* Amount going to us, not counting unfinished HTLCs; if we have one. */
|
/* Amount going to us, not counting unfinished HTLCs; if we have one. */
|
||||||
u64 *balance;
|
u64 *our_msatoshi;
|
||||||
|
|
||||||
/* Keys for channel. */
|
/* Keys for channel. */
|
||||||
struct channel_info *channel_info;
|
struct channel_info *channel_info;
|
||||||
|
@ -747,9 +747,9 @@ static void remove_htlc_in(struct peer *peer, struct htlc_in *hin)
|
|||||||
/* If we fulfilled their HTLC, credit us. */
|
/* If we fulfilled their HTLC, credit us. */
|
||||||
if (hin->preimage) {
|
if (hin->preimage) {
|
||||||
log_debug(peer->log, "Balance %"PRIu64" -> %"PRIu64,
|
log_debug(peer->log, "Balance %"PRIu64" -> %"PRIu64,
|
||||||
*peer->balance,
|
*peer->our_msatoshi,
|
||||||
*peer->balance + hin->msatoshi);
|
*peer->our_msatoshi + hin->msatoshi);
|
||||||
*peer->balance += hin->msatoshi;
|
*peer->our_msatoshi += hin->msatoshi;
|
||||||
}
|
}
|
||||||
|
|
||||||
tal_free(hin);
|
tal_free(hin);
|
||||||
@ -770,7 +770,10 @@ static void remove_htlc_out(struct peer *peer, struct htlc_out *hout)
|
|||||||
fail_out_htlc(hout, NULL);
|
fail_out_htlc(hout, NULL);
|
||||||
} else {
|
} else {
|
||||||
/* We paid for this HTLC, so deduct balance. */
|
/* We paid for this HTLC, so deduct balance. */
|
||||||
*peer->balance -= hout->msatoshi;
|
log_debug(peer->log, "Balance %"PRIu64" -> %"PRIu64,
|
||||||
|
*peer->our_msatoshi,
|
||||||
|
*peer->our_msatoshi - hout->msatoshi);
|
||||||
|
*peer->our_msatoshi -= hout->msatoshi;
|
||||||
}
|
}
|
||||||
|
|
||||||
tal_free(hout);
|
tal_free(hout);
|
||||||
|
Loading…
Reference in New Issue
Block a user