mirror of
				https://github.com/bumi/blockstream_satellite
				synced 2025-11-04 06:00:23 +00:00 
			
		
		
		
	Update for satellite mainnet launch
This commit is contained in:
		
							parent
							
								
									d3865a65a4
								
							
						
					
					
						commit
						899a458de5
					
				@ -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
 | 
				
			||||||
 | 
				
			|||||||
@ -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
 | 
				
			||||||
 | 
				
			|||||||
@ -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?
 | 
				
			||||||
 | 
				
			|||||||
@ -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] }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user