| 381 | } |
| 382 | |
| 383 | WARN_UNUSED_RESULT bool amount_sat_scale(struct amount_sat *val, |
| 384 | struct amount_sat sat, |
| 385 | double scale) |
| 386 | { |
| 387 | if (scale != scale || scale < 0) |
| 388 | return false; |
| 389 | |
| 390 | double scaled = sat.satoshis * scale; |
| 391 | |
| 392 | /* If mantissa is < 64 bits, a naive "if (scaled > |
| 393 | * UINT64_MAX)" doesn't work. Stick to powers of 2. */ |
| 394 | if (scaled >= (double)((u64)1 << 63) * 2) |
| 395 | return false; |
| 396 | val->satoshis = scaled; |
| 397 | return true; |
| 398 | } |
| 399 | |
| 400 | WARN_UNUSED_RESULT bool amount_msat_add_sat_s64(struct amount_msat *val, |
| 401 | struct amount_msat a, |
no outgoing calls
no test coverage detected