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

Function parse_and_log_chain_move

plugins/bkpr/bookkeeper.c:1381–1598  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1379 return notification_handled(cmd);
1380}
1381static struct command_result *
1382parse_and_log_chain_move(struct command *cmd,
1383 const char *buf,
1384 const jsmntok_t *params,
1385 const char *acct_name STEALS,
1386 const struct amount_msat credit,
1387 const struct amount_msat debit,
1388 const char *coin_type STEALS,
1389 const u64 timestamp,
1390 const enum mvt_tag *tags,
1391 const char *desc)
1392{
1393 struct chain_event *e = tal(cmd, struct chain_event);
1394 struct sha256 *payment_hash = tal(cmd, struct sha256);
1395 struct bitcoin_txid *spending_txid = tal(cmd, struct bitcoin_txid);
1396 struct node_id *peer_id;
1397 struct account *acct, *orig_acct;
1398 u32 closed_count;
1399 const char *err;
1400
1401 /* Fields we expect on *every* chain movement */
1402 err = json_scan(tmpctx, buf, params,
1403 "{coin_movement:"
1404 "{utxo_txid:%"
1405 ",vout:%"
1406 ",output_msat:%"
1407 ",blockheight:%"
1408 "}}",
1409 JSON_SCAN(json_to_txid, &e->outpoint.txid),
1410 JSON_SCAN(json_to_number, &e->outpoint.n),
1411 JSON_SCAN(json_to_msat, &e->output_value),
1412 JSON_SCAN(json_to_number, &e->blockheight));
1413
1414 if (err)
1415 plugin_err(cmd->plugin,
1416 "`coin_movement` payload did"
1417 " not scan %s: %.*s",
1418 err, json_tok_full_len(params),
1419 json_tok_full(buf, params));
1420
1421 /* Now try to get out the optional parts */
1422 err = json_scan(tmpctx, buf, params,
1423 "{coin_movement:"
1424 "{txid:%"
1425 "}}",
1426 JSON_SCAN(json_to_txid, spending_txid));
1427
1428 if (err) {
1429 spending_txid = tal_free(spending_txid);
1430 err = tal_free(err);
1431 }
1432
1433 e->spending_txid = tal_steal(e, spending_txid);
1434
1435 /* Now try to get out the optional parts */
1436 err = json_scan(tmpctx, buf, params,
1437 "{coin_movement:"
1438 "{payment_hash:%"

Callers 1

json_coin_movedFunction · 0.85

Calls 15

tal_freeFunction · 0.85
find_accountFunction · 0.85
new_accountFunction · 0.85
account_addFunction · 0.85
log_chain_eventFunction · 0.85
notification_handledFunction · 0.85
maybe_update_accountFunction · 0.85
is_channel_accountFunction · 0.85
do_account_close_checksFunction · 0.85
lookup_invoice_descFunction · 0.85

Tested by

no test coverage detected