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_dependency "faraday", "> 0.8"
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"
end

View File

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

View File

@ -19,12 +19,12 @@ module BlockstreamSatellite
end
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
def request(http_method, path, params=nil, body=nil)
response = http_client.send(http_method) do |req|
req.url "/api/#{path}"
req.url "/#{path}"
req.params = params if params
req.body = body if body
yield req if block_given?

View File

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