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

Function parse_and_log_channel_move

plugins/bkpr/bookkeeper.c:1600–1679  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1598}
1599
1600static struct command_result *
1601parse_and_log_channel_move(struct command *cmd,
1602 const char *buf,
1603 const jsmntok_t *params,
1604 const char *acct_name STEALS,
1605 const struct amount_msat credit,
1606 const struct amount_msat debit,
1607 const char *coin_type STEALS,
1608 const u64 timestamp,
1609 const enum mvt_tag *tags,
1610 const char *desc)
1611{
1612 struct channel_event *e = tal(cmd, struct channel_event);
1613 struct account *acct;
1614 const char *err;
1615
1616 e->payment_id = tal(e, struct sha256);
1617 err = json_scan(tmpctx, buf, params,
1618 "{coin_movement:{payment_hash:%}}",
1619 JSON_SCAN(json_to_sha256, e->payment_id));
1620 if (err) {
1621 e->payment_id = tal_free(e->payment_id);
1622 err = tal_free(err);
1623 }
1624
1625 err = json_scan(tmpctx, buf, params,
1626 "{coin_movement:{part_id:%}}",
1627 JSON_SCAN(json_to_number, &e->part_id));
1628 if (err) {
1629 e->part_id = 0;
1630 err = tal_free(err);
1631 }
1632
1633 err = json_scan(tmpctx, buf, params,
1634 "{coin_movement:{fees_msat:%}}",
1635 JSON_SCAN(json_to_msat, &e->fees));
1636 if (err) {
1637 e->fees = AMOUNT_MSAT(0);
1638 err = tal_free(err);
1639 }
1640
1641 e->credit = credit;
1642 e->debit = debit;
1643 e->currency = tal_steal(e, coin_type);
1644 e->timestamp = timestamp;
1645 e->tag = mvt_tag_str(tags[0]);
1646 e->desc = tal_steal(e, desc);
1647 e->rebalance_id = NULL;
1648
1649 /* Go find the account for this event */
1650 db_begin_transaction(db);
1651 acct = find_account(tmpctx, db, acct_name);
1652 if (!acct)
1653 plugin_err(cmd->plugin,
1654 "Received channel event,"
1655 " but no account exists %s",
1656 acct_name);
1657

Callers 1

json_coin_movedFunction · 0.85

Calls 11

tal_freeFunction · 0.85
find_accountFunction · 0.85
log_channel_eventFunction · 0.85
amount_msat_zeroFunction · 0.85
maybe_record_rebalanceFunction · 0.85
lookup_invoice_descFunction · 0.85
notification_handledFunction · 0.85
json_scanFunction · 0.50
mvt_tag_strFunction · 0.50
plugin_errFunction · 0.50
db_commit_transactionFunction · 0.50

Tested by

no test coverage detected