1
0
mirror of https://github.com/bumi/blockstream_satellite synced 2025-07-25 16:26:57 +00:00

Update for satellite mainnet launch

This commit is contained in:
bumi 2019-03-15 19:30:37 +01:00
parent d3865a65a4
commit 899a458de5
4 changed files with 7 additions and 12 deletions

View File

@ -39,6 +39,6 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "rspec", "~> 3.0" spec.add_development_dependency "rspec", "~> 3.0"
spec.add_dependency "faraday", "> 0.8" spec.add_dependency "faraday", "> 0.8"
spec.add_dependency "faraday_middleware", ">0.12" spec.add_dependency "faraday_middleware", ">0.12"
spec.add_dependency "lnrpc", ">= 0.1.0" spec.add_dependency "lnrpc", ">= 0.5.2"
spec.add_dependency "activesupport", ">= 5.0.1" spec.add_dependency "activesupport", ">= 5.0.1"
end end

View File

@ -9,7 +9,7 @@ module BlockstreamSatellite
autoload :Configuration, 'blockstream_satellite/configuration' autoload :Configuration, 'blockstream_satellite/configuration'
autoload :Response, 'blockstream_satellite/response' autoload :Response, 'blockstream_satellite/response'
API_HOST = 'https://satellite.blockstream.com' API_HOST = 'https://api.blockstream.space'
def self.lnd_client=(value) def self.lnd_client=(value)
@lnd_client = value @lnd_client = value

View File

@ -19,12 +19,12 @@ module BlockstreamSatellite
end end
def pay(payreq) def pay(payreq)
self.lnd_client.send_payment_sync(Lnrpc::SendRequest.new(payment_request: payreq)) self.lnd_client.send_payment_sync(payment_request: payreq)
end end
def request(http_method, path, params=nil, body=nil) def request(http_method, path, params=nil, body=nil)
response = http_client.send(http_method) do |req| response = http_client.send(http_method) do |req|
req.url "/api/#{path}" req.url "/#{path}"
req.params = params if params req.params = params if params
req.body = body if body req.body = body if body
yield req if block_given? yield req if block_given?

View File

@ -25,16 +25,11 @@ module BlockstreamSatellite
end end
def self.create(options) def self.create(options)
if data = options.delete(:data) if path = options.delete(:path)
file = Tempfile.new(SecureRandom.hex(5)) options[:file] = UploadIO.new(options[:file], 'text/plain') # TODO: get rid of this content type here
file.write(data)
file.rewind
options[:file] = file
elsif path = options.delete(:path)
options[:file] = File.open(path) options[:file] = File.open(path)
end end
options[:bid] ||= options[:file].size * 51 # default price options[:bid] ||= (options[:file] || options[:message]).size * 51 # default price
options[:file] = UploadIO.new(options[:file], 'text/plain') # TODO: get rid of this content type here
response = BlockstreamSatellite.client.post('order', options) response = BlockstreamSatellite.client.post('order', options)
if response.success? if response.success?
Order.new(response.body).tap { |o| o.file = options[:file] } Order.new(response.body).tap { |o| o.file = options[:file] }