Skip to content

Commit

Permalink
Expand blockchain host compatibility (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
aurelienshz authored Oct 12, 2023
1 parent a8a73cf commit cb5edb8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/pinetwork.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ def initialize(api_key, wallet_private_key, options = {})
@api_key = api_key
@account = load_account(wallet_private_key)
@base_url = options[:base_url] || "https://api.minepi.com"
@mainnet_host = options[:mainnet_host] || "api.mainnet.minepi.com"
@testnet_host = options[:testnet_host] || "api.testnet.minepi.com"

@open_payments = {}
end
Expand Down Expand Up @@ -143,8 +145,9 @@ def handle_http_response(response, unknown_error_message = "An unknown error occ
end

def set_horizon_client(network)
host = network == "Pi Network" ? "api.mainnet.minepi.com" : "api.testnet.minepi.com"
horizon = network == "Pi Network" ? "https://api.mainnet.minepi.com" : "https://api.testnet.minepi.com"
host = (network.starts_with? "Pi Network") ? @mainnet_host : @testnet_host
horizon = "https://#{host}"

client = Stellar::Client.new(host: host, horizon: horizon)
Stellar::default_network = network

Expand Down

0 comments on commit cb5edb8

Please sign in to comment.