mirror of
https://github.com/bumi/faraday_ln_paywall
synced 2025-06-16 09:15:35 +00:00
Add support to path macaraoon hex directly
This commit is contained in:
parent
3d5e28dd8b
commit
0c963ffa7c
@ -2,8 +2,11 @@ require "bundler/setup"
|
|||||||
require "faraday_ln_paywall"
|
require "faraday_ln_paywall"
|
||||||
require "faraday"
|
require "faraday"
|
||||||
|
|
||||||
conn = Faraday.new(:url => 'https://api.lightning.ws') do |faraday|
|
conn = Faraday.new(:url => 'https://fourohtwo.herokuapp.com') do |faraday|
|
||||||
faraday.use FaradayLnPaywall::Middleware, { max_amount: 100 }
|
faraday.use FaradayLnPaywall::Middleware, {
|
||||||
|
max_amount: 1000,
|
||||||
|
timeout: 300
|
||||||
|
}
|
||||||
faraday.adapter Faraday.default_adapter
|
faraday.adapter Faraday.default_adapter
|
||||||
end
|
end
|
||||||
puts conn.get("/translate?text=Hallo%20Welt&to=en").body
|
puts conn.get("/402").body
|
||||||
|
@ -14,8 +14,10 @@ module FaradayLnPaywall
|
|||||||
@options[:address] ||= 'localhost:10009'
|
@options[:address] ||= 'localhost:10009'
|
||||||
@options[:timeout] ||= 5
|
@options[:timeout] ||= 5
|
||||||
@options[:credentials] ||= File.read(File.expand_path(@options[:credentials_path] || "~/.lnd/tls.cert"))
|
@options[:credentials] ||= File.read(File.expand_path(@options[:credentials_path] || "~/.lnd/tls.cert"))
|
||||||
macaroon_binary ||= File.read(File.expand_path(@options[:macaroon_path] || "~/.lnd/data/chain/bitcoin/testnet/admin.macaroon"))
|
@options[:macaroon] ||= begin
|
||||||
@options[:macaroon] = macaroon_binary.each_byte.map { |b| b.to_s(16).rjust(2,'0') }.join
|
macaroon_binary = ::File.read(::File.expand_path(@options[:macaroon_path] || "~/.lnd/data/chain/bitcoin/testnet/admin.macaroon"))
|
||||||
|
macaroon_binary.each_byte.map { |b| b.to_s(16).rjust(2,'0') }.join
|
||||||
|
end
|
||||||
@lnd_client = Lnrpc::Lightning::Stub.new(@options[:address], GRPC::Core::ChannelCredentials.new(@options[:credentials]))
|
@lnd_client = Lnrpc::Lightning::Stub.new(@options[:address], GRPC::Core::ChannelCredentials.new(@options[:credentials]))
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -50,7 +52,7 @@ module FaradayLnPaywall
|
|||||||
payment = pay(response_env)
|
payment = pay(response_env)
|
||||||
if payment && payment.payment_error == ""
|
if payment && payment.payment_error == ""
|
||||||
preimage = payment.payment_preimage.each_byte.map { |b| b.to_s(16).rjust(2, '0') }.join
|
preimage = payment.payment_preimage.each_byte.map { |b| b.to_s(16).rjust(2, '0') }.join
|
||||||
request_env[:request_headers].merge!({'X-Preimage' => preimage})
|
request_env[:request_headers].merge!('X-Preimage' => preimage)
|
||||||
@app.call(request_env)
|
@app.call(request_env)
|
||||||
else
|
else
|
||||||
raise PaymentError, payment.payment_error
|
raise PaymentError, payment.payment_error
|
||||||
|
Loading…
x
Reference in New Issue
Block a user