| 364 | } |
| 365 | |
| 366 | WARN_UNUSED_RESULT bool amount_msat_scale(struct amount_msat *val, |
| 367 | struct amount_msat msat, |
| 368 | double scale) |
| 369 | { |
| 370 | if (scale != scale || scale < 0) |
| 371 | return false; |
| 372 | |
| 373 | double scaled = msat.millisatoshis * scale; |
| 374 | |
| 375 | /* If mantissa is < 64 bits, a naive "if (scaled > |
| 376 | * UINT64_MAX)" doesn't work. Stick to powers of 2. */ |
| 377 | if (scaled >= (double)((u64)1 << 63) * 2) |
| 378 | return false; |
| 379 | val->millisatoshis = scaled; |
| 380 | return true; |
| 381 | } |
| 382 | |
| 383 | WARN_UNUSED_RESULT bool amount_sat_scale(struct amount_sat *val, |
| 384 | struct amount_sat sat, |
no outgoing calls
no test coverage detected