upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/wallet_sqlite.h
blob: 5e6467b2ea33b88f0301203db34644d7c9990043 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright (c) 2026 Bitflash developers
// Distributed under the MIT/X11 software license.

#ifndef BITFLASH_WALLET_SQLITE_H
#define BITFLASH_WALLET_SQLITE_H

#include <sqlite3.h>

class CWalletRecordVisitor;

class CWalletDBSQLite
{
public:
    CWalletDBSQLite();
    ~CWalletDBSQLite();

    bool Open(const string& strPath, string& strError);
    bool OpenReadOnly(const string& strPath, string& strError);
    void Close();

    bool BeginTransaction(string& strError);
    bool CommitTransaction(string& strError);
    bool RollbackTransaction(string& strError);
    bool Checkpoint(string& strError);

    bool WriteRecord(const vector<unsigned char>& vchKey,
                     const vector<unsigned char>& vchValue,
                     string& strError);
    bool ReadRecord(const vector<unsigned char>& vchKey,
                    vector<unsigned char>& vchValueRet,
                    string& strError);
    bool ScanRecords(CWalletRecordVisitor& visitor, string& strError);
    bool CountRecords(int& nRecordsRet, string& strError);

private:
    sqlite3* pdb;

    bool Exec(const char* pszSql, string& strError);
    bool InitSchema(string& strError);

    CWalletDBSQLite(const CWalletDBSQLite&);
    void operator=(const CWalletDBSQLite&);
};

#endif