Net out credit/debit --> basically find the diff */
| 751 | |
| 752 | /* Net out credit/debit --> basically find the diff */ |
| 753 | static char *msat_net(const tal_t *ctx, |
| 754 | struct amount_msat credit, |
| 755 | struct amount_msat debit, |
| 756 | struct amount_msat *credit_net, |
| 757 | struct amount_msat *debit_net) |
| 758 | { |
| 759 | if (amount_msat_eq(credit, debit)) { |
| 760 | *credit_net = AMOUNT_MSAT(0); |
| 761 | *debit_net = AMOUNT_MSAT(0); |
| 762 | } else if (amount_msat_greater(credit, debit)) { |
| 763 | if (!amount_msat_sub(credit_net, credit, debit)) |
| 764 | return tal_fmt(ctx, "unexpected fail, can't sub." |
| 765 | " %s - %s", |
| 766 | type_to_string(ctx, struct amount_msat, |
| 767 | &credit), |
| 768 | type_to_string(ctx, struct amount_msat, |
| 769 | &debit)); |
| 770 | *debit_net = AMOUNT_MSAT(0); |
| 771 | } else { |
| 772 | if (!amount_msat_sub(debit_net, debit, credit)) { |
| 773 | return tal_fmt(ctx, "unexpected fail, can't sub." |
| 774 | " %s - %s", |
| 775 | type_to_string(ctx, |
| 776 | struct amount_msat, |
| 777 | &debit), |
| 778 | type_to_string(ctx, |
| 779 | struct amount_msat, |
| 780 | &credit)); |
| 781 | } |
| 782 | *credit_net = AMOUNT_MSAT(0); |
| 783 | } |
| 784 | |
| 785 | return NULL; |
| 786 | } |
| 787 | |
| 788 | static char *msat_find_diff(struct amount_msat balance, |
| 789 | struct amount_msat credits, |
no test coverage detected