diff --git a/blockstream_satellite.gemspec b/blockstream_satellite.gemspec index 156b278..b247106 100644 --- a/blockstream_satellite.gemspec +++ b/blockstream_satellite.gemspec @@ -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 diff --git a/lib/blockstream_satellite.rb b/lib/blockstream_satellite.rb index 598692e..e6924f4 100644 --- a/lib/blockstream_satellite.rb +++ b/lib/blockstream_satellite.rb @@ -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 diff --git a/lib/blockstream_satellite/client.rb b/lib/blockstream_satellite/client.rb index 27e3635..3faa6ed 100644 --- a/lib/blockstream_satellite/client.rb +++ b/lib/blockstream_satellite/client.rb @@ -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? diff --git a/lib/blockstream_satellite/order.rb b/lib/blockstream_satellite/order.rb index ab91572..242477a 100644 --- a/lib/blockstream_satellite/order.rb +++ b/lib/blockstream_satellite/order.rb @@ -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] }