| 6948 | } |
| 6949 | |
| 6950 | static u64 insert_channel_mvt(struct lightningd *ld, |
| 6951 | struct db *db, |
| 6952 | const struct channel_coin_mvt *chan_mvt) |
| 6953 | { |
| 6954 | struct db_stmt *stmt; |
| 6955 | u64 id; |
| 6956 | |
| 6957 | stmt = db_prepare_v2(db, |
| 6958 | SQL("INSERT INTO channel_moves (" |
| 6959 | " id," |
| 6960 | " account_channel_id," |
| 6961 | " account_nonchannel_id," |
| 6962 | " credit_or_debit," |
| 6963 | " tag_bitmap," |
| 6964 | " timestamp," |
| 6965 | " payment_hash," |
| 6966 | " payment_part_id," |
| 6967 | " payment_group_id," |
| 6968 | " fees) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);")); |
| 6969 | id = channel_mvt_index_created(ld, db, |
| 6970 | &chan_mvt->account, |
| 6971 | chan_mvt->credit, chan_mvt->debit); |
| 6972 | db_bind_u64(stmt, id); |
| 6973 | db_bind_mvt_account_id(stmt, db, &chan_mvt->account); |
| 6974 | db_bind_credit_debit(stmt, chan_mvt->credit, chan_mvt->debit); |
| 6975 | db_bind_mvt_tags(stmt, chan_mvt->tags); |
| 6976 | db_bind_u64(stmt, chan_mvt->timestamp); |
| 6977 | /* push funding / leases don't have a payment_hash */ |
| 6978 | if (chan_mvt->payment_hash) |
| 6979 | db_bind_sha256(stmt, chan_mvt->payment_hash); |
| 6980 | else |
| 6981 | db_bind_null(stmt); |
| 6982 | if (chan_mvt->part_and_group) { |
| 6983 | db_bind_u64(stmt, chan_mvt->part_and_group->part_id); |
| 6984 | db_bind_u64(stmt, chan_mvt->part_and_group->group_id); |
| 6985 | } else { |
| 6986 | db_bind_null(stmt); |
| 6987 | db_bind_null(stmt); |
| 6988 | } |
| 6989 | db_bind_amount_msat(stmt, chan_mvt->fees); |
| 6990 | db_exec_prepared_v2(take(stmt)); |
| 6991 | |
| 6992 | notify_channel_mvt(ld, chan_mvt, id); |
| 6993 | tal_free_if_taken(chan_mvt); |
| 6994 | |
| 6995 | return id; |
| 6996 | } |
| 6997 | |
| 6998 | void wallet_save_channel_mvt(struct lightningd *ld, |
| 6999 | const struct channel_coin_mvt *chan_mvt) |
no test coverage detected