mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-03 18:57:06 +01:00
db: route to extract an array of struct secret from a column.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
2cbe5b65c7
commit
9b99b74c41
2 changed files with 14 additions and 1 deletions
12
wallet/db.c
12
wallet/db.c
|
@ -525,6 +525,18 @@ bool sqlite3_column_sha256_double(sqlite3_stmt *stmt, int col, struct sha256_do
|
||||||
return memcpy(dest, sqlite3_column_blob(stmt, col), sizeof(struct sha256_double));
|
return memcpy(dest, sqlite3_column_blob(stmt, col), sizeof(struct sha256_double));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct secret *sqlite3_column_secrets(const tal_t *ctx,
|
||||||
|
sqlite3_stmt *stmt, int col)
|
||||||
|
{
|
||||||
|
struct secret *secrets;
|
||||||
|
size_t n = sqlite3_column_bytes(stmt, col) / sizeof(*secrets);
|
||||||
|
|
||||||
|
/* Must fit exactly */
|
||||||
|
assert(n * sizeof(struct secret) == sqlite3_column_bytes(stmt, col));
|
||||||
|
secrets = tal_arr(ctx, struct secret, n);
|
||||||
|
return memcpy(secrets, sqlite3_column_blob(stmt, col), tal_len(secrets));
|
||||||
|
}
|
||||||
|
|
||||||
bool sqlite3_bind_sha256_double(sqlite3_stmt *stmt, int col, const struct sha256_double *p)
|
bool sqlite3_bind_sha256_double(sqlite3_stmt *stmt, int col, const struct sha256_double *p)
|
||||||
{
|
{
|
||||||
sqlite3_bind_blob(stmt, col, p, sizeof(struct sha256_double), SQLITE_TRANSIENT);
|
sqlite3_bind_blob(stmt, col, p, sizeof(struct sha256_double), SQLITE_TRANSIENT);
|
||||||
|
|
|
@ -134,5 +134,6 @@ bool sqlite3_bind_sha256(sqlite3_stmt *stmt, int col, const struct sha256 *p);
|
||||||
|
|
||||||
bool sqlite3_column_sha256_double(sqlite3_stmt *stmt, int col, struct sha256_double *dest);
|
bool sqlite3_column_sha256_double(sqlite3_stmt *stmt, int col, struct sha256_double *dest);
|
||||||
bool sqlite3_bind_sha256_double(sqlite3_stmt *stmt, int col, const struct sha256_double *p);
|
bool sqlite3_bind_sha256_double(sqlite3_stmt *stmt, int col, const struct sha256_double *p);
|
||||||
|
struct secret *sqlite3_column_secrets(const tal_t *ctx,
|
||||||
|
sqlite3_stmt *stmt, int col);
|
||||||
#endif /* WALLET_DB_H */
|
#endif /* WALLET_DB_H */
|
||||||
|
|
Loading…
Add table
Reference in a new issue