mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 01:43:36 +01:00
common/amount: rename amount_sat_zero/amount_msat_zerp -> amount_sat_is_zero/amount_msat_is_zero.
I used `amount_msat_eq(x, AMOUNT_MSAT(0))` because I forgot this function existed. I probably missed it because the name is surprising, so add "is" in there to make it clear it's a boolean function. You'll note almost all the places which did use it are Eduardo's and Lisa's code, so maybe it's just me. Fix up a few places which I could use it, too. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
f05f871c92
commit
679f46f733
@ -2571,7 +2571,7 @@ static void add_amount_to_side(struct peer *peer,
|
||||
{
|
||||
enum tx_role role;
|
||||
|
||||
if (amount_sat_zero(amount))
|
||||
if (amount_sat_is_zero(amount))
|
||||
peer_failed_warn(peer->pps, &peer->channel_id,
|
||||
"Unable to add 0 sat fields to calculation");
|
||||
|
||||
|
@ -647,7 +647,7 @@ static enum channel_add_err add_htlc(struct channel *channel,
|
||||
* - SHOULD send a `warning` and close the connection, or send an
|
||||
* `error` and fail the channel.
|
||||
*/
|
||||
if (amount_msat_eq(htlc->amount, AMOUNT_MSAT(0))) {
|
||||
if (amount_msat_is_zero(htlc->amount)) {
|
||||
return CHANNEL_ERR_HTLC_BELOW_MINIMUM;
|
||||
}
|
||||
if (amount_msat_less(htlc->amount, channel->config[recipient].htlc_minimum)) {
|
||||
|
@ -386,12 +386,12 @@ bool amount_sat_eq(struct amount_sat a, struct amount_sat b)
|
||||
return a.satoshis == b.satoshis;
|
||||
}
|
||||
|
||||
bool amount_sat_zero(struct amount_sat a)
|
||||
bool amount_sat_is_zero(struct amount_sat a)
|
||||
{
|
||||
return a.satoshis == 0;
|
||||
}
|
||||
|
||||
bool amount_msat_zero(struct amount_msat a)
|
||||
bool amount_msat_is_zero(struct amount_msat a)
|
||||
{
|
||||
return a.millisatoshis == 0;
|
||||
}
|
||||
|
@ -115,8 +115,8 @@ bool amount_sat_eq(struct amount_sat a, struct amount_sat b);
|
||||
bool amount_msat_eq(struct amount_msat a, struct amount_msat b);
|
||||
|
||||
/* Is a zero? */
|
||||
bool amount_sat_zero(struct amount_sat a);
|
||||
bool amount_msat_zero(struct amount_msat a);
|
||||
bool amount_sat_is_zero(struct amount_sat a);
|
||||
bool amount_msat_is_zero(struct amount_msat a);
|
||||
|
||||
/* Is a > b? */
|
||||
bool amount_sat_greater(struct amount_sat a, struct amount_sat b);
|
||||
|
@ -14,7 +14,7 @@ bool route_can_carry_even_disabled(const struct gossmap *map,
|
||||
if (!gossmap_chan_set(c, dir))
|
||||
return false;
|
||||
/* Amount 0 is a special "ignore min" probe case */
|
||||
if (!amount_msat_eq(amount, AMOUNT_MSAT(0))
|
||||
if (!amount_msat_is_zero(amount)
|
||||
&& !gossmap_chan_has_capacity(c, dir, amount))
|
||||
return false;
|
||||
return true;
|
||||
|
@ -937,7 +937,7 @@ void channel_record_open(struct channel *channel, u32 blockheight, bool record_p
|
||||
{
|
||||
struct chain_coin_mvt *mvt;
|
||||
struct amount_msat start_balance;
|
||||
bool is_pushed = !amount_msat_zero(channel->push);
|
||||
bool is_pushed = !amount_msat_is_zero(channel->push);
|
||||
bool is_leased = channel->lease_expiry > 0;
|
||||
|
||||
/* If funds were pushed, add/sub them from the starting balance */
|
||||
@ -1852,7 +1852,7 @@ is_fundee_should_forget(struct lightningd *ld,
|
||||
return false;
|
||||
|
||||
/* If we've got funds in the channel, don't forget it */
|
||||
if (!amount_sat_zero(channel->our_funds))
|
||||
if (!amount_sat_is_zero(channel->our_funds))
|
||||
return false;
|
||||
|
||||
/* Ah forget it! */
|
||||
|
@ -56,7 +56,7 @@ static void json_add_closed_channel(struct json_stream *response,
|
||||
else
|
||||
json_add_amount_msat(response, "funding_fee_rcvd_msat",
|
||||
channel->push);
|
||||
} else if (!amount_msat_eq(channel->push, AMOUNT_MSAT(0)))
|
||||
} else if (!amount_msat_is_zero(channel->push))
|
||||
json_add_amount_msat(response, "funding_pushed_msat",
|
||||
channel->push);
|
||||
|
||||
|
@ -627,11 +627,11 @@ rbf_channel_hook_deserialize(struct rbf_channel_payload *payload,
|
||||
fatal("Plugin failed to supply our_funding_msat field");
|
||||
|
||||
if (payload->psbt
|
||||
&& amount_sat_zero(payload->our_funding))
|
||||
&& amount_sat_is_zero(payload->our_funding))
|
||||
fatal("Plugin failed to supply our_funding_msat field");
|
||||
|
||||
if (!payload->psbt &&
|
||||
!amount_sat_zero(payload->our_funding)) {
|
||||
!amount_sat_is_zero(payload->our_funding)) {
|
||||
|
||||
log_broken(channel->log, "`our_funding_msat` returned"
|
||||
" but no `psbt` present. %.*s",
|
||||
@ -835,11 +835,11 @@ openchannel2_hook_deserialize(struct openchannel2_payload *payload,
|
||||
fatal("Plugin failed to supply our_funding_msat field");
|
||||
|
||||
if (payload->psbt
|
||||
&& amount_sat_zero(payload->accepter_funding))
|
||||
&& amount_sat_is_zero(payload->accepter_funding))
|
||||
fatal("Plugin failed to supply our_funding_msat field");
|
||||
|
||||
if (!payload->psbt
|
||||
&& !amount_sat_zero(payload->accepter_funding)) {
|
||||
&& !amount_sat_is_zero(payload->accepter_funding)) {
|
||||
/* Gotta give a PSBT if you set the accepter_funding amount */
|
||||
/* Let dualopend know we've failed */
|
||||
payload->err_msg = "Client error. Unable to continue";
|
||||
@ -3089,7 +3089,7 @@ static struct command_result *openchannel_init(struct command *cmd,
|
||||
unilateral_feerate(cmd->ld->topology, true),
|
||||
feerate_per_kw_funding,
|
||||
channel->channel_flags,
|
||||
amount_sat_zero(request_amt) ?
|
||||
amount_sat_is_zero(request_amt) ?
|
||||
NULL : &request_amt,
|
||||
get_block_height(cmd->ld->topology),
|
||||
false,
|
||||
@ -3190,7 +3190,7 @@ static struct command_result *json_openchannel_init(struct command *cmd,
|
||||
}
|
||||
|
||||
/* Gotta expect some rates ! */
|
||||
if (!amount_sat_zero(*info->request_amt) && !info->rates)
|
||||
if (!amount_sat_is_zero(*info->request_amt) && !info->rates)
|
||||
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
||||
"Must pass in 'compact_lease' if requesting"
|
||||
" funds from peer");
|
||||
@ -3858,7 +3858,7 @@ static struct command_result *json_queryrates(struct command *cmd,
|
||||
unilateral_feerate(cmd->ld->topology, true),
|
||||
*feerate_per_kw_funding,
|
||||
channel->channel_flags,
|
||||
amount_sat_zero(*request_amt) ?
|
||||
amount_sat_is_zero(*request_amt) ?
|
||||
NULL : request_amt,
|
||||
get_block_height(cmd->ld->topology),
|
||||
true,
|
||||
@ -4235,7 +4235,7 @@ bool peer_restart_dualopend(struct peer *peer,
|
||||
inflight->lease_commit_sig,
|
||||
inflight->lease_chan_max_msat,
|
||||
inflight->lease_chan_max_ppt,
|
||||
amount_sat_zero(inflight->lease_amt) ?
|
||||
amount_sat_is_zero(inflight->lease_amt) ?
|
||||
NULL : &inflight->lease_amt,
|
||||
channel->type,
|
||||
channel->req_confirmed_ins[LOCAL],
|
||||
|
@ -117,7 +117,7 @@ void json_add_forwarding_fields(struct json_stream *response,
|
||||
json_add_amount_msat(response, "in_msat", cur->msat_in);
|
||||
|
||||
/* These can be unset (aka zero) if we failed before channel lookup */
|
||||
if (!amount_msat_eq(cur->msat_out, AMOUNT_MSAT(0))) {
|
||||
if (!amount_msat_is_zero(cur->msat_out)) {
|
||||
json_add_amount_msat(response, "out_msat", cur->msat_out);
|
||||
json_add_amount_msat(response, "fee_msat", cur->fee);
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ static void *corrupt(const char *abortstr, const char *fmt, ...)
|
||||
|
||||
struct htlc_in *htlc_in_check(const struct htlc_in *hin, const char *abortstr)
|
||||
{
|
||||
if (amount_msat_eq(hin->msat, AMOUNT_MSAT(0)))
|
||||
if (amount_msat_is_zero(hin->msat))
|
||||
return corrupt(abortstr, "zero msatoshi");
|
||||
else if (htlc_state_owner(hin->hstate) != REMOTE)
|
||||
return corrupt(abortstr, "invalid state %s",
|
||||
|
@ -1020,7 +1020,7 @@ static struct command_result *param_positive_msat_or_any(struct command *cmd,
|
||||
}
|
||||
*msat = tal(cmd, struct amount_msat);
|
||||
if (parse_amount_msat(*msat, buffer + tok->start, tok->end - tok->start)
|
||||
&& !amount_msat_eq(**msat, AMOUNT_MSAT(0)))
|
||||
&& !amount_msat_is_zero(**msat))
|
||||
return NULL;
|
||||
|
||||
return command_fail_badparam(cmd, name, buffer, tok,
|
||||
|
@ -1000,7 +1000,7 @@ static struct command_result *check_progress(struct lightningd *ld,
|
||||
* set is already greater or equal to `total_msat`.
|
||||
*/
|
||||
/* We don't do this for single 0-value payments (sendonion does this) */
|
||||
if (!amount_msat_eq(total_msat, AMOUNT_MSAT(0))
|
||||
if (!amount_msat_is_zero(total_msat)
|
||||
&& amount_msat_greater_eq(msat_already_pending, total_msat)) {
|
||||
return command_fail(cmd, PAY_IN_PROGRESS,
|
||||
"Already have %s of %s payments in progress",
|
||||
|
@ -2093,7 +2093,7 @@ static bool channel_added_their_htlc(struct channel *channel,
|
||||
* - SHOULD send a `warning` and close the connection, or send an
|
||||
* `error` and fail the channel.
|
||||
*/
|
||||
if (amount_msat_eq(added->amount, AMOUNT_MSAT(0))
|
||||
if (amount_msat_is_zero(added->amount)
|
||||
|| amount_msat_less(added->amount, channel->our_config.htlc_minimum)) {
|
||||
channel_internal_error(channel,
|
||||
"trying to add HTLC amount %s"
|
||||
|
@ -156,7 +156,7 @@ routehint_candidates(const tal_t *ctx,
|
||||
continue;
|
||||
}
|
||||
/* If they give us a hint, we use even if capacity 0 */
|
||||
} else if (amount_msat_eq(capacity, AMOUNT_MSAT(0))) {
|
||||
} else if (amount_msat_is_zero(capacity)) {
|
||||
log_debug(ld->log, "%s: deadend",
|
||||
fmt_short_channel_id(tmpctx,
|
||||
r->short_channel_id));
|
||||
|
@ -395,7 +395,7 @@ static void record_coin_movements(struct tracked_output *out,
|
||||
|| out->resolved->tx_type == OUR_HTLC_TIMEOUT_TO_US
|
||||
|| out->resolved->tx_type == OUR_PENALTY_TX) {
|
||||
/* penalty rbf cases, the amount might be zero */
|
||||
if (amount_sat_zero(out->sat))
|
||||
if (amount_sat_is_zero(out->sat))
|
||||
record_channel_withdrawal(txid, out, blockheight, TO_MINER);
|
||||
else
|
||||
record_channel_withdrawal(txid, out, blockheight, TO_WALLET);
|
||||
|
@ -2562,7 +2562,7 @@ static void accepter_start(struct state *state, const u8 *oc2_msg)
|
||||
* ...
|
||||
* - MUST set `funding_satoshis` to a value greater than 0msat
|
||||
*/
|
||||
if (tx_state->rates && amount_sat_zero(tx_state->accepter_funding)) {
|
||||
if (tx_state->rates && amount_sat_is_zero(tx_state->accepter_funding)) {
|
||||
status_broken("opt_will_fund ad passed in, but no funding");
|
||||
negotiation_failed(state, "We're unable to accept"
|
||||
" your lease offer.");
|
||||
|
@ -309,7 +309,7 @@ static const char *get_routes(const tal_t *ctx,
|
||||
/* This value is somewhat implied by our fee budget: say we would pay
|
||||
* the entire budget for 100% probability, that means prob_cost_factor
|
||||
* is (fee / amount) / 1000, or in PPM: (fee / amount) * 1000 */
|
||||
if (amount_msat_zero(amount))
|
||||
if (amount_msat_is_zero(amount))
|
||||
prob_cost_factor = 0;
|
||||
else
|
||||
prob_cost_factor = amount_msat_ratio(maxfee, amount) * 1000;
|
||||
|
@ -22,7 +22,7 @@ static bool check_fee_inequality(struct amount_msat recv, struct amount_msat sen
|
||||
u64 base_fee, u64 proportional_fee)
|
||||
{
|
||||
// nothing to forward, any incoming amount is good
|
||||
if (amount_msat_zero(send))
|
||||
if (amount_msat_is_zero(send))
|
||||
return true;
|
||||
// FIXME If this addition fails we return false. The caller will not be
|
||||
// able to know that there was an addition overflow, he will just assume
|
||||
@ -182,7 +182,7 @@ flow_maximum_deliverable(struct amount_msat *max_deliverable,
|
||||
get_constraints(rq, flow->path[0], flow->dirs[0], NULL, &maxcap);
|
||||
maxcap = amount_msat_min(maxcap, gossmap_chan_htlc_max(flow->path[0], flow->dirs[0]));
|
||||
|
||||
if (amount_msat_zero(maxcap))
|
||||
if (amount_msat_is_zero(maxcap))
|
||||
return flow->path[0];
|
||||
|
||||
for (size_t i = 1; i < tal_count(flow->path); ++i) {
|
||||
@ -205,7 +205,7 @@ flow_maximum_deliverable(struct amount_msat *max_deliverable,
|
||||
/* safety check: amounts decrease along the route */
|
||||
assert(amount_msat_less_eq(new_max, maxcap));
|
||||
|
||||
if (amount_msat_zero(new_max))
|
||||
if (amount_msat_is_zero(new_max))
|
||||
return flow->path[i];
|
||||
|
||||
/* safety check: the max liquidity in the next hop + fees cannot
|
||||
@ -219,7 +219,7 @@ flow_maximum_deliverable(struct amount_msat *max_deliverable,
|
||||
|
||||
maxcap = new_max;
|
||||
}
|
||||
assert(!amount_msat_zero(maxcap));
|
||||
assert(!amount_msat_is_zero(maxcap));
|
||||
*max_deliverable = maxcap;
|
||||
return NULL;
|
||||
}
|
||||
@ -410,7 +410,7 @@ flow_assign_delivery(struct flow *flow,
|
||||
badchan = flow_maximum_deliverable(&max_deliverable, flow, rq);
|
||||
if (badchan)
|
||||
return badchan;
|
||||
assert(!amount_msat_zero(max_deliverable));
|
||||
assert(!amount_msat_is_zero(max_deliverable));
|
||||
flow->amount = amount_msat_min(requested_amount, max_deliverable);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ getblockheight_done(struct command *cmd, const char *buf,
|
||||
}
|
||||
|
||||
/* Append a net/rollup entry */
|
||||
if (!amount_msat_zero(net_apys->total_start_bal)) {
|
||||
if (!amount_msat_is_zero(net_apys->total_start_bal)) {
|
||||
net_apys->acct_name = tal_fmt(net_apys, "net");
|
||||
json_add_channel_apy(res, net_apys);
|
||||
}
|
||||
@ -726,8 +726,8 @@ static bool new_missed_channel_account(struct command *cmd,
|
||||
try_update_open_fees(cmd, acct);
|
||||
|
||||
/* We log a channel event for the push amt */
|
||||
if (!amount_msat_zero(push_credit)
|
||||
|| !amount_msat_zero(push_debit)) {
|
||||
if (!amount_msat_is_zero(push_credit)
|
||||
|| !amount_msat_is_zero(push_debit)) {
|
||||
struct channel_event *chan_ev;
|
||||
char *chan_tag;
|
||||
|
||||
@ -799,13 +799,13 @@ static char *msat_find_diff(struct amount_msat balance,
|
||||
return err;
|
||||
|
||||
/* If we're not missing events, debits == 0 */
|
||||
if (!amount_msat_zero(net_debit)) {
|
||||
assert(amount_msat_zero(net_credit));
|
||||
if (!amount_msat_is_zero(net_debit)) {
|
||||
assert(amount_msat_is_zero(net_credit));
|
||||
if (!amount_msat_add(credit_diff, net_debit, balance))
|
||||
return "Overflow finding credit_diff";
|
||||
*debit_diff = AMOUNT_MSAT(0);
|
||||
} else {
|
||||
assert(amount_msat_zero(net_debit));
|
||||
assert(amount_msat_is_zero(net_debit));
|
||||
if (amount_msat_greater(net_credit, balance)) {
|
||||
if (!amount_msat_sub(debit_diff, net_credit,
|
||||
balance))
|
||||
@ -832,8 +832,8 @@ static void log_journal_entry(struct account *acct,
|
||||
struct channel_event *chan_ev;
|
||||
|
||||
/* No diffs to register, no journal needed */
|
||||
if (amount_msat_zero(credit_diff)
|
||||
&& amount_msat_zero(debit_diff))
|
||||
if (amount_msat_is_zero(credit_diff)
|
||||
&& amount_msat_is_zero(debit_diff))
|
||||
return;
|
||||
|
||||
chan_ev = new_channel_event(tmpctx,
|
||||
@ -1091,7 +1091,7 @@ static struct command_result *json_balance_snapshot(struct command *cmd,
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!amount_msat_zero(credit_diff) || !amount_msat_zero(debit_diff)) {
|
||||
if (!amount_msat_is_zero(credit_diff) || !amount_msat_is_zero(debit_diff)) {
|
||||
struct channel_event *ev;
|
||||
|
||||
plugin_log(cmd->plugin, LOG_UNUSUAL,
|
||||
@ -1287,7 +1287,7 @@ static struct command_result *lookup_invoice_desc(struct command *cmd,
|
||||
|
||||
/* Otherwise will go away when event is cleaned up */
|
||||
tal_steal(cmd, payment_hash);
|
||||
if (!amount_msat_zero(credit))
|
||||
if (!amount_msat_is_zero(credit))
|
||||
req = jsonrpc_request_start(cmd->plugin, cmd,
|
||||
"listinvoices",
|
||||
listinvoices_done,
|
||||
@ -1660,7 +1660,7 @@ parse_and_log_channel_move(struct command *cmd,
|
||||
|
||||
/* We only do rebalance checks for debits,
|
||||
* the credit event always arrives first */
|
||||
if (!amount_msat_zero(e->debit))
|
||||
if (!amount_msat_is_zero(e->debit))
|
||||
maybe_record_rebalance(db, e);
|
||||
|
||||
db_commit_transaction(db);
|
||||
|
@ -41,7 +41,7 @@ void json_add_channel_event(struct json_stream *out,
|
||||
json_add_string(out, "tag", ev->tag);
|
||||
json_add_amount_msat(out, "credit_msat", ev->credit);
|
||||
json_add_amount_msat(out, "debit_msat", ev->debit);
|
||||
if (!amount_msat_zero(ev->fees))
|
||||
if (!amount_msat_is_zero(ev->fees))
|
||||
json_add_amount_msat(out, "fees_msat", ev->fees);
|
||||
json_add_string(out, "currency", ev->currency);
|
||||
if (ev->payment_id) {
|
||||
|
@ -201,7 +201,7 @@ struct channel_apy **compute_channel_apys(const tal_t *ctx, struct db *db,
|
||||
if (streq("invoice", ev->tag))
|
||||
continue;
|
||||
|
||||
if (!amount_msat_zero(ev->credit))
|
||||
if (!amount_msat_is_zero(ev->credit))
|
||||
ok = amount_msat_accumulate(&apy->fees_in,
|
||||
ev->fees);
|
||||
else
|
||||
@ -247,7 +247,7 @@ WARN_UNUSED_RESULT static bool calc_apy(struct amount_msat earned,
|
||||
{
|
||||
double apy;
|
||||
|
||||
assert(!amount_msat_zero(capital));
|
||||
assert(!amount_msat_is_zero(capital));
|
||||
assert(blocks_elapsed > 0);
|
||||
|
||||
apy = amount_msat_ratio(earned, capital) * BLOCK_YEAR / blocks_elapsed;
|
||||
@ -297,12 +297,12 @@ void json_add_channel_apy(struct json_stream *res,
|
||||
json_add_amount_msat(res, "fees_in_msat", apy->fees_in);
|
||||
|
||||
/* utilization (out): routed_out/total_balance */
|
||||
assert(!amount_msat_zero(apy->total_start_bal));
|
||||
assert(!amount_msat_is_zero(apy->total_start_bal));
|
||||
utilization = amount_msat_ratio(apy->routed_out, apy->total_start_bal);
|
||||
json_add_string(res, "utilization_out",
|
||||
tal_fmt(apy, "%.4f%%", utilization * 100));
|
||||
|
||||
if (!amount_msat_zero(apy->our_start_bal)) {
|
||||
if (!amount_msat_is_zero(apy->our_start_bal)) {
|
||||
utilization = amount_msat_ratio(apy->routed_out,
|
||||
apy->our_start_bal);
|
||||
json_add_string(res, "utilization_out_initial",
|
||||
@ -314,7 +314,7 @@ void json_add_channel_apy(struct json_stream *res,
|
||||
json_add_string(res, "utilization_in",
|
||||
tal_fmt(apy, "%.4f%%", utilization * 100));
|
||||
|
||||
if (!amount_msat_zero(their_start_bal)) {
|
||||
if (!amount_msat_is_zero(their_start_bal)) {
|
||||
utilization = amount_msat_ratio(apy->routed_in,
|
||||
their_start_bal);
|
||||
json_add_string(res, "utilization_in_initial",
|
||||
@ -331,7 +331,7 @@ void json_add_channel_apy(struct json_stream *res,
|
||||
json_add_string(res, "apy_out", tal_fmt(apy, "%.4f%%", apy_result));
|
||||
|
||||
/* APY (outbound, initial) */
|
||||
if (!amount_msat_zero(apy->our_start_bal)) {
|
||||
if (!amount_msat_is_zero(apy->our_start_bal)) {
|
||||
ok = calc_apy(apy->fees_out, apy->our_start_bal,
|
||||
blocks_elapsed, &apy_result);
|
||||
assert(ok);
|
||||
@ -345,7 +345,7 @@ void json_add_channel_apy(struct json_stream *res,
|
||||
assert(ok);
|
||||
json_add_string(res, "apy_in", tal_fmt(apy, "%.4f%%", apy_result));
|
||||
|
||||
if (!amount_msat_zero(their_start_bal)) {
|
||||
if (!amount_msat_is_zero(their_start_bal)) {
|
||||
ok = calc_apy(apy->fees_in, their_start_bal,
|
||||
blocks_elapsed, &apy_result);
|
||||
assert(ok);
|
||||
@ -359,7 +359,7 @@ void json_add_channel_apy(struct json_stream *res,
|
||||
assert(ok);
|
||||
json_add_string(res, "apy_total", tal_fmt(apy, "%.4f%%", apy_result));
|
||||
|
||||
if (!amount_msat_zero(apy->our_start_bal)) {
|
||||
if (!amount_msat_is_zero(apy->our_start_bal)) {
|
||||
ok = calc_apy(total_fees, apy->total_start_bal,
|
||||
blocks_elapsed, &apy_result);
|
||||
assert(ok);
|
||||
@ -370,7 +370,7 @@ void json_add_channel_apy(struct json_stream *res,
|
||||
/* If you earned fees for leasing funds, calculate APY
|
||||
* Note that this is a bit higher than it *should* be,
|
||||
* given that the onchainfees are partly covered here */
|
||||
if (!amount_msat_zero(apy->lease_in)) {
|
||||
if (!amount_msat_is_zero(apy->lease_in)) {
|
||||
struct amount_msat start_no_lease_in;
|
||||
|
||||
/* We added the lease in to the starting balance, so we
|
||||
|
@ -226,13 +226,13 @@ static struct income_event *rebalance_fee(const tal_t *ctx,
|
||||
static struct income_event *maybe_channel_income(const tal_t *ctx,
|
||||
struct channel_event *ev)
|
||||
{
|
||||
if (amount_msat_zero(ev->credit)
|
||||
&& amount_msat_zero(ev->debit))
|
||||
if (amount_msat_is_zero(ev->credit)
|
||||
&& amount_msat_is_zero(ev->debit))
|
||||
return NULL;
|
||||
|
||||
/* We record a +/- penalty adj, but we only count the credit */
|
||||
if (streq(ev->tag, "penalty_adj")) {
|
||||
if (!amount_msat_zero(ev->credit))
|
||||
if (!amount_msat_is_zero(ev->credit))
|
||||
return channel_to_income(ctx, ev,
|
||||
ev->credit,
|
||||
ev->debit);
|
||||
@ -245,7 +245,7 @@ static struct income_event *maybe_channel_income(const tal_t *ctx,
|
||||
return NULL;
|
||||
|
||||
/* If it's a payment, we note fees separately */
|
||||
if (!amount_msat_zero(ev->debit)) {
|
||||
if (!amount_msat_is_zero(ev->debit)) {
|
||||
struct amount_msat paid;
|
||||
bool ok;
|
||||
ok = amount_msat_sub(&paid, ev->debit, ev->fees);
|
||||
@ -263,7 +263,7 @@ static struct income_event *maybe_channel_income(const tal_t *ctx,
|
||||
/* for routed payments, we only record the fees on the
|
||||
* debiting side -- the side the $$ was made on! */
|
||||
if (streq(ev->tag, "routed")) {
|
||||
if (!amount_msat_zero(ev->debit))
|
||||
if (!amount_msat_is_zero(ev->debit))
|
||||
return channel_to_income(ctx, ev,
|
||||
ev->fees,
|
||||
AMOUNT_MSAT(0));
|
||||
@ -290,7 +290,7 @@ static struct onchain_fee **find_consolidated_fees(const tal_t *ctx,
|
||||
/* Find the last matching feerate's data */
|
||||
struct onchain_fee *fee;
|
||||
|
||||
if (amount_msat_zero(sums[i]->fees_paid))
|
||||
if (amount_msat_is_zero(sums[i]->fees_paid))
|
||||
continue;
|
||||
|
||||
fee = tal(fee_sums, struct onchain_fee);
|
||||
@ -394,8 +394,8 @@ struct income_event **list_income_events(const tal_t *ctx,
|
||||
|
||||
/* Report fees on payments, if present */
|
||||
if (streq(chan->tag, "invoice")
|
||||
&& !amount_msat_zero(chan->debit)
|
||||
&& !amount_msat_zero(chan->fees)) {
|
||||
&& !amount_msat_is_zero(chan->debit)
|
||||
&& !amount_msat_is_zero(chan->fees)) {
|
||||
if (!chan->rebalance_id)
|
||||
ev = paid_invoice_fee(evs, chan);
|
||||
else
|
||||
@ -482,7 +482,7 @@ static char *income_event_cointrack_type(const struct income_event *ev)
|
||||
{
|
||||
/* ['gift', 'lost', 'mined', 'airdrop', 'payment',
|
||||
* 'fork', 'donation', 'staked'] */
|
||||
if (!amount_msat_zero(ev->debit)
|
||||
if (!amount_msat_is_zero(ev->debit)
|
||||
&& streq(ev->tag, "penalty"))
|
||||
return "lost";
|
||||
|
||||
@ -512,7 +512,7 @@ static void cointrack_entry(const tal_t *ctx, FILE *csvf, struct income_event *e
|
||||
fprintf(csvf, ",");
|
||||
|
||||
/* Received Quantity + Received Currency */
|
||||
if (!amount_msat_zero(ev->credit)) {
|
||||
if (!amount_msat_is_zero(ev->credit)) {
|
||||
fprintf(csvf, "%s", fmt_amount_msat_btc(ctx, ev->credit, false));
|
||||
fprintf(csvf, ",");
|
||||
fprintf(csvf, "%s", convert_asset_type(ev));
|
||||
@ -522,7 +522,7 @@ static void cointrack_entry(const tal_t *ctx, FILE *csvf, struct income_event *e
|
||||
fprintf(csvf, ",");
|
||||
|
||||
/* "Sent Quantity,Sent Currency," */
|
||||
if (!amount_msat_zero(ev->debit)) {
|
||||
if (!amount_msat_is_zero(ev->debit)) {
|
||||
fprintf(csvf, "%s", fmt_amount_msat_btc(ctx, ev->debit, false));
|
||||
fprintf(csvf, ",");
|
||||
fprintf(csvf, "%s", convert_asset_type(ev));
|
||||
@ -532,7 +532,7 @@ static void cointrack_entry(const tal_t *ctx, FILE *csvf, struct income_event *e
|
||||
fprintf(csvf, ",");
|
||||
|
||||
/* "Fee Amount,Fee Currency," */
|
||||
if (!amount_msat_zero(ev->fees)
|
||||
if (!amount_msat_is_zero(ev->fees)
|
||||
&& streq(ev->tag, mvt_tag_str(INVOICE))) {
|
||||
fprintf(csvf, "%s", fmt_amount_msat_btc(ctx, ev->fees, false));
|
||||
fprintf(csvf, ",");
|
||||
@ -584,7 +584,7 @@ static void koinly_entry(const tal_t *ctx, FILE *csvf, struct income_event *ev)
|
||||
fprintf(csvf, ",");
|
||||
|
||||
/* "Sent Amount,Sent Currency," */
|
||||
if (!amount_msat_zero(ev->debit)) {
|
||||
if (!amount_msat_is_zero(ev->debit)) {
|
||||
fprintf(csvf, "%s", fmt_amount_msat_btc(ctx, ev->debit, false));
|
||||
fprintf(csvf, ",");
|
||||
fprintf(csvf, "%s", convert_asset_type(ev));
|
||||
@ -594,7 +594,7 @@ static void koinly_entry(const tal_t *ctx, FILE *csvf, struct income_event *ev)
|
||||
fprintf(csvf, ",");
|
||||
|
||||
/* Received Amount, Received Currency */
|
||||
if (!amount_msat_zero(ev->credit)) {
|
||||
if (!amount_msat_is_zero(ev->credit)) {
|
||||
fprintf(csvf, "%s", fmt_amount_msat_btc(ctx, ev->credit, false));
|
||||
fprintf(csvf, ",");
|
||||
fprintf(csvf, "%s", convert_asset_type(ev));
|
||||
@ -605,7 +605,7 @@ static void koinly_entry(const tal_t *ctx, FILE *csvf, struct income_event *ev)
|
||||
|
||||
|
||||
/* "Fee Amount,Fee Currency," */
|
||||
if (!amount_msat_zero(ev->fees)
|
||||
if (!amount_msat_is_zero(ev->fees)
|
||||
&& streq(ev->tag, mvt_tag_str(INVOICE))) {
|
||||
fprintf(csvf, "%s", fmt_amount_msat_btc(ctx, ev->fees, false));
|
||||
fprintf(csvf, ",");
|
||||
@ -673,7 +673,7 @@ static char *income_event_harmony_type(const struct income_event *ev)
|
||||
if (streq(ONCHAIN_FEE, ev->tag))
|
||||
return "fee:network";
|
||||
|
||||
if (!amount_msat_zero(ev->credit)) {
|
||||
if (!amount_msat_is_zero(ev->credit)) {
|
||||
if (streq(WALLET_ACCT, ev->acct_name))
|
||||
return tal_fmt(ev, "transfer:%s", ev->tag);
|
||||
|
||||
@ -716,7 +716,7 @@ static void harmony_entry(const tal_t *ctx, FILE *csvf, struct income_event *ev)
|
||||
fprintf(csvf, ",");
|
||||
|
||||
/* ",Amount" */
|
||||
if (!amount_msat_zero(ev->debit)) {
|
||||
if (!amount_msat_is_zero(ev->debit)) {
|
||||
/* Debits are negative */
|
||||
fprintf(csvf, "-");
|
||||
fprintf(csvf, "%s",
|
||||
@ -799,13 +799,13 @@ static void quickbooks_entry(const tal_t *ctx, FILE *csvf, struct income_event *
|
||||
fprintf(csvf, ",");
|
||||
|
||||
/* Credit */
|
||||
if (!amount_msat_zero(ev->credit))
|
||||
if (!amount_msat_is_zero(ev->credit))
|
||||
fprintf(csvf, "%s", fmt_amount_msat_btc(ctx, ev->credit, false));
|
||||
|
||||
fprintf(csvf, ",");
|
||||
|
||||
/* Debit */
|
||||
if (!amount_msat_zero(ev->debit))
|
||||
if (!amount_msat_is_zero(ev->debit))
|
||||
fprintf(csvf, "%s", fmt_amount_msat_btc(ctx, ev->debit, false));
|
||||
}
|
||||
|
||||
|
@ -1916,8 +1916,8 @@ char *maybe_update_onchain_fees(const tal_t *ctx, struct db *db,
|
||||
goto finished;
|
||||
|
||||
/* If either is zero, keep waiting */
|
||||
if (amount_msat_zero(withdraw_msat)
|
||||
|| amount_msat_zero(deposit_msat))
|
||||
if (amount_msat_is_zero(withdraw_msat)
|
||||
|| amount_msat_is_zero(deposit_msat))
|
||||
goto finished;
|
||||
|
||||
/* If our withdraws < deposits, wait for more data */
|
||||
|
@ -490,10 +490,10 @@ static bool test_onchain_fee_wallet_spend(const tal_t *ctx, struct plugin *p)
|
||||
|
||||
/* we expect 800, then -700 */
|
||||
CHECK(amount_msat_eq(ofs[0]->credit, AMOUNT_MSAT(800)));
|
||||
CHECK(amount_msat_zero(ofs[0]->debit));
|
||||
CHECK(amount_msat_is_zero(ofs[0]->debit));
|
||||
CHECK(ofs[0]->update_count == 1);
|
||||
|
||||
CHECK(amount_msat_zero(ofs[1]->credit));
|
||||
CHECK(amount_msat_is_zero(ofs[1]->credit));
|
||||
CHECK(amount_msat_eq(ofs[1]->debit, AMOUNT_MSAT(700)));
|
||||
CHECK(ofs[1]->update_count == 2);
|
||||
|
||||
@ -736,28 +736,28 @@ static bool test_onchain_fee_chan_close(const tal_t *ctx, struct plugin *p)
|
||||
if (bitcoin_txid_eq(&txid, &ofs[i]->txid)) {
|
||||
CHECK(ofs[i]->update_count == 1);
|
||||
CHECK(amount_msat_eq(ofs[i]->credit, AMOUNT_MSAT(200)));
|
||||
CHECK(amount_msat_zero(ofs[i]->debit));
|
||||
CHECK(amount_msat_is_zero(ofs[i]->debit));
|
||||
continue;
|
||||
}
|
||||
memset(&txid, '2', sizeof(struct bitcoin_txid));
|
||||
if (bitcoin_txid_eq(&txid, &ofs[i]->txid)) {
|
||||
CHECK(ofs[i]->update_count == 1);
|
||||
CHECK(amount_msat_eq(ofs[i]->credit, AMOUNT_MSAT(50)));
|
||||
CHECK(amount_msat_zero(ofs[i]->debit));
|
||||
CHECK(amount_msat_is_zero(ofs[i]->debit));
|
||||
continue;
|
||||
}
|
||||
memset(&txid, '3', sizeof(struct bitcoin_txid));
|
||||
if (bitcoin_txid_eq(&txid, &ofs[i]->txid)) {
|
||||
CHECK(ofs[i]->update_count == 1);
|
||||
CHECK(amount_msat_eq(ofs[i]->credit, AMOUNT_MSAT(150)));
|
||||
CHECK(amount_msat_zero(ofs[i]->debit));
|
||||
CHECK(amount_msat_is_zero(ofs[i]->debit));
|
||||
continue;
|
||||
}
|
||||
memset(&txid, '4', sizeof(struct bitcoin_txid));
|
||||
if (bitcoin_txid_eq(&txid, &ofs[i]->txid)) {
|
||||
CHECK(ofs[i]->update_count == 1);
|
||||
CHECK(amount_msat_eq(ofs[i]->credit, AMOUNT_MSAT(100)));
|
||||
CHECK(amount_msat_zero(ofs[i]->debit));
|
||||
CHECK(amount_msat_is_zero(ofs[i]->debit));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -448,7 +448,7 @@ psbt_funded(struct command *cmd,
|
||||
|
||||
/* If we're accepting an lease request, *and* they've
|
||||
* requested one, fill in our most recent infos */
|
||||
if (current_policy->rates && !amount_sat_zero(info->requested_lease))
|
||||
if (current_policy->rates && !amount_sat_is_zero(info->requested_lease))
|
||||
json_add_lease_rates(response, current_policy->rates);
|
||||
|
||||
return command_finished(cmd, response);
|
||||
@ -696,7 +696,7 @@ listfunds_success(struct command *cmd,
|
||||
fmt_amount_sat(tmpctx, info->our_funding),
|
||||
funding_err ? funding_err : "");
|
||||
|
||||
if (amount_sat_zero(info->our_funding))
|
||||
if (amount_sat_is_zero(info->our_funding))
|
||||
return command_hook_success(cmd);
|
||||
|
||||
plugin_log(cmd->plugin, LOG_DBG,
|
||||
@ -841,7 +841,7 @@ json_openchannel2_call(struct command *cmd,
|
||||
/* If they've requested funds, but we're not actually
|
||||
* supporting requested funds...*/
|
||||
if (!current_policy->rates &&
|
||||
!amount_sat_zero(info->requested_lease)) {
|
||||
!amount_sat_is_zero(info->requested_lease)) {
|
||||
struct json_stream *res = jsonrpc_stream_success(cmd);
|
||||
json_add_string(res, "result", "reject");
|
||||
json_add_string(res, "error_message",
|
||||
@ -852,7 +852,7 @@ json_openchannel2_call(struct command *cmd,
|
||||
|
||||
|
||||
/* Check that their block height isn't too far behind */
|
||||
if (!amount_sat_zero(info->requested_lease)) {
|
||||
if (!amount_sat_is_zero(info->requested_lease)) {
|
||||
u32 upper_bound, lower_bound;
|
||||
|
||||
/* BOLT- #2:
|
||||
|
@ -193,7 +193,7 @@ apply_policy(struct funder_policy *policy,
|
||||
switch (policy->opt) {
|
||||
case MATCH:
|
||||
/* For matches, we use requested funding, if availalbe */
|
||||
if (!amount_sat_zero(requested_lease))
|
||||
if (!amount_sat_is_zero(requested_lease))
|
||||
their_funding = requested_lease;
|
||||
|
||||
/* if this fails, it implies ludicrous funding offer, *and*
|
||||
@ -230,7 +230,7 @@ calculate_our_funding(struct funder_policy *policy,
|
||||
struct amount_sat avail_channel_space, net_available_funds;
|
||||
|
||||
/* Are we only funding lease requests ? */
|
||||
if (policy->leases_only && amount_sat_zero(requested_lease)) {
|
||||
if (policy->leases_only && amount_sat_is_zero(requested_lease)) {
|
||||
*our_funding = AMOUNT_SAT(0);
|
||||
return tal_fmt(tmpctx,
|
||||
"Skipping funding open; leases-only=true"
|
||||
@ -240,7 +240,7 @@ calculate_our_funding(struct funder_policy *policy,
|
||||
/* Are we skipping this one? */
|
||||
if (pseudorand(100) >= policy->fund_probability
|
||||
/* We don't skip lease requests */
|
||||
&& amount_sat_zero(requested_lease)) {
|
||||
&& amount_sat_is_zero(requested_lease)) {
|
||||
*our_funding = AMOUNT_SAT(0);
|
||||
return tal_fmt(tmpctx,
|
||||
"Skipping, failed fund_probability test");
|
||||
@ -248,7 +248,7 @@ calculate_our_funding(struct funder_policy *policy,
|
||||
|
||||
/* Figure out amount of actual headroom we have */
|
||||
if (!amount_sat_sub(&avail_channel_space, channel_max, their_funding)
|
||||
|| amount_sat_zero(avail_channel_space)) {
|
||||
|| amount_sat_is_zero(avail_channel_space)) {
|
||||
*our_funding = AMOUNT_SAT(0);
|
||||
return tal_fmt(tmpctx, "No space available in channel."
|
||||
" channel_max %s, their_funding %s",
|
||||
@ -260,7 +260,7 @@ calculate_our_funding(struct funder_policy *policy,
|
||||
* 'reserve_tank' */
|
||||
if (!amount_sat_sub(&net_available_funds, available_funds,
|
||||
policy->reserve_tank)
|
||||
|| amount_sat_zero(net_available_funds)) {
|
||||
|| amount_sat_is_zero(net_available_funds)) {
|
||||
*our_funding = AMOUNT_SAT(0);
|
||||
return tal_fmt(tmpctx, "Reserve tank too low."
|
||||
" available_funds %s, reserve_tank requires %s",
|
||||
@ -295,7 +295,7 @@ calculate_our_funding(struct funder_policy *policy,
|
||||
available_funds);
|
||||
|
||||
/* Don't return an 'error' if we're already at 0 */
|
||||
if (amount_sat_zero(*our_funding))
|
||||
if (amount_sat_is_zero(*our_funding))
|
||||
return NULL;
|
||||
|
||||
/* our_funding is probably sane, so let's fuzz this amount a bit */
|
||||
@ -317,7 +317,7 @@ calculate_our_funding(struct funder_policy *policy,
|
||||
|
||||
/* Are we putting in less than last time + it's a lease?
|
||||
* Return an error as a convenience to the buyer */
|
||||
if (our_last_funding && !amount_sat_zero(requested_lease)) {
|
||||
if (our_last_funding && !amount_sat_is_zero(requested_lease)) {
|
||||
if (amount_sat_less(*our_funding, *our_last_funding)
|
||||
&& amount_sat_less(*our_funding, requested_lease)) {
|
||||
return tal_fmt(tmpctx, "New amount (%s) is less than"
|
||||
|
@ -140,7 +140,7 @@ bool check_fee_inequality(struct amount_msat recv, struct amount_msat send,
|
||||
u64 base_fee, u64 proportional_fee)
|
||||
{
|
||||
// nothing to forward, any incoming amount is good
|
||||
if (amount_msat_zero(send))
|
||||
if (amount_msat_is_zero(send))
|
||||
return true;
|
||||
// FIXME If this addition fails we return false. The caller will not be
|
||||
// able to know that there was an addition overflow, he will just assume
|
||||
|
@ -93,7 +93,7 @@ flow_maximum_deliverable(struct amount_msat *max_deliverable,
|
||||
}
|
||||
x = amount_msat_min(x, gossmap_chan_htlc_max(flow->path[0], flow->dirs[0]));
|
||||
|
||||
if(amount_msat_zero(x))
|
||||
if(amount_msat_is_zero(x))
|
||||
{
|
||||
if(bad_channel)*bad_channel = flow->path[0];
|
||||
return RENEPAY_BAD_CHANNEL;
|
||||
@ -130,7 +130,7 @@ flow_maximum_deliverable(struct amount_msat *max_deliverable,
|
||||
/* safety check: amounts decrease along the route */
|
||||
assert(amount_msat_less_eq(x_new, x));
|
||||
|
||||
if(amount_msat_zero(x_new))
|
||||
if(amount_msat_is_zero(x_new))
|
||||
{
|
||||
if(bad_channel)*bad_channel = flow->path[i];
|
||||
return RENEPAY_BAD_CHANNEL;
|
||||
@ -147,7 +147,7 @@ flow_maximum_deliverable(struct amount_msat *max_deliverable,
|
||||
|
||||
x = x_new;
|
||||
}
|
||||
assert(!amount_msat_zero(x));
|
||||
assert(!amount_msat_is_zero(x));
|
||||
*max_deliverable = x;
|
||||
return RENEPAY_NOERROR;
|
||||
}
|
||||
@ -423,7 +423,7 @@ bool flow_assign_delivery(struct flow *flow, const struct gossmap *gossmap,
|
||||
if (flow_maximum_deliverable(&max_deliverable, flow, gossmap,
|
||||
chan_extra_map, NULL))
|
||||
return false;
|
||||
assert(!amount_msat_zero(max_deliverable));
|
||||
assert(!amount_msat_is_zero(max_deliverable));
|
||||
flow->amount = amount_msat_min(requested_amount, max_deliverable);
|
||||
return true;
|
||||
}
|
||||
|
@ -234,8 +234,8 @@ REGISTER_PAYMENT_MODIFIER(previoussuccess, previoussuccess_cb);
|
||||
*/
|
||||
static struct command_result *initial_sanity_checks_cb(struct payment *payment)
|
||||
{
|
||||
assert(amount_msat_zero(payment->total_sent));
|
||||
assert(amount_msat_zero(payment->total_delivering));
|
||||
assert(amount_msat_is_zero(payment->total_sent));
|
||||
assert(amount_msat_is_zero(payment->total_delivering));
|
||||
assert(!payment->preimage);
|
||||
assert(tal_count(payment->cmd_array) == 1);
|
||||
|
||||
@ -666,7 +666,7 @@ static struct command_result *compute_routes_cb(struct payment *payment)
|
||||
/* How much are we still trying to send? */
|
||||
if (!amount_msat_sub(&remaining, payment->payment_info.amount,
|
||||
payment->total_delivering) ||
|
||||
amount_msat_zero(remaining)) {
|
||||
amount_msat_is_zero(remaining)) {
|
||||
plugin_log(pay_plugin->plugin, LOG_UNUSUAL,
|
||||
"%s: Payment is pending with full amount already "
|
||||
"committed. We skip the computation of new routes.",
|
||||
|
@ -24,7 +24,7 @@ flow_adjust_htlcmax_constraints(struct flow *flow, struct gossmap *gossmap,
|
||||
assert(gossmap);
|
||||
assert(chan_extra_map);
|
||||
assert(disabled_bitmap);
|
||||
assert(!amount_msat_zero(flow_delivers(flow)));
|
||||
assert(!amount_msat_is_zero(flow_delivers(flow)));
|
||||
|
||||
enum renepay_errorcode errorcode;
|
||||
|
||||
@ -35,7 +35,7 @@ flow_adjust_htlcmax_constraints(struct flow *flow, struct gossmap *gossmap,
|
||||
chan_extra_map, &bad_channel);
|
||||
|
||||
if (!errorcode) {
|
||||
assert(!amount_msat_zero(max_deliverable));
|
||||
assert(!amount_msat_is_zero(max_deliverable));
|
||||
|
||||
// no issues
|
||||
flow->amount =
|
||||
@ -166,7 +166,7 @@ struct route **get_routes(const tal_t *ctx,
|
||||
"Failed to build disabled_bitmap.");
|
||||
goto function_fail;
|
||||
}
|
||||
if (amount_msat_zero(amount_to_deliver)) {
|
||||
if (amount_msat_is_zero(amount_to_deliver)) {
|
||||
tal_report_error(ctx, ecode, fail, PLUGIN_ERROR,
|
||||
"amount to deliver is zero");
|
||||
goto function_fail;
|
||||
@ -207,7 +207,7 @@ struct route **get_routes(const tal_t *ctx,
|
||||
|
||||
char *errmsg;
|
||||
|
||||
while (!amount_msat_zero(amount_to_deliver)) {
|
||||
while (!amount_msat_is_zero(amount_to_deliver)) {
|
||||
|
||||
/* TODO: choose an algorithm, could be something like
|
||||
* payment->algorithm, that we set up based on command line
|
||||
@ -277,7 +277,7 @@ struct route **get_routes(const tal_t *ctx,
|
||||
|
||||
// a bound check, we shouldn't deliver a zero amount, it
|
||||
// would mean a bug somewhere
|
||||
if (amount_msat_zero(flows[i]->amount)) {
|
||||
if (amount_msat_is_zero(flows[i]->amount)) {
|
||||
tal_report_error(ctx, ecode, fail, PLUGIN_ERROR,
|
||||
"flow conveys a zero amount");
|
||||
goto function_fail;
|
||||
|
@ -1380,7 +1380,7 @@ perform_fundpsbt(struct multifundchannel_command *mfc, u32 feerate)
|
||||
"Overflow while summing "
|
||||
"destination values.");
|
||||
/* Also add in any fees for requested amt! */
|
||||
if (!amount_sat_zero(requested)) {
|
||||
if (!amount_sat_is_zero(requested)) {
|
||||
struct amount_sat fee;
|
||||
|
||||
/* Assume they send >= what we've
|
||||
@ -1567,7 +1567,7 @@ connect_ok(struct command *cmd,
|
||||
dest->their_features,
|
||||
OPT_DUAL_FUND))
|
||||
dest->protocol = OPEN_CHANNEL;
|
||||
else if (!amount_sat_zero(dest->request_amt) || !(!dest->rates))
|
||||
else if (!amount_sat_is_zero(dest->request_amt) || !(!dest->rates))
|
||||
/* Return an error */
|
||||
fail_destination_msg(dest, FUNDING_V2_NOT_SUPPORTED,
|
||||
"Tried to buy a liquidity ad"
|
||||
@ -1884,7 +1884,7 @@ param_destinations_array(struct command *cmd, const char *name,
|
||||
json_dest,
|
||||
"output would be dust");
|
||||
|
||||
if (!amount_sat_zero(*request_amt) && !rates)
|
||||
if (!amount_sat_is_zero(*request_amt) && !rates)
|
||||
return command_fail_badparam(cmd, name, buffer,
|
||||
json_dest,
|
||||
"Must pass in 'compact_"
|
||||
|
@ -1015,7 +1015,7 @@ openchannel_init_dest(struct multifundchannel_destination *dest)
|
||||
fmt_amount_msat(tmpctx, dest->push_msat));
|
||||
|
||||
/* Request some sats from the peer! */
|
||||
if (!amount_sat_zero(dest->request_amt)) {
|
||||
if (!amount_sat_is_zero(dest->request_amt)) {
|
||||
json_add_string(req->js, "request_amt",
|
||||
fmt_amount_sat(tmpctx, dest->request_amt));
|
||||
json_add_string(req->js, "compact_lease",
|
||||
|
Loading…
Reference in New Issue
Block a user