| 6888 | } |
| 6889 | |
| 6890 | static u64 insert_channel_mvt(struct lightningd *ld, |
| 6891 | struct db *db, |
| 6892 | const struct channel_coin_mvt *chan_mvt) |
| 6893 | { |
| 6894 | struct db_stmt *stmt; |
| 6895 | u64 id; |
| 6896 | |
| 6897 | stmt = db_prepare_v2(db, |
| 6898 | SQL("INSERT INTO channel_moves (" |
| 6899 | " id," |
| 6900 | " account_channel_id," |
| 6901 | " account_nonchannel_id," |
| 6902 | " credit_or_debit," |
| 6903 | " tag_bitmap," |
| 6904 | " timestamp," |
| 6905 | " payment_hash," |
| 6906 | " payment_part_id," |
| 6907 | " payment_group_id," |
| 6908 | " fees) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);")); |
| 6909 | id = channel_mvt_index_created(ld, db, |
| 6910 | &chan_mvt->account, |
| 6911 | chan_mvt->credit, chan_mvt->debit); |
| 6912 | db_bind_u64(stmt, id); |
| 6913 | db_bind_mvt_account_id(stmt, db, &chan_mvt->account); |
| 6914 | db_bind_credit_debit(stmt, chan_mvt->credit, chan_mvt->debit); |
| 6915 | db_bind_mvt_tags(stmt, chan_mvt->tags); |
| 6916 | db_bind_u64(stmt, chan_mvt->timestamp); |
| 6917 | /* push funding / leases don't have a payment_hash */ |
| 6918 | if (chan_mvt->payment_hash) |
| 6919 | db_bind_sha256(stmt, chan_mvt->payment_hash); |
| 6920 | else |
| 6921 | db_bind_null(stmt); |
| 6922 | if (chan_mvt->part_and_group) { |
| 6923 | db_bind_u64(stmt, chan_mvt->part_and_group->part_id); |
| 6924 | db_bind_u64(stmt, chan_mvt->part_and_group->group_id); |
| 6925 | } else { |
| 6926 | db_bind_null(stmt); |
| 6927 | db_bind_null(stmt); |
| 6928 | } |
| 6929 | db_bind_amount_msat(stmt, chan_mvt->fees); |
| 6930 | db_exec_prepared_v2(take(stmt)); |
| 6931 | |
| 6932 | notify_channel_mvt(ld, chan_mvt, id); |
| 6933 | tal_free_if_taken(chan_mvt); |
| 6934 | |
| 6935 | return id; |
| 6936 | } |
| 6937 | |
| 6938 | void wallet_save_channel_mvt(struct lightningd *ld, |
| 6939 | const struct channel_coin_mvt *chan_mvt) |
no test coverage detected