bundler-thankyou 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +6 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +34 -0
- data/LICENSE.txt +21 -0
- data/README.md +76 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/bundler-thankyou.gemspec +32 -0
- data/exe/bundler-thankyou +9 -0
- data/lib/bundler/thankyou.rb +52 -0
- data/lib/bundler/thankyou/cli.rb +115 -0
- data/lib/bundler/thankyou/disbursement.rb +80 -0
- data/lib/bundler/thankyou/version.rb +5 -0
- metadata +106 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9e83194e1e683b5aad584eca997d6acc0409a8b5db294196728473743a143067
|
4
|
+
data.tar.gz: 1e4e2e02a1c10b841277d9789f5e885e2dca73d076f4b61faea78cc2816920d8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bf960135a2c1923d549c50ebd63c501f6c752a6b0c9583084809f2618463f42742f25f93f60ff556fa58b8411f5aaf7848bda534ed4167d905f519f018d21719
|
7
|
+
data.tar.gz: 0ad710a81c5a1df0e88f547514e10e444e2ad47db6c1b5e4f4da295dc810435dec0e2ff214831ef6f463a59a90d5e885afbea506a7667aff9c853859fb95b5dc
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
bundler-thankyou (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.3)
|
10
|
+
rake (12.3.3)
|
11
|
+
rspec (3.9.0)
|
12
|
+
rspec-core (~> 3.9.0)
|
13
|
+
rspec-expectations (~> 3.9.0)
|
14
|
+
rspec-mocks (~> 3.9.0)
|
15
|
+
rspec-core (3.9.2)
|
16
|
+
rspec-support (~> 3.9.3)
|
17
|
+
rspec-expectations (3.9.1)
|
18
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
19
|
+
rspec-support (~> 3.9.0)
|
20
|
+
rspec-mocks (3.9.1)
|
21
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
+
rspec-support (~> 3.9.0)
|
23
|
+
rspec-support (3.9.3)
|
24
|
+
|
25
|
+
PLATFORMS
|
26
|
+
ruby
|
27
|
+
|
28
|
+
DEPENDENCIES
|
29
|
+
bundler-thankyou!
|
30
|
+
rake (~> 12.0)
|
31
|
+
rspec (~> 3.0)
|
32
|
+
|
33
|
+
BUNDLED WITH
|
34
|
+
2.1.4
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Michael Bumann
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
# Bundler::Thankyou
|
4
|
+
## lightning donation system for rubygems (and other package managers)
|
5
|
+
|
6
|
+
|
7
|
+
## Background
|
8
|
+
|
9
|
+
### What the author needs to do:
|
10
|
+
|
11
|
+
The gem authoer adds a funding details to the gemspec (in the metadata hash). This currently either can be a lightning node pubkey (that can receive keysend payments) or a LNURL.
|
12
|
+
|
13
|
+
That's it. That is all the author needs to do.
|
14
|
+
|
15
|
+
Because of the funding details are in the gemspec we can be sure it is where the author/maintainer wants the money to go to.
|
16
|
+
|
17
|
+
The author could also decide to dedicate the donations to somebody else. For example the rails gems could say thankyous should go to RailsGirls or similar projects.
|
18
|
+
|
19
|
+
### What the user has to do:
|
20
|
+
|
21
|
+
Use this tool and basically run `bundle thankyou` and specify a desired amount. The amount will automatically be split among all the used gems.
|
22
|
+
|
23
|
+
### Advantages
|
24
|
+
|
25
|
+
* No signup whatsover
|
26
|
+
* User and maintainer do not need to agree on a service (like paypal) to perform the transaction
|
27
|
+
* No central directories
|
28
|
+
* Based on existing tools (rubygems)
|
29
|
+
* Implemented on a "protocol level" - additional service can be built and integrated. (like subscriptions, etc.)
|
30
|
+
* Works internationally
|
31
|
+
* Usable at the moment where the user interacts with the gems (in the terminal running a bundle command)
|
32
|
+
* Minimal fees and all the Bitcoin/Lightning advantages
|
33
|
+
|
34
|
+
## Questions?
|
35
|
+
|
36
|
+
### Why Bitcoin?
|
37
|
+
|
38
|
+
It is pretty much the only adopted solution to build such things.
|
39
|
+
|
40
|
+
### But I want to pay with credit card (or whatever else)
|
41
|
+
|
42
|
+
Bitcoin is used as a method/"protocol" to transfer value.
|
43
|
+
|
44
|
+
We could provide additional services (for both user and project separately) to better fit their needs - for example different payment methods, subscriptions, etc.
|
45
|
+
|
46
|
+
### But I want to receive payments on my credit card
|
47
|
+
|
48
|
+
Again Bitcoin is the "protocol". There are already plenty tools out there that for example give you a visa/master card for spending the received bitcoins.
|
49
|
+
|
50
|
+
## A comment about money
|
51
|
+
|
52
|
+
I am very critical about the human perception of the "payment". I do not want it to feel like I've "paid" somebody for something.
|
53
|
+
The tone/message is super important and it should not be "payment" but a way of saying "thank you"... thus bundle thankyou.
|
54
|
+
|
55
|
+
|
56
|
+
## Installation
|
57
|
+
|
58
|
+
|
59
|
+
## Usage
|
60
|
+
|
61
|
+
|
62
|
+
## Contributing
|
63
|
+
|
64
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/bumi/bundler-thankyou.
|
65
|
+
|
66
|
+
|
67
|
+
## Contact
|
68
|
+
|
69
|
+
If you have questions, feedback, ideas please contact me... or even better open an issue.
|
70
|
+
|
71
|
+
Michael Bumann
|
72
|
+
[@bumi](http://twitter.com/bumi)
|
73
|
+
|
74
|
+
## License
|
75
|
+
|
76
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "bundle/thankyou"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require_relative 'lib/bundler/thankyou/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = 'bundler-thankyou'
|
5
|
+
spec.version = Bundler::Thankyou::VERSION
|
6
|
+
spec.authors = ['Michael Bumann']
|
7
|
+
spec.email = ['hello@michaelbumann.com"']
|
8
|
+
|
9
|
+
spec.summary = %q{Lightning based donation system for rubygems}
|
10
|
+
spec.description = %q{A Bitcoin lightning based donation system that allows to send a "thankyou" to the gems in your Gemfile}
|
11
|
+
spec.homepage = 'https://michaelbumann.com'
|
12
|
+
spec.license = 'MIT'
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
14
|
+
|
15
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
16
|
+
spec.metadata["source_code_uri"] = 'https://github.com/bumi/bundle-thankyou'
|
17
|
+
|
18
|
+
spec.metadata['funding'] = 'lightning:02ad33d99d0bb3bf3bb8ec8e089cbefa8fd7de23a13cfa59aec9af9730816be76f'
|
19
|
+
|
20
|
+
# Specify which files should be added to the gem when it is released.
|
21
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
22
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
23
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
24
|
+
end
|
25
|
+
spec.bindir = 'exe'
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ['lib']
|
28
|
+
|
29
|
+
spec.add_runtime_dependency 'lightning-invoice', '~> 0.1.5'
|
30
|
+
spec.add_runtime_dependency 'lnurl'
|
31
|
+
spec.add_runtime_dependency 'lnrpc', '>= 0.10.0'
|
32
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'bundler'
|
3
|
+
require 'bundler/thankyou/version'
|
4
|
+
require 'bundler/thankyou/disbursement'
|
5
|
+
|
6
|
+
module Bundler
|
7
|
+
module Thankyou
|
8
|
+
class Error < StandardError; end
|
9
|
+
|
10
|
+
@lnd_client = nil
|
11
|
+
|
12
|
+
def self.lnd_client
|
13
|
+
@lnd_client ||= Lnrpc::Client.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.lnd_client=(client)
|
17
|
+
@lnd_client = client
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.specs_from_bundler(options = {})
|
21
|
+
Bundler.load.specs.to_a.tap do |specs|
|
22
|
+
specs.filter! { |s| s.metadata['funding'] && s.metadata['funding'].match?(/^lightning:/) }
|
23
|
+
if options[:only]&.any?
|
24
|
+
specs.filter! { |s| options[:only].include?(s.name) }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.recipients_from_bundler(options = {})
|
30
|
+
specs_from_bundler(options).each_with_object({}) do |spec, memo|
|
31
|
+
memo[spec.name] = 'LNURL1DP68GUP69UHKCMMRV9KXSMMNWSARXVPSXYHKCMN4WFKR76TY85MRXVMRVGERXDPSXQNXU0T9XFNXZVP3X9NRWETP89SKVV34YE6XZEEAWPSHJ5N9W96K2UM5YEKKJMJNV4HXGCTZD3JN6VFSXQCRQFNDV9U9XETWV3SKYMR9856NQVPSXQCRQVPXD4JHGCTYV96XZ02MTVJNYVN5V4U8GFFJGECXCCTFDCJNYV39XFPJ2V3JWA5XZAR9WEJHYFFJXFW46FNN85UKZCFNX4JRZDMRXUCNGVPEVGCXYDNRXYEKXDFKVVCKYWFKXYERYCE3XSEKXWF48Q6NVVTZX33KYD3EXFJRJE3HXQMR2VE4V4JXGDE5FH9YHF' #spec.metadata['funding'].gsub(/^lightning:/, '')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.specs_from_rubygems(names)
|
36
|
+
specs = names.collect do |name|
|
37
|
+
uri = URI("https://rubygems.org/api/v1/gems/#{name}.json")
|
38
|
+
response = Net::HTTP.get_response(uri)
|
39
|
+
if response.is_a?(Net::HTTPSuccess) # ignore gems that are not found
|
40
|
+
JSON.parse(response.body)
|
41
|
+
end
|
42
|
+
end.compact
|
43
|
+
specs.filter { |s| s['metadata'] && s['metadata']['funding'] && s['metadata']['funding'].match?(/^lightning:/) }
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.recipients_from_rubygems(names)
|
47
|
+
specs_from_rubygems(names).each_with_object({}) do |spec, memo|
|
48
|
+
memo[spec['name']] = 'LNURL1DP68GUP69UHKCMMRV9KXSMMNWSARXVPSXYHKCMN4WFKR76TY85MRXVMRVGERXDPSXQNXU0T9XFNXZVP3X9NRWETP89SKVV34YE6XZEEAWPSHJ5N9W96K2UM5YEKKJMJNV4HXGCTZD3JN6VFSXQCRQFNDV9U9XETWV3SKYMR9856NQVPSXQCRQVPXD4JHGCTYV96XZ02MTVJNYVN5V4U8GFFJGECXCCTFDCJNYV39XFPJ2V3JWA5XZAR9WEJHYFFJXFW46FNN85UKZCFNX4JRZDMRXUCNGVPEVGCXYDNRXYEKXDFKVVCKYWFKXYERYCE3XSEKXWF48Q6NVVTZX33KYD3EXFJRJE3HXQMR2VE4V4JXGDE5FH9YHF' #spec['metadata']['funding'].gsub(/^lightning:/, '')
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
require 'bundler/vendored_thor'
|
3
|
+
require 'yaml'
|
4
|
+
require 'lnrpc'
|
5
|
+
|
6
|
+
module Bundler
|
7
|
+
module Thankyou
|
8
|
+
class CLI < Thor
|
9
|
+
include Thor::Actions
|
10
|
+
MINIMUM_AMOUNT = 100 # minimum amount in sats for each recipient
|
11
|
+
|
12
|
+
CONFIG_FILE = File.join(ENV['HOME'], '.bundle-thankyou.yml')
|
13
|
+
attr_accessor :recipients, :amount
|
14
|
+
|
15
|
+
default_task :gemfile
|
16
|
+
|
17
|
+
method_option :amount, type: :numeric, aliases: '-a'
|
18
|
+
method_option :only, type: :array, aliases: '-o'
|
19
|
+
method_option :verbose, type: :boolean, aliases: '-v'
|
20
|
+
desc 'gemfile', 'Send a payment to gems in the Gemfile'
|
21
|
+
def gemfile
|
22
|
+
say "Analyzing Gemfile: #{Bundler.default_gemfile}"
|
23
|
+
say '...'
|
24
|
+
|
25
|
+
self.recipients = Bundler::Thankyou.recipients_from_bundler(options)
|
26
|
+
disburse!
|
27
|
+
end
|
28
|
+
|
29
|
+
method_option :amount, type: :numeric, aliases: '-a'
|
30
|
+
method_option :only, type: :array, aliases: '-o'
|
31
|
+
method_option :verbose, type: :boolean, aliases: '-v'
|
32
|
+
desc 'fund <names>', 'Send to to specific gems'
|
33
|
+
def fund(*names)
|
34
|
+
if names.empty?
|
35
|
+
invoke :gemfile
|
36
|
+
else
|
37
|
+
self.recipients = Bundler::Thankyou.recipients_from_rubygems(names)
|
38
|
+
disburse!
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
desc 'setup', 'Setup your lnd connection'
|
43
|
+
def setup
|
44
|
+
say 'Connecting your LND node'
|
45
|
+
config = {}
|
46
|
+
config['address'] = ask('Address of your LND node (e.g. localhost:10009):')
|
47
|
+
config['macaroon_path'] = ask('Macaroon file path: (e.g. /path/to/admin.macaroon):', path: true)
|
48
|
+
config['credentials_path'] = ask('Credentials file path: (e.g. /path/to/tls.cert):', path: true)
|
49
|
+
add_file(CONFIG_FILE, YAML.dump(config))
|
50
|
+
node_info = lnd_client.lightning.get_info
|
51
|
+
say "Successfully connected to #{node_info['alias']} #{node_info['identity_pubkey']}"
|
52
|
+
end
|
53
|
+
|
54
|
+
no_commands do
|
55
|
+
|
56
|
+
def disburse!
|
57
|
+
say "Found #{recipients.count} fundable gems", Shell::Color::BLUE
|
58
|
+
if recipients.count < 1
|
59
|
+
exit
|
60
|
+
end
|
61
|
+
shell.print_table(recipients.to_a, indent: 4, truncate: true)
|
62
|
+
say
|
63
|
+
|
64
|
+
if options[:amount].nil?
|
65
|
+
self.amount = ask('How many sats do you want do send in total?', Shell::Color::RED).to_i
|
66
|
+
say
|
67
|
+
end
|
68
|
+
Bundler::Thankyou.lnd_client = lnd_client
|
69
|
+
|
70
|
+
say "Sending #{amount} sats split among #{recipients.count} recipients"
|
71
|
+
say
|
72
|
+
if amount / recipients.count < MINIMUM_AMOUNT
|
73
|
+
say "A minimum of #{MINIMUM_AMOUNT * recipients.count} sats is required", Shell::Color::RED
|
74
|
+
exit
|
75
|
+
end
|
76
|
+
|
77
|
+
disbursment = Disbursement.new(recipients: recipients, total_amount: amount)
|
78
|
+
|
79
|
+
shell.indent do
|
80
|
+
disbursment.pay! do |result|
|
81
|
+
states = result[:payment_states].map(&:status)
|
82
|
+
if states.include?(:SUCCEEDED)
|
83
|
+
say "Sent #{result[:amount]} to #{result[:name]}"
|
84
|
+
else
|
85
|
+
say "Failed to send to #{result[:name]}"
|
86
|
+
result[:payment_states].each do |r|
|
87
|
+
say r.inspect
|
88
|
+
end if options[:verbose]
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
say
|
94
|
+
say 'Done! Thank you!', Shell::Color::BLUE
|
95
|
+
end
|
96
|
+
|
97
|
+
def lnd_config
|
98
|
+
if File.exist?(CONFIG_FILE)
|
99
|
+
YAML.safe_load(File.read(CONFIG_FILE)).transform_keys(&:to_sym)
|
100
|
+
else # TODO: check env variables
|
101
|
+
{}
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def lnd_client
|
106
|
+
@lnd_client ||= Lnrpc::Client.new(lnd_config)
|
107
|
+
end
|
108
|
+
|
109
|
+
def amount
|
110
|
+
@amount || options[:amount]
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'lnrpc'
|
2
|
+
require 'lnurl'
|
3
|
+
require 'lightning/invoice'
|
4
|
+
|
5
|
+
module Bundler
|
6
|
+
module Thankyou
|
7
|
+
class Disbursement
|
8
|
+
attr_accessor :total_amount, :recipients
|
9
|
+
|
10
|
+
def initialize(recipients:, total_amount:)
|
11
|
+
self.recipients = recipients
|
12
|
+
self.total_amount = total_amount
|
13
|
+
end
|
14
|
+
|
15
|
+
def amount_per_recipient
|
16
|
+
@amount_per_recipient ||= total_amount / recipients.count
|
17
|
+
end
|
18
|
+
|
19
|
+
def amount_per_recipient_msat
|
20
|
+
amount_per_recipient * 1000
|
21
|
+
end
|
22
|
+
|
23
|
+
def pay!
|
24
|
+
recipients.each do |name, pubkey_or_lnurl|
|
25
|
+
result_array = if Lnurl.valid?(pubkey_or_lnurl)
|
26
|
+
pay_lnurl(pubkey_or_lnurl)
|
27
|
+
else
|
28
|
+
pay_keysend(pubkey_or_lnurl)
|
29
|
+
end
|
30
|
+
yield({ name: name, payment_states: result_array, amount: amount_per_recipient }) if block_given?
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def pay_keysend(pubkey)
|
35
|
+
dest = Lnrpc.to_byte_array(pubkey)
|
36
|
+
Bundler::Thankyou.lnd_client.keysend(dest: dest, amt: amount_per_recipient).to_a
|
37
|
+
end
|
38
|
+
|
39
|
+
def pay_lnurl(lnurl)
|
40
|
+
lnurl = Lnurl.decode(lnurl)
|
41
|
+
lnurl_response = lnurl.response
|
42
|
+
invoice_response = lnurl_response.request_invoice(amount: amount_per_recipient_msat )
|
43
|
+
if invoice_response.status.to_s.downcase == 'error'
|
44
|
+
return [OpenStruct.new(status: 'ERROR', lnurl_response: invoice_response)] # ignore for now. returning an error similar to the response from send_payment_v2
|
45
|
+
end
|
46
|
+
invoice = Lightning::Invoice.parse(invoice_response.pr)
|
47
|
+
if invoice_valid?(invoice: invoice, lnurl_response: lnurl_response)
|
48
|
+
args = { payment_request: invoice_response.pr }
|
49
|
+
args[:amt] = amount_per_recipient if invoice.amount.nil? # if the invoice does not specify an amount
|
50
|
+
Bundler::Thankyou.lnd_client.pay(args).to_a
|
51
|
+
else
|
52
|
+
[OpenStruct.new(status: 'ERROR', message: 'invoice invalid')] # ignoring invalid invoices but keeping the method signature, returning an error similar to the response from send_payment_v2
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def invoice_valid?(invoice:, lnurl_response:)
|
57
|
+
# invalid if the amount is too high
|
58
|
+
return false if !invoice.amount.nil? && invoice_amount_in_satoshi(invoice) > amount_per_recipient
|
59
|
+
# invalid if it is expired
|
60
|
+
return false if Time.now.to_i > invoice.timestamp + (invoice.expiry || 3600).to_i
|
61
|
+
|
62
|
+
# if the invoice does not specify an amount we check if the amount_per_recipient is within the sendable amount defined in the lnurl
|
63
|
+
return false if invoice.amount.nil? && (amount_per_recipient_msat < lnurl_response.minSendable || amount_per_recipient_msat > lnurl_response.maxSendable)
|
64
|
+
|
65
|
+
return true # default
|
66
|
+
end
|
67
|
+
|
68
|
+
def invoice_amount_in_satoshi(invoice)
|
69
|
+
return if invoice.amount.nil?
|
70
|
+
multi = {
|
71
|
+
'm' => 0.001,
|
72
|
+
'u' => 0.000001,
|
73
|
+
'n' => 0.000000001,
|
74
|
+
'p' => 0.000000000001
|
75
|
+
}[invoice.multiplier]
|
76
|
+
(invoice.amount * multi * 100000000).to_i # amount in bitcoin * 100000000
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bundler-thankyou
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Michael Bumann
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-05-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: lightning-invoice
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.1.5
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.1.5
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: lnurl
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: lnrpc
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.10.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.10.0
|
55
|
+
description: A Bitcoin lightning based donation system that allows to send a "thankyou"
|
56
|
+
to the gems in your Gemfile
|
57
|
+
email:
|
58
|
+
- hello@michaelbumann.com"
|
59
|
+
executables:
|
60
|
+
- bundler-thankyou
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- ".gitignore"
|
65
|
+
- ".rspec"
|
66
|
+
- ".travis.yml"
|
67
|
+
- Gemfile
|
68
|
+
- Gemfile.lock
|
69
|
+
- LICENSE.txt
|
70
|
+
- README.md
|
71
|
+
- Rakefile
|
72
|
+
- bin/console
|
73
|
+
- bin/setup
|
74
|
+
- bundler-thankyou.gemspec
|
75
|
+
- exe/bundler-thankyou
|
76
|
+
- lib/bundler/thankyou.rb
|
77
|
+
- lib/bundler/thankyou/cli.rb
|
78
|
+
- lib/bundler/thankyou/disbursement.rb
|
79
|
+
- lib/bundler/thankyou/version.rb
|
80
|
+
homepage: https://michaelbumann.com
|
81
|
+
licenses:
|
82
|
+
- MIT
|
83
|
+
metadata:
|
84
|
+
homepage_uri: https://michaelbumann.com
|
85
|
+
source_code_uri: https://github.com/bumi/bundle-thankyou
|
86
|
+
funding: lightning:02ad33d99d0bb3bf3bb8ec8e089cbefa8fd7de23a13cfa59aec9af9730816be76f
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: 2.3.0
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements: []
|
102
|
+
rubygems_version: 3.0.3
|
103
|
+
signing_key:
|
104
|
+
specification_version: 4
|
105
|
+
summary: Lightning based donation system for rubygems
|
106
|
+
test_files: []
|