Skip to content

Commit fe9f29d

Browse files
authored
Add local regtest payment setup with esplora (#494)
1 parent 6cb15a5 commit fe9f29d

File tree

14 files changed

+101
-11
lines changed

14 files changed

+101
-11
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/target
22
/contacts/*
3+
/esplora/.docker_data/
34
data/
45
/frontend_build/*
56
/identity/*

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 0.3.9
2+
3+
* Add possibility to use a local regtest esplora setup for payment
4+
15
# 0.3.8
26

37
* Add `esplora_base_url` as config parameter to be able to use a custom esplora based block explorer

crates/bcr-ebill-api/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bcr-ebill-api"
3-
version = "0.3.8"
3+
version = "0.3.9"
44
edition = "2024"
55

66
[lib]

crates/bcr-ebill-api/src/external/bitcoin.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ impl BitcoinClient {
8181
Network::Bitcoin => {
8282
format!("{}/api{path}", get_config().esplora_base_url)
8383
}
84+
Network::Regtest => {
85+
format!("{}/regtest/api{path}", get_config().esplora_base_url)
86+
}
8487
_ => {
8588
format!("{}/testnet/api{path}", get_config().esplora_base_url)
8689
}
@@ -92,6 +95,9 @@ impl BitcoinClient {
9295
Network::Bitcoin => {
9396
format!("{}{path}", get_config().esplora_base_url)
9497
}
98+
Network::Regtest => {
99+
format!("{}/regtest{path}", get_config().esplora_base_url)
100+
}
95101
_ => {
96102
format!("{}/testnet{path}", get_config().esplora_base_url)
97103
}

crates/bcr-ebill-core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bcr-ebill-core"
3-
version = "0.3.8"
3+
version = "0.3.9"
44
edition = "2024"
55

66
[lib]

crates/bcr-ebill-persistence/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bcr-ebill-persistence"
3-
version = "0.3.8"
3+
version = "0.3.9"
44
edition = "2024"
55

66
[lib]

crates/bcr-ebill-transport/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bcr-ebill-transport"
3-
version = "0.3.8"
3+
version = "0.3.9"
44
edition = "2024"
55

66
[lib]

crates/bcr-ebill-wasm/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bcr-ebill-wasm"
3-
version = "0.3.8"
3+
version = "0.3.9"
44
edition = "2024"
55

66
[lib]

crates/bcr-ebill-wasm/main.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ document.getElementById("clear_bill_cache").addEventListener("click", clearBillC
3030
async function start() {
3131
let config = {
3232
log_level: "debug",
33-
bitcoin_network: "testnet",
34-
esplora_base_url: "https://blockstream.info",
33+
bitcoin_network: "regtest", // local reg test
34+
esplora_base_url: "http://localhost:8094", // local reg test via docker-compose
35+
// bitcoin_network: "testnet",
36+
// esplora_base_url: "https://blockstream.info",
3537
nostr_relay: "wss://bitcr-cloud-run-05-550030097098.europe-west1.run.app",
3638
job_runner_initial_delay_seconds: 1,
3739
job_runner_check_interval_seconds: 600,
@@ -224,9 +226,9 @@ async function triggerBill() {
224226

225227
const now = new Date();
226228
const issue_date = now.toISOString().split('T')[0];
227-
const threeMonthsLater = new Date(now);
228-
threeMonthsLater.setMonth(now.getMonth() + 3);
229-
const maturity_date = threeMonthsLater.toISOString().split('T')[0];
229+
const nMonthsLater = new Date(now);
230+
nMonthsLater.setMonth(now.getMonth() + 0); // use to set maturity date after issue date
231+
const maturity_date = nMonthsLater.toISOString().split('T')[0];
230232

231233
let file_upload_id = document.getElementById("file_upload_id").value || undefined;
232234
let node_id = document.getElementById("node_id_bill").value;

crates/bcr-ebill-web/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bcr-ebill-web"
3-
version = "0.3.8"
3+
version = "0.3.9"
44
edition = "2024"
55

66
[dependencies]

0 commit comments

Comments
 (0)