mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-19 05:44:12 +01:00
db: add amount functions.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
7fad7bccba
commit
1d1fcc41b8
28
wallet/db.c
28
wallet/db.c
@ -943,3 +943,31 @@ bool sqlite3_bind_json_escaped(sqlite3_stmt *stmt, int col,
|
|||||||
int err = sqlite3_bind_text(stmt, col, esc->s, strlen(esc->s), SQLITE_TRANSIENT);
|
int err = sqlite3_bind_text(stmt, col, esc->s, strlen(esc->s), SQLITE_TRANSIENT);
|
||||||
return err == SQLITE_OK;
|
return err == SQLITE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct amount_msat sqlite3_column_amount_msat(sqlite3_stmt *stmt, int col)
|
||||||
|
{
|
||||||
|
struct amount_msat msat;
|
||||||
|
|
||||||
|
msat.millisatoshis = sqlite3_column_int64(stmt, col);
|
||||||
|
return msat;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct amount_sat sqlite3_column_amount_sat(sqlite3_stmt *stmt, int col)
|
||||||
|
{
|
||||||
|
struct amount_sat sat;
|
||||||
|
|
||||||
|
sat.satoshis = sqlite3_column_int64(stmt, col);
|
||||||
|
return sat;
|
||||||
|
}
|
||||||
|
|
||||||
|
void sqlite3_bind_amount_msat(sqlite3_stmt *stmt, int col,
|
||||||
|
struct amount_msat msat)
|
||||||
|
{
|
||||||
|
sqlite3_bind_int64(stmt, col, msat.millisatoshis);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sqlite3_bind_amount_sat(sqlite3_stmt *stmt, int col,
|
||||||
|
struct amount_sat sat)
|
||||||
|
{
|
||||||
|
sqlite3_bind_int64(stmt, col, sat.satoshis);
|
||||||
|
}
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include <bitcoin/tx.h>
|
#include <bitcoin/tx.h>
|
||||||
#include <ccan/short_types/short_types.h>
|
#include <ccan/short_types/short_types.h>
|
||||||
#include <ccan/tal/tal.h>
|
#include <ccan/tal/tal.h>
|
||||||
|
#include <common/amount.h>
|
||||||
#include <secp256k1_ecdh.h>
|
#include <secp256k1_ecdh.h>
|
||||||
#include <sqlite3.h>
|
#include <sqlite3.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
@ -170,4 +171,11 @@ struct json_escaped *sqlite3_column_json_escaped(const tal_t *ctx,
|
|||||||
sqlite3_stmt *stmt, int col);
|
sqlite3_stmt *stmt, int col);
|
||||||
bool sqlite3_bind_json_escaped(sqlite3_stmt *stmt, int col,
|
bool sqlite3_bind_json_escaped(sqlite3_stmt *stmt, int col,
|
||||||
const struct json_escaped *esc);
|
const struct json_escaped *esc);
|
||||||
|
|
||||||
|
struct amount_msat sqlite3_column_amount_msat(sqlite3_stmt *stmt, int col);
|
||||||
|
struct amount_sat sqlite3_column_amount_sat(sqlite3_stmt *stmt, int col);
|
||||||
|
void sqlite3_bind_amount_msat(sqlite3_stmt *stmt, int col,
|
||||||
|
struct amount_msat msat);
|
||||||
|
void sqlite3_bind_amount_sat(sqlite3_stmt *stmt, int col,
|
||||||
|
struct amount_sat sat);
|
||||||
#endif /* LIGHTNING_WALLET_DB_H */
|
#endif /* LIGHTNING_WALLET_DB_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user