Add PostgreSQL support for mint and wallet (#878)

* Add PostgreSQL support for mint and wallet

* Fixed bug to avoid empty calls `get_proofs_states`

* Fixed SQL bug

* Avoid redudant clone()

* Add more tests for the storage layer

* Minor enhacements

* Add a generic function to execute db operations

This function would log slow operations and log errors

* Provision a postgres db for tests

* Update deps for msrv

* Add postgres to pipeline

* feat: add psgl to example and docker

* feat: db url fmt

---------

Co-authored-by: thesimplekid <tsk@thesimplekid.com>
This commit is contained in:
C
2025-08-18 13:45:11 -03:00
committed by GitHub
parent 2e424e629f
commit 28a01398fd
34 changed files with 1282 additions and 40 deletions

View File

@@ -45,6 +45,7 @@ struct Args {
/// Start a fake mint with authentication using the library
async fn start_fake_auth_mint(
temp_dir: &Path,
database: &str,
port: u16,
openid_discovery: String,
shutdown: Arc<Notify>,
@@ -62,6 +63,7 @@ async fn start_fake_auth_mint(
let mut settings = shared::create_fake_wallet_settings(
port,
database,
Some(Mnemonic::generate(12)?.to_string()),
None,
Some(fake_wallet_config),
@@ -123,6 +125,7 @@ async fn main() -> Result<()> {
let handle = start_fake_auth_mint(
&temp_dir,
&args.database_type,
args.port,
args.openid_discovery.clone(),
shutdown_clone,

View File

@@ -46,6 +46,7 @@ struct Args {
async fn start_fake_mint(
temp_dir: &Path,
port: u16,
database: &str,
shutdown: Arc<Notify>,
external_signatory: bool,
) -> Result<tokio::task::JoinHandle<()>> {
@@ -77,8 +78,13 @@ async fn start_fake_mint(
});
// Create settings struct for fake mint using shared function
let settings =
shared::create_fake_wallet_settings(port, mnemonic, signatory_config, fake_wallet_config);
let settings = shared::create_fake_wallet_settings(
port,
database,
mnemonic,
signatory_config,
fake_wallet_config,
);
println!("Starting fake mintd on port {port}");
@@ -129,6 +135,7 @@ async fn main() -> Result<()> {
let handle = start_fake_mint(
&temp_dir,
args.port,
&args.database_type,
shutdown_clone,
args.external_signatory,
)

View File

@@ -11,6 +11,7 @@ use std::time::Duration;
use anyhow::Result;
use cdk_axum::cache;
use cdk_mintd::config::{Database, DatabaseEngine};
use tokio::signal;
use tokio::sync::Notify;
@@ -150,6 +151,7 @@ pub fn display_mint_info(port: u16, temp_dir: &Path, database_type: &str) {
/// Create settings for a fake wallet mint
pub fn create_fake_wallet_settings(
port: u16,
database: &str,
mnemonic: Option<String>,
signatory_config: Option<(String, String)>, // (url, certs_dir)
fake_wallet_config: Option<cdk_mintd::config::FakeWallet>,
@@ -182,7 +184,10 @@ pub fn create_fake_wallet_settings(
lnd: None,
fake_wallet: fake_wallet_config,
grpc_processor: None,
database: cdk_mintd::config::Database::default(),
database: Database {
engine: DatabaseEngine::from_str(database).expect("valid database"),
postgres: None,
},
mint_management_rpc: None,
auth: None,
}