Skip to content

Commit

Permalink
Replace electrumx with electrs (#274)
Browse files Browse the repository at this point in the history
* replace electrumx with electrs

* update rpc interface to implement electrs rpc; the main thing here is that parameters are now passed in based on their position, rather than json object key/value pairings
* replace "electrumx" with "electrs" in source code
* update localnet to use electrs

* removed remaining electrumx mentions
  • Loading branch information
ClaytonNorthey92 authored Oct 7, 2024
1 parent 70c3fd7 commit fd5c4b2
Show file tree
Hide file tree
Showing 13 changed files with 188 additions and 212 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ go run ./integrationtest
### 🏁 Prerequisites

- A **PostgreSQL database**, bfgd expects the sql scripts in `./database/bfgd/scripts/` to be run to set up your schema.
- A **connection to an ElectrumX node** on the proper Bitcoin network (testnet or mainnet).
- A **connection to an Electrs node** on the proper Bitcoin network (testnet or mainnet).

## ▶️ Running bssd

Expand Down
6 changes: 3 additions & 3 deletions cmd/bfgd/bfgd.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ var (
"BFG_EXBTC_ADDRESS": config.Config{
Value: &cfg.EXBTCAddress,
DefaultValue: "localhost:18001",
Help: "electrumx endpoint",
Help: "electrs endpoint",
Print: config.PrintAll,
},
"BFG_EXBTC_INITIAL_CONNECTIONS": config.Config{
Value: &cfg.EXBTCInitialConns,
DefaultValue: 5,
Help: "electrumx initial connections",
Help: "electrs initial connections",
Print: config.PrintAll,
},
"BFG_EXBTC_MAX_CONNECTIONS": config.Config{
Value: &cfg.EXBTCMaxConns,
DefaultValue: 100,
Help: "electrumx max connections",
Help: "electrs max connections",
Print: config.PrintAll,
},
"BFG_PUBLIC_KEY_AUTH": config.Config{
Expand Down
6 changes: 3 additions & 3 deletions cmd/extool/extool.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (

btcchainhash "github.com/btcsuite/btcd/chaincfg/chainhash"

"github.com/hemilabs/heminetwork/hemi/electrumx"
"github.com/hemilabs/heminetwork/hemi/electrs"
"github.com/hemilabs/heminetwork/version"
)

Expand All @@ -37,12 +37,12 @@ func main() {
log.Fatal("No address specified")
}

c, err := electrumx.NewClient(address, &electrumx.ClientOptions{
c, err := electrs.NewClient(address, &electrs.ClientOptions{
InitialConnections: 1,
MaxConnections: 1,
})
if err != nil {
log.Fatalf("Failed to create electrumx client: %v", err)
log.Fatalf("Failed to create electrs client: %v", err)
}

ctx, ctxCancel := context.WithTimeout(context.Background(), 10*time.Second)
Expand Down
1 change: 1 addition & 0 deletions e2e/cookie
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
user:password
36 changes: 23 additions & 13 deletions e2e/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ services:
- "-rpcport=18443"
- "-rpcconnect=bitcoind"
- "generatetoaddress"
- "3000" # need to generate a lot for greater chance to not spend coinbase
- "1000" # need to generate a lot for greater chance to not spend coinbase
- "$BTC_ADDRESS"
restart: on-failure

Expand All @@ -55,19 +55,28 @@ services:
- "1"
- "$BTC_ADDRESS"

electrumx:
image: "lukechilds/electrumx@sha256:2949784536f8f85af229004e12e5b5c3a1d7428918a492f77b4e958035c2ae2a"
electrs:
build:
context: https://github.com/romanz/electrs.git#1d02f10ec38edbc3b7df6b16bb8989d9bc0aaa0f
depends_on:
- "bitcoind"
ports:
- "50001:8000"
environment:
DAEMON_URL: "http://user:password@bitcoind:18443"
COIN: "Bitcoin"
COST_HARD_LIMIT: "0"
COST_SOFT_LIMIT: "0"
MAX_SEND: "8388608"
NET: "regtest"
command:
- electrs
- --electrum-rpc-addr
- '0.0.0.0:50001'
- --daemon-rpc-addr
- "bitcoind:18443"
- --daemon-p2p-addr
- "bitcoind:18444"
- --network
- regtest
- --cookie-file
- "/tmp/.cookie"
volumes:
- ./cookie:/tmp/.cookie
deploy:
restart_policy:
condition: "on-failure"

bfgd-postgres:
build:
Expand Down Expand Up @@ -96,13 +105,14 @@ services:
condition: "any"
depends_on:
- "bfgd-postgres"
- "electrs"
ports:
- "8080:8080"
- "8383:8383"
environment:
BFG_POSTGRES_URI: "postgres://postgres@bfgd-postgres:5432/bfg?sslmode=disable"
BFG_BTC_START_HEIGHT: "1"
BFG_EXBTC_ADDRESS: "electrumx:50001"
BFG_EXBTC_ADDRESS: "electrs:50001"
BFG_LOG_LEVEL: "INFO"
BFG_PUBLIC_ADDRESS: ":8383"
BFG_PRIVATE_ADDRESS: ":8080"
Expand Down
Loading

0 comments on commit fd5c4b2

Please sign in to comment.