PostgresWalletStorage class
PostgreSQL implementation of ReadModelStorage.
Provides read model storage for wallets, UTXOs, transactions, addresses, invoices, payment channels, and SPV data (block headers, merkle proofs).
- Implemented types
Constructors
- PostgresWalletStorage(PostgresConfig _config)
- Creates a new PostgresWalletStorage with the given configuration.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
checkAddresses(
String walletId, List< String> addresses) → Future<Map< String, bool> > -
Batch check if addresses belong to wallet (optimized for bulk operations)
override
-
close(
) → Future< void> - Closes the storage and releases resources.
-
deletePaymentChannel(
String channelId) → Future< void> -
Delete a payment channel
override
-
deleteUTXO(
String walletId, String txid, int vout) → Future< void> -
Delete a UTXO from the read model.
override
-
deleteWallet(
String walletId) → Future< void> -
Delete all data for a specific wallet.
override
-
getAddressCount(
String walletId) → Future< int> -
Get the count of addresses for a wallet (for verification during import)
override
-
getAddressesWithMetadata(
String walletId, {bool? includeUnused, bool? isChange, int? limit, int? offset}) → Future< List< AddressMetadata> > -
Get all addresses for a wallet with pagination
override
-
getAddressMetadata(
String walletId, String address) → Future< AddressMetadata?> -
Get address metadata if it belongs to wallet
override
-
getAddressRange(
String walletId, {required int startIndex, required int count, bool isChange = false}) → Future< List< AddressMetadata> > -
Get addresses by derivation range (efficient for HD wallets)
override
-
getAddressTransactionCount(
String walletId, String address) → Future< int> -
Get transaction count for an address
override
-
getAvailableUTXOs(
String walletId) → Future< List< BitcoinUtxo> > -
Get only available (unspent and unreserved) UTXOs for a wallet.
override
-
getBalance(
String walletId) → Future< BigInt> -
Calculate the total balance for a wallet.
override
-
getBestHeight(
) → Future< int> -
Get current best block height
override
-
getBlockHeaderByHash(
String hash) → Future< BlockHeader?> -
Get block header by hash
override
-
getBlockHeaderByHeight(
int height) → Future< BlockHeader?> -
Get block header by height
override
-
getBlockHeaderRange(
int fromHeight, int toHeight) → Future< List< BlockHeader> > -
Get range of block headers
override
-
getChainTip(
) → Future< BlockHeader?> -
Get current chain tip header
override
-
getHeightByBlockHash(
String hash) → Future< int?> -
Get height for a block hash
override
-
getInvoice(
String invoiceId) → Future -
Get a specific invoice by ID.
override
-
getInvoicesByStatus(
dynamic status, {String? walletId}) → Future< List> -
Get all invoices with a specific status.
override
-
getInvoicesByWallet(
String walletId) → Future< List> -
Get all invoices for a specific wallet.
override
-
getMerkleProof(
String txid) → Future< MerkleProof?> -
Get merkle proof for a transaction
override
-
getMerkleProofCount(
{String? walletId}) → Future< int> -
Get the count of stored merkle proofs.
override
-
getMerkleProofsBatch(
List< String> txids) → Future<Map< String, MerkleProof> > -
Batch get merkle proofs by txid list
override
-
getMerkleProofsForBlock(
String blockHash) → Future< List< MerkleProof> > -
Get all merkle proofs for a block
override
-
getPaymentChannel(
String channelId) → Future -
Get a payment channel by ID
override
-
getPaymentChannelsForWallet(
String walletId) → Future< List> -
Get all payment channels for a wallet
override
-
getRecentHeaders(
int count) → Future< List< BlockHeader> > -
Get recent block headers
override
-
getTransaction(
String txid) → Future< BitcoinTransaction?> -
Get a specific transaction by ID
override
-
getTransactionAddresses(
String walletId, String txid) → Future< TransactionAddresses> -
Get all addresses involved in a transaction
override
-
getTransactionHistory(
String walletId, {int? limit, int? offset}) → Future< List< BitcoinTransaction> > -
Get transaction history for a wallet
override
-
getTransactionsBatch(
List< String> txids) → Future<Map< String, BitcoinTransaction> > -
Batch get transactions by txid list
override
-
getTransactionsByAddress(
String walletId, String address, {String? direction, int? limit, int? offset}) → Future< List< String> > -
Get all transactions involving a specific address
override
-
getTransactionsByStatus(
TransactionStatus status, {String? walletId}) → Future< List< BitcoinTransaction> > -
Get transactions by status
override
-
getUTXOs(
String walletId, {bool includeSpent = false}) → Future< List< BitcoinUtxo> > -
Get all UTXOs for a specific wallet.
override
-
getUTXOsByPlugin(
String walletId, String pluginId, {Map< String, dynamic> ? metadataFilter}) → Future<List< BitcoinUtxo> > -
Get UTXOs managed by a specific plugin.
override
-
getWallet(
String walletId) → Future< Map< String, dynamic> ?> -
Get wallet metadata
override
-
getWalletAddresses(
String walletId) → Future< List< String> > -
Get all addresses for a wallet
override
-
getWalletIds(
) → Future< List< String> > -
Get a list of all wallet IDs in storage.
override
-
initialize(
) → Future< void> - Initializes the storage by creating the connection pool.
-
isWalletAddress(
String walletId, String address) → Future< bool> -
Check if an address belongs to a wallet (O(1) hash lookup)
override
-
listWallets(
) → Future< List< String> > -
List all wallet IDs
override
-
markHeaderAsOrphaned(
String hash) → Future< void> -
Mark a block header as orphaned due to reorganization
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
storeBlockHeader(
BlockHeader header, int height) → Future< void> -
Store a block header at a specific height
override
-
storeBlockHeadersBulk(
List< (BlockHeader, int)> headers) → Future<void> -
Bulk store block headers for fast initial sync (CDN import).
override
-
storeInvoice(
dynamic invoice) → Future< void> -
Store an invoice in the read model.
override
-
storeMerkleProof(
String txid, MerkleProof proof) → Future< void> -
Store merkle proof for a transaction
override
-
storePaymentChannel(
dynamic channel) → Future< void> -
Store a payment channel
override
-
storeTransaction(
String walletId, BitcoinTransaction transaction) → Future< void> -
Store a raw transaction in the read model.
override
-
storeTransactionAddresses(
String walletId, String txid, List< TransactionAddressLink> links) → Future<void> -
Store transaction-address junction records
override
-
storeWallet(
String walletId, String name, {String? rootAddress, String? networkType, Map< String, dynamic> ? metadata}) → Future<void> -
Store or update wallet metadata
override
-
toString(
) → String -
A string representation of this object.
inherited
-
updateAddressUsage(
String walletId, String address, {DateTime? usedAt, BigInt? balanceDelta}) → Future< void> -
Update address usage statistics
override
-
updateInvoiceStatus(
String invoiceId, dynamic status, {String? txid, BigInt? amountReceived, DateTime? paidAt}) → Future< void> -
Update the status of an invoice.
override
-
updatePaymentChannelBalance(
String channelId, BigInt clientBalance, BigInt serverBalance) → Future< void> -
Update payment channel balances
override
-
updatePaymentChannelState(
String channelId, String state) → Future< void> -
Update payment channel state
override
-
upsertAddress(
String walletId, AddressMetadata metadata) → Future< void> -
Store or update address metadata
override
-
upsertUTXO(
String walletId, BitcoinUtxo utxo) → Future< void> -
Upsert (insert or update) a UTXO in the read model.
override
-
walletExists(
String walletId) → Future< bool> -
Check if a wallet exists in storage.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited