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

Function insert_channel_mvt

wallet/wallet.c:6927–6973  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6925}
6926
6927static u64 insert_channel_mvt(struct lightningd *ld,
6928 struct db *db,
6929 const struct channel_coin_mvt *chan_mvt)
6930{
6931 struct db_stmt *stmt;
6932 u64 id;
6933
6934 stmt = db_prepare_v2(db,
6935 SQL("INSERT INTO channel_moves ("
6936 " id,"
6937 " account_channel_id,"
6938 " account_nonchannel_id,"
6939 " credit_or_debit,"
6940 " tag_bitmap,"
6941 " timestamp,"
6942 " payment_hash,"
6943 " payment_part_id,"
6944 " payment_group_id,"
6945 " fees) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"));
6946 id = channel_mvt_index_created(ld, db,
6947 &chan_mvt->account,
6948 chan_mvt->credit, chan_mvt->debit);
6949 db_bind_u64(stmt, id);
6950 db_bind_mvt_account_id(stmt, db, &chan_mvt->account);
6951 db_bind_credit_debit(stmt, chan_mvt->credit, chan_mvt->debit);
6952 db_bind_mvt_tags(stmt, chan_mvt->tags);
6953 db_bind_u64(stmt, chan_mvt->timestamp);
6954 /* push funding / leases don't have a payment_hash */
6955 if (chan_mvt->payment_hash)
6956 db_bind_sha256(stmt, chan_mvt->payment_hash);
6957 else
6958 db_bind_null(stmt);
6959 if (chan_mvt->part_and_group) {
6960 db_bind_u64(stmt, chan_mvt->part_and_group->part_id);
6961 db_bind_u64(stmt, chan_mvt->part_and_group->group_id);
6962 } else {
6963 db_bind_null(stmt);
6964 db_bind_null(stmt);
6965 }
6966 db_bind_amount_msat(stmt, chan_mvt->fees);
6967 db_exec_prepared_v2(take(stmt));
6968
6969 notify_channel_mvt(ld, chan_mvt, id);
6970 tal_free_if_taken(chan_mvt);
6971
6972 return id;
6973}
6974
6975void wallet_save_channel_mvt(struct lightningd *ld,
6976 const struct channel_coin_mvt *chan_mvt)

Callers 2

wallet_save_channel_mvtFunction · 0.85
migrate_setup_coinmovesFunction · 0.85

Calls 11

db_bind_u64Function · 0.85
db_bind_mvt_account_idFunction · 0.85
db_bind_credit_debitFunction · 0.85
db_bind_mvt_tagsFunction · 0.85
db_bind_sha256Function · 0.85
db_bind_nullFunction · 0.85
db_bind_amount_msatFunction · 0.85
db_exec_prepared_v2Function · 0.85
tal_free_if_takenFunction · 0.85
notify_channel_mvtFunction · 0.50

Tested by

no test coverage detected