mirror of
https://github.com/aljazceru/cdk.git
synced 2026-02-04 20:55:59 +01:00
feat: fake wallet
This commit is contained in:
@@ -15,6 +15,7 @@ bitcoin = { version = "0.32.2", default-features = false }
|
||||
cdk = { path = "../cdk", version = "0.4.0", default-features = false, features = ["mint"] }
|
||||
futures = { version = "0.3.28", default-features = false }
|
||||
tokio = { version = "1", default-features = false }
|
||||
tokio-util = { version = "0.7.11", default-features = false }
|
||||
tracing = { version = "0.1", default-features = false, features = ["attributes", "log"] }
|
||||
thiserror = "1"
|
||||
serde = "1"
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::pin::Pin;
|
||||
use std::str::FromStr;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
@@ -33,6 +34,7 @@ use serde::{Deserialize, Serialize};
|
||||
use tokio::sync::Mutex;
|
||||
use tokio::time;
|
||||
use tokio_stream::wrappers::ReceiverStream;
|
||||
use tokio_util::sync::CancellationToken;
|
||||
|
||||
pub mod error;
|
||||
|
||||
@@ -47,6 +49,8 @@ pub struct FakeWallet {
|
||||
payment_states: Arc<Mutex<HashMap<String, MeltQuoteState>>>,
|
||||
failed_payment_check: Arc<Mutex<HashSet<String>>>,
|
||||
payment_delay: u64,
|
||||
wait_invoice_cancel_token: CancellationToken,
|
||||
wait_invoice_is_active: Arc<AtomicBool>,
|
||||
}
|
||||
|
||||
impl FakeWallet {
|
||||
@@ -70,6 +74,8 @@ impl FakeWallet {
|
||||
payment_states: Arc::new(Mutex::new(payment_states)),
|
||||
failed_payment_check: Arc::new(Mutex::new(fail_payment_check)),
|
||||
payment_delay,
|
||||
wait_invoice_cancel_token: CancellationToken::new(),
|
||||
wait_invoice_is_active: Arc::new(AtomicBool::new(false)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -113,11 +119,11 @@ impl MintLightning for FakeWallet {
|
||||
}
|
||||
|
||||
fn is_wait_invoice_active(&self) -> bool {
|
||||
todo!()
|
||||
self.wait_invoice_is_active.load(Ordering::SeqCst)
|
||||
}
|
||||
|
||||
fn cancel_wait_invoice(&self) {
|
||||
todo!()
|
||||
self.wait_invoice_cancel_token.cancel()
|
||||
}
|
||||
|
||||
async fn wait_any_invoice(
|
||||
|
||||
Reference in New Issue
Block a user