MCPcopy Create free account
hub / github.com/ElementsProject/lightning / find_push_amts

Function find_push_amts

plugins/bkpr/bookkeeper.c:551–605  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

549}
550
551static void find_push_amts(const char *buf,
552 const jsmntok_t *curr_chan,
553 bool is_opener,
554 struct amount_msat *push_credit,
555 struct amount_msat *push_debit,
556 bool *is_leased)
557{
558 const char *err;
559 struct amount_msat push_amt;
560
561 /* Try to pull out fee_rcvd_msat */
562 err = json_scan(tmpctx, buf, curr_chan,
563 "{funding:{fee_rcvd_msat:%}}",
564 JSON_SCAN(json_to_msat,
565 push_credit));
566
567 if (!err) {
568 *is_leased = true;
569 *push_debit = AMOUNT_MSAT(0);
570 return;
571 }
572
573 /* Try to pull out fee_paid_msat */
574 err = json_scan(tmpctx, buf, curr_chan,
575 "{funding:{fee_paid_msat:%}}",
576 JSON_SCAN(json_to_msat,
577 push_debit));
578 if (!err) {
579 *is_leased = true;
580 *push_credit = AMOUNT_MSAT(0);
581 return;
582 }
583
584 /* Try to pull out pushed amt? */
585 err = json_scan(tmpctx, buf, curr_chan,
586 "{funding:{pushed_msat:%}}",
587 JSON_SCAN(json_to_msat, &push_amt));
588
589 if (!err) {
590 *is_leased = false;
591 if (is_opener) {
592 *push_credit = AMOUNT_MSAT(0);
593 *push_debit = push_amt;
594 } else {
595 *push_credit = push_amt;
596 *push_debit = AMOUNT_MSAT(0);
597 }
598 return;
599 }
600
601 /* Nothing pushed nor fees paid */
602 *is_leased = false;
603 *push_credit = AMOUNT_MSAT(0);
604 *push_debit = AMOUNT_MSAT(0);
605}
606
607static bool new_missed_channel_account(struct command *cmd,
608 const char *buf,

Callers 1

Calls 1

json_scanFunction · 0.50

Tested by

no test coverage detected