Browse Source

amount: use initializers everywhere.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
bump-pyln-proto
Rusty Russell 5 years ago
parent
commit
ffbb409b47
  1. 2
      bitcoin/psbt.c
  2. 3
      bitcoin/test/run-bitcoin_block_from_hex.c
  3. 3
      bitcoin/test/run-tx-encode.c
  4. 2
      channeld/full_channel.c
  5. 3
      cli/test/run-large-input.c
  6. 3
      cli/test/run-remove-hint.c
  7. 2
      common/amount.c
  8. 2
      common/bolt11.c
  9. 4
      common/onion.c
  10. 2
      common/penalty_base.c
  11. 3
      common/test/run-bigsize.c
  12. 3
      common/test/run-cryptomsg.c
  13. 3
      common/test/run-derive_basepoints.c
  14. 3
      common/test/run-features.c
  15. 3
      common/test/run-gossip_rcvd_filter.c
  16. 3
      common/test/run-ip_port_parsing.c
  17. 3
      common/test/run-json_remove.c
  18. 3
      common/test/run-key_derive.c
  19. 3
      common/test/run-lock.c
  20. 3
      common/test/run-softref.c
  21. 3
      common/test/run-sphinx.c
  22. 3
      connectd/test/run-initiator-success.c
  23. 3
      connectd/test/run-responder-success.c
  24. 2
      devtools/onion.c
  25. 2
      gossipd/routing.c

2
bitcoin/psbt.c

@ -443,7 +443,7 @@ struct amount_sat psbt_input_get_amount(struct wally_psbt *psbt,
} else if (psbt->inputs[in].non_witness_utxo) {
int idx = psbt->tx->inputs[in].index;
struct wally_tx *prev_tx = psbt->inputs[in].non_witness_utxo;
val.satoshis = prev_tx->outputs[idx].satoshi; /* Raw: type conversion */
val = amount_sat(prev_tx->outputs[idx].satoshi);
} else
abort();

3
bitcoin/test/run-bitcoin_block_from_hex.c

@ -16,6 +16,9 @@ bool amount_asset_is_main(struct amount_asset *asset UNNEEDED)
/* Generated stub for amount_asset_to_sat */
struct amount_sat amount_asset_to_sat(struct amount_asset *asset UNNEEDED)
{ fprintf(stderr, "amount_asset_to_sat called!\n"); abort(); }
/* Generated stub for amount_sat */
struct amount_sat amount_sat(u64 satoshis UNNEEDED)
{ fprintf(stderr, "amount_sat called!\n"); abort(); }
/* Generated stub for amount_sat_add */
bool amount_sat_add(struct amount_sat *val UNNEEDED,
struct amount_sat a UNNEEDED,

3
bitcoin/test/run-tx-encode.c

@ -17,6 +17,9 @@ bool amount_asset_is_main(struct amount_asset *asset UNNEEDED)
/* Generated stub for amount_asset_to_sat */
struct amount_sat amount_asset_to_sat(struct amount_asset *asset UNNEEDED)
{ fprintf(stderr, "amount_asset_to_sat called!\n"); abort(); }
/* Generated stub for amount_sat */
struct amount_sat amount_sat(u64 satoshis UNNEEDED)
{ fprintf(stderr, "amount_sat called!\n"); abort(); }
/* Generated stub for amount_sat_add */
bool amount_sat_add(struct amount_sat *val UNNEEDED,
struct amount_sat a UNNEEDED,

2
channeld/full_channel.c

@ -85,7 +85,7 @@ static bool balance_ok(const struct balance *balance,
{
if (balance->msat < 0)
return false;
msat->millisatoshis = balance->msat; /* Raw: balance */
*msat = amount_msat(balance->msat);
return true;
}

3
cli/test/run-large-input.c

@ -42,6 +42,9 @@ bool amount_asset_is_main(struct amount_asset *asset UNNEEDED)
/* Generated stub for amount_asset_to_sat */
struct amount_sat amount_asset_to_sat(struct amount_asset *asset UNNEEDED)
{ fprintf(stderr, "amount_asset_to_sat called!\n"); abort(); }
/* Generated stub for amount_sat */
struct amount_sat amount_sat(u64 satoshis UNNEEDED)
{ fprintf(stderr, "amount_sat called!\n"); abort(); }
/* Generated stub for amount_sat_add */
bool amount_sat_add(struct amount_sat *val UNNEEDED,
struct amount_sat a UNNEEDED,

3
cli/test/run-remove-hint.c

@ -45,6 +45,9 @@ bool amount_asset_is_main(struct amount_asset *asset UNNEEDED)
/* Generated stub for amount_asset_to_sat */
struct amount_sat amount_asset_to_sat(struct amount_asset *asset UNNEEDED)
{ fprintf(stderr, "amount_asset_to_sat called!\n"); abort(); }
/* Generated stub for amount_sat */
struct amount_sat amount_sat(u64 satoshis UNNEEDED)
{ fprintf(stderr, "amount_sat called!\n"); abort(); }
/* Generated stub for amount_sat_add */
bool amount_sat_add(struct amount_sat *val UNNEEDED,
struct amount_sat a UNNEEDED,

2
common/amount.c

@ -487,7 +487,7 @@ struct amount_asset amount_sat_to_asset(struct amount_sat *sat, const u8 *asset)
assert(33 == sizeof(amt_asset.asset));
memcpy(amt_asset.asset, asset, sizeof(amt_asset.asset));
amt_asset.value = sat->satoshis; /* Raw: type conversion */
amt_asset.value = sat->satoshis;
return amt_asset;
}

2
common/bolt11.c

@ -662,7 +662,7 @@ struct bolt11 *bolt11_decode(const tal_t *ctx, const char *str,
"Invalid sub-millisatoshi amount"
" '%sp'", amountstr);
b11->msat->millisatoshis = amount * m10 / 10; /* Raw: raw amount multiplier calculation */
*b11->msat = amount_msat(amount * m10 / 10);
}
/* BOLT #11:

4
common/onion.c

@ -400,8 +400,8 @@ struct onion_payload *onion_decode(const tal_t *ctx,
&tlv->payment_data->payment_secret);
tal_free(p->total_msat);
p->total_msat = tal(p, struct amount_msat);
p->total_msat->millisatoshis /* Raw: tu64 on wire */
= tlv->payment_data->total_msat;
*p->total_msat
= amount_msat(tlv->payment_data->total_msat);
}
tal_free(tlv);
return p;

2
common/penalty_base.c

@ -14,7 +14,7 @@ struct penalty_base *penalty_base_new(const tal_t *ctx,
bitcoin_txid(tx, &pbase->txid);
pbase->outnum = txout - tx->wtx->outputs;
assert(pbase->outnum < tx->wtx->num_outputs);
pbase->amount.satoshis = txout->satoshi; /* Raw: from wally_tx_output */
pbase->amount = amount_sat(txout->satoshi);
return pbase;
}

3
common/test/run-bigsize.c

@ -22,6 +22,9 @@ bool amount_asset_is_main(struct amount_asset *asset UNNEEDED)
/* Generated stub for amount_asset_to_sat */
struct amount_sat amount_asset_to_sat(struct amount_asset *asset UNNEEDED)
{ fprintf(stderr, "amount_asset_to_sat called!\n"); abort(); }
/* Generated stub for amount_sat */
struct amount_sat amount_sat(u64 satoshis UNNEEDED)
{ fprintf(stderr, "amount_sat called!\n"); abort(); }
/* Generated stub for amount_sat_add */
bool amount_sat_add(struct amount_sat *val UNNEEDED,
struct amount_sat a UNNEEDED,

3
common/test/run-cryptomsg.c

@ -17,6 +17,9 @@ bool amount_asset_is_main(struct amount_asset *asset UNNEEDED)
/* Generated stub for amount_asset_to_sat */
struct amount_sat amount_asset_to_sat(struct amount_asset *asset UNNEEDED)
{ fprintf(stderr, "amount_asset_to_sat called!\n"); abort(); }
/* Generated stub for amount_sat */
struct amount_sat amount_sat(u64 satoshis UNNEEDED)
{ fprintf(stderr, "amount_sat called!\n"); abort(); }
/* Generated stub for amount_sat_add */
bool amount_sat_add(struct amount_sat *val UNNEEDED,
struct amount_sat a UNNEEDED,

3
common/test/run-derive_basepoints.c

@ -18,6 +18,9 @@ bool amount_asset_is_main(struct amount_asset *asset UNNEEDED)
/* Generated stub for amount_asset_to_sat */
struct amount_sat amount_asset_to_sat(struct amount_asset *asset UNNEEDED)
{ fprintf(stderr, "amount_asset_to_sat called!\n"); abort(); }
/* Generated stub for amount_sat */
struct amount_sat amount_sat(u64 satoshis UNNEEDED)
{ fprintf(stderr, "amount_sat called!\n"); abort(); }
/* Generated stub for amount_sat_add */
bool amount_sat_add(struct amount_sat *val UNNEEDED,
struct amount_sat a UNNEEDED,

3
common/test/run-features.c

@ -17,6 +17,9 @@ bool amount_asset_is_main(struct amount_asset *asset UNNEEDED)
/* Generated stub for amount_asset_to_sat */
struct amount_sat amount_asset_to_sat(struct amount_asset *asset UNNEEDED)
{ fprintf(stderr, "amount_asset_to_sat called!\n"); abort(); }
/* Generated stub for amount_sat */
struct amount_sat amount_sat(u64 satoshis UNNEEDED)
{ fprintf(stderr, "amount_sat called!\n"); abort(); }
/* Generated stub for amount_sat_add */
bool amount_sat_add(struct amount_sat *val UNNEEDED,
struct amount_sat a UNNEEDED,

3
common/test/run-gossip_rcvd_filter.c

@ -14,6 +14,9 @@ bool amount_asset_is_main(struct amount_asset *asset UNNEEDED)
/* Generated stub for amount_asset_to_sat */
struct amount_sat amount_asset_to_sat(struct amount_asset *asset UNNEEDED)
{ fprintf(stderr, "amount_asset_to_sat called!\n"); abort(); }
/* Generated stub for amount_sat */
struct amount_sat amount_sat(u64 satoshis UNNEEDED)
{ fprintf(stderr, "amount_sat called!\n"); abort(); }
/* Generated stub for amount_sat_add */
bool amount_sat_add(struct amount_sat *val UNNEEDED,
struct amount_sat a UNNEEDED,

3
common/test/run-ip_port_parsing.c

@ -16,6 +16,9 @@ bool amount_asset_is_main(struct amount_asset *asset UNNEEDED)
/* Generated stub for amount_asset_to_sat */
struct amount_sat amount_asset_to_sat(struct amount_asset *asset UNNEEDED)
{ fprintf(stderr, "amount_asset_to_sat called!\n"); abort(); }
/* Generated stub for amount_sat */
struct amount_sat amount_sat(u64 satoshis UNNEEDED)
{ fprintf(stderr, "amount_sat called!\n"); abort(); }
/* Generated stub for amount_sat_add */
bool amount_sat_add(struct amount_sat *val UNNEEDED,
struct amount_sat a UNNEEDED,

3
common/test/run-json_remove.c

@ -14,6 +14,9 @@ bool amount_asset_is_main(struct amount_asset *asset UNNEEDED)
/* Generated stub for amount_asset_to_sat */
struct amount_sat amount_asset_to_sat(struct amount_asset *asset UNNEEDED)
{ fprintf(stderr, "amount_asset_to_sat called!\n"); abort(); }
/* Generated stub for amount_sat */
struct amount_sat amount_sat(u64 satoshis UNNEEDED)
{ fprintf(stderr, "amount_sat called!\n"); abort(); }
/* Generated stub for amount_sat_add */
bool amount_sat_add(struct amount_sat *val UNNEEDED,
struct amount_sat a UNNEEDED,

3
common/test/run-key_derive.c

@ -19,6 +19,9 @@ bool amount_asset_is_main(struct amount_asset *asset UNNEEDED)
/* Generated stub for amount_asset_to_sat */
struct amount_sat amount_asset_to_sat(struct amount_asset *asset UNNEEDED)
{ fprintf(stderr, "amount_asset_to_sat called!\n"); abort(); }
/* Generated stub for amount_sat */
struct amount_sat amount_sat(u64 satoshis UNNEEDED)
{ fprintf(stderr, "amount_sat called!\n"); abort(); }
/* Generated stub for amount_sat_add */
bool amount_sat_add(struct amount_sat *val UNNEEDED,
struct amount_sat a UNNEEDED,

3
common/test/run-lock.c

@ -18,6 +18,9 @@ bool amount_asset_is_main(struct amount_asset *asset UNNEEDED)
/* Generated stub for amount_asset_to_sat */
struct amount_sat amount_asset_to_sat(struct amount_asset *asset UNNEEDED)
{ fprintf(stderr, "amount_asset_to_sat called!\n"); abort(); }
/* Generated stub for amount_sat */
struct amount_sat amount_sat(u64 satoshis UNNEEDED)
{ fprintf(stderr, "amount_sat called!\n"); abort(); }
/* Generated stub for amount_sat_add */
bool amount_sat_add(struct amount_sat *val UNNEEDED,
struct amount_sat a UNNEEDED,

3
common/test/run-softref.c

@ -15,6 +15,9 @@ bool amount_asset_is_main(struct amount_asset *asset UNNEEDED)
/* Generated stub for amount_asset_to_sat */
struct amount_sat amount_asset_to_sat(struct amount_asset *asset UNNEEDED)
{ fprintf(stderr, "amount_asset_to_sat called!\n"); abort(); }
/* Generated stub for amount_sat */
struct amount_sat amount_sat(u64 satoshis UNNEEDED)
{ fprintf(stderr, "amount_sat called!\n"); abort(); }
/* Generated stub for amount_sat_add */
bool amount_sat_add(struct amount_sat *val UNNEEDED,
struct amount_sat a UNNEEDED,

3
common/test/run-sphinx.c

@ -31,6 +31,9 @@ struct amount_msat amount_msat(u64 millisatoshis UNNEEDED)
/* Generated stub for amount_msat_eq */
bool amount_msat_eq(struct amount_msat a UNNEEDED, struct amount_msat b UNNEEDED)
{ fprintf(stderr, "amount_msat_eq called!\n"); abort(); }
/* Generated stub for amount_sat */
struct amount_sat amount_sat(u64 satoshis UNNEEDED)
{ fprintf(stderr, "amount_sat called!\n"); abort(); }
/* Generated stub for amount_sat_add */
bool amount_sat_add(struct amount_sat *val UNNEEDED,
struct amount_sat a UNNEEDED,

3
connectd/test/run-initiator-success.c

@ -21,6 +21,9 @@ bool amount_asset_is_main(struct amount_asset *asset UNNEEDED)
/* Generated stub for amount_asset_to_sat */
struct amount_sat amount_asset_to_sat(struct amount_asset *asset UNNEEDED)
{ fprintf(stderr, "amount_asset_to_sat called!\n"); abort(); }
/* Generated stub for amount_sat */
struct amount_sat amount_sat(u64 satoshis UNNEEDED)
{ fprintf(stderr, "amount_sat called!\n"); abort(); }
/* Generated stub for amount_sat_add */
bool amount_sat_add(struct amount_sat *val UNNEEDED,
struct amount_sat a UNNEEDED,

3
connectd/test/run-responder-success.c

@ -21,6 +21,9 @@ bool amount_asset_is_main(struct amount_asset *asset UNNEEDED)
/* Generated stub for amount_asset_to_sat */
struct amount_sat amount_asset_to_sat(struct amount_asset *asset UNNEEDED)
{ fprintf(stderr, "amount_asset_to_sat called!\n"); abort(); }
/* Generated stub for amount_sat */
struct amount_sat amount_sat(u64 satoshis UNNEEDED)
{ fprintf(stderr, "amount_sat called!\n"); abort(); }
/* Generated stub for amount_sat_add */
bool amount_sat_add(struct amount_sat *val UNNEEDED,
struct amount_sat a UNNEEDED,

2
devtools/onion.c

@ -83,7 +83,7 @@ static void do_generate(int argc, char **argv,
/* FIXME: support secret and and total_msat */
memset(&scid, i, sizeof(scid));
amt.millisatoshis = i; /* Raw: test code */
amt = amount_msat(i);
if (i == num_hops - 1)
sphinx_add_hop(sp, &path[i],
take(onion_final_hop(NULL,

2
gossipd/routing.c

@ -2906,7 +2906,7 @@ void remove_all_gossip(struct routing_state *rstate)
while ((c = uintmap_first(&rstate->chanmap, &index)) != NULL) {
uintmap_del(&rstate->chanmap, index);
#if DEVELOPER
c->sat.satoshis = (unsigned long)c; /* Raw: dev-hack */
c->sat = amount_sat((unsigned long)c);
#endif
tal_free(c);
}

Loading…
Cancel
Save