btcpay 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 765581c5e126ca0ebd973fb76637dac51de61eb28856a2a5f2e6d9517fb1fc2e
4
+ data.tar.gz: 37787c831f8e977971c70c1d7a9d973e5685e302b1fce04a84fd92f542607cee
5
+ SHA512:
6
+ metadata.gz: b0ce38e683b4901c69de9565713d7d839f80d1ea5b3c8f6a3f0dc235e52f032d05d8d37ebf8534b7cb3ad4399e4ad236b4b50cfcb8ab93f4b7244ce071997a0e
7
+ data.tar.gz: 9e5c178330d04034fe1ee4442457a30f72a94c657c20bec428f189db51db2afe7cd9a5ec4fc5a19d50cb07bceb25ff127b7a61fd052a872a2c083e1823814dc3
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+
13
+ coverage
14
+ .DS_Store
15
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,19 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.7
3
+ Exclude:
4
+ - 'bin/**/*'
5
+ Documentation:
6
+ Enabled: false
7
+ LineLength:
8
+ Max: 120
9
+ Style/RaiseArgs:
10
+ EnforcedStyle: compact
11
+ Metrics/AbcSize:
12
+ Enabled: false
13
+ Metrics/MethodLength:
14
+ Max: 25
15
+ Lint/Debugger:
16
+ Enabled: false
17
+ Metrics/BlockLength:
18
+ Exclude:
19
+ - 'spec/**/*.rb'
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.1
6
+ before_install: gem install bundler -v 2.1.4
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in btcpay.gemspec
6
+ gemspec
7
+
8
+ gem 'rake', '~> 12.0'
9
+ gem 'rspec', '~> 3.0'
@@ -0,0 +1,120 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ btcpay (0.1.0)
5
+ activesupport (> 5)
6
+ multi_json (~> 1.15)
7
+ rest-client (~> 2.1)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ activesupport (6.0.3.2)
13
+ concurrent-ruby (~> 1.0, >= 1.0.2)
14
+ i18n (>= 0.7, < 2)
15
+ minitest (~> 5.1)
16
+ tzinfo (~> 1.1)
17
+ zeitwerk (~> 2.2, >= 2.2.2)
18
+ addressable (2.7.0)
19
+ public_suffix (>= 2.0.2, < 5.0)
20
+ ast (2.4.1)
21
+ coderay (1.1.3)
22
+ concurrent-ruby (1.1.6)
23
+ crack (0.4.3)
24
+ safe_yaml (~> 1.0.0)
25
+ diff-lcs (1.4.4)
26
+ docile (1.3.2)
27
+ domain_name (0.5.20190701)
28
+ unf (>= 0.0.5, < 1.0.0)
29
+ factory_bot (6.1.0)
30
+ activesupport (>= 5.0.0)
31
+ hashdiff (1.0.1)
32
+ http-accept (1.7.0)
33
+ http-cookie (1.0.3)
34
+ domain_name (~> 0.5)
35
+ i18n (1.8.5)
36
+ concurrent-ruby (~> 1.0)
37
+ method_source (1.0.0)
38
+ mime-types (3.3.1)
39
+ mime-types-data (~> 3.2015)
40
+ mime-types-data (3.2020.0512)
41
+ minitest (5.14.1)
42
+ multi_json (1.15.0)
43
+ netrc (0.11.0)
44
+ parallel (1.19.2)
45
+ parser (2.7.1.4)
46
+ ast (~> 2.4.1)
47
+ pry (0.13.1)
48
+ coderay (~> 1.1)
49
+ method_source (~> 1.0)
50
+ public_suffix (4.0.5)
51
+ rainbow (3.0.0)
52
+ rake (12.3.3)
53
+ regexp_parser (1.7.1)
54
+ rest-client (2.1.0)
55
+ http-accept (>= 1.7.0, < 2.0)
56
+ http-cookie (>= 1.0.2, < 2.0)
57
+ mime-types (>= 1.16, < 4.0)
58
+ netrc (~> 0.8)
59
+ rexml (3.2.4)
60
+ rspec (3.9.0)
61
+ rspec-core (~> 3.9.0)
62
+ rspec-expectations (~> 3.9.0)
63
+ rspec-mocks (~> 3.9.0)
64
+ rspec-core (3.9.2)
65
+ rspec-support (~> 3.9.3)
66
+ rspec-expectations (3.9.2)
67
+ diff-lcs (>= 1.2.0, < 2.0)
68
+ rspec-support (~> 3.9.0)
69
+ rspec-mocks (3.9.1)
70
+ diff-lcs (>= 1.2.0, < 2.0)
71
+ rspec-support (~> 3.9.0)
72
+ rspec-support (3.9.3)
73
+ rubocop (0.88.0)
74
+ parallel (~> 1.10)
75
+ parser (>= 2.7.1.1)
76
+ rainbow (>= 2.2.2, < 4.0)
77
+ regexp_parser (>= 1.7)
78
+ rexml
79
+ rubocop-ast (>= 0.1.0, < 1.0)
80
+ ruby-progressbar (~> 1.7)
81
+ unicode-display_width (>= 1.4.0, < 2.0)
82
+ rubocop-ast (0.1.0)
83
+ parser (>= 2.7.0.1)
84
+ ruby-progressbar (1.10.1)
85
+ safe_yaml (1.0.5)
86
+ simplecov (0.18.5)
87
+ docile (~> 1.1)
88
+ simplecov-html (~> 0.11)
89
+ simplecov-html (0.12.2)
90
+ thread_safe (0.3.6)
91
+ tzinfo (1.2.7)
92
+ thread_safe (~> 0.1)
93
+ unf (0.1.4)
94
+ unf_ext
95
+ unf_ext (0.0.7.7)
96
+ unicode-display_width (1.7.0)
97
+ vcr (6.0.0)
98
+ webmock (3.8.3)
99
+ addressable (>= 2.3.6)
100
+ crack (>= 0.3.2)
101
+ hashdiff (>= 0.4.0, < 2.0.0)
102
+ zeitwerk (2.4.0)
103
+
104
+ PLATFORMS
105
+ ruby
106
+
107
+ DEPENDENCIES
108
+ btcpay!
109
+ bundler (~> 2.0)
110
+ factory_bot (~> 6.1)
111
+ pry (> 0)
112
+ rake (~> 12.0)
113
+ rspec (~> 3.0)
114
+ rubocop (> 0)
115
+ simplecov (> 0)
116
+ vcr (~> 6.0)
117
+ webmock (~> 3.8)
118
+
119
+ BUNDLED WITH
120
+ 2.1.4
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 ZippyDev
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.
@@ -0,0 +1,159 @@
1
+ # Btcpay Server
2
+
3
+ [BTCPay Server Api Client](https://btcpayserver.org/)
4
+
5
+ [BTCPay Server is a free and open-source cryptocurrency payment processor which allows you to receive payments in Bitcoin and altcoins directly, with no fees, transaction cost or a middleman.](https://docs.btcpayserver.org/API/Greenfield/v1/)
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'btcpay'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install btcpay
22
+
23
+ ## Usage
24
+
25
+ #### Required Params
26
+
27
+ ##### Auth Token
28
+
29
+ At least one of the following auth tokens are required. Auth tokens can be created via the following:
30
+
31
+ 1. `auth_token`
32
+
33
+ - Scoped Api Tokens can be created via `/Manage/APIKeys`
34
+
35
+ - `BTCPAY_AUTH_TOKEN` environment variable can also be used
36
+
37
+ 1. `basic_auth_token`
38
+
39
+ - Legacy Api Key can be created per store via `/stores/{store-id}/Tokens`
40
+
41
+ - `BTCPAY_BASIC_AUTH_TOKEN` environment variable can also be used
42
+
43
+ ##### Base Url
44
+
45
+ A `base_url` is required to interact with the server.
46
+ - `BTCPAY_BASE_URL` environment variable can also be used
47
+
48
+ ```ruby
49
+ client = BtcPay.new(auth_token: 'foobar', base_url: 'http://localhost:49392')
50
+ ```
51
+
52
+ ### Response
53
+
54
+ A response consists of the following accessible attributes:
55
+
56
+ 1. `#body` - rubified response body
57
+ 1. `#code` - response status code
58
+ 1. `#headers` - response headers
59
+ 1. `#raw` - unaltered response body
60
+ 1. `#status` - `:success`/`:failure`
61
+
62
+ ### Request object types
63
+
64
+ All endpoints are accessed via namespaced Api resource. Example: `client.users.create({ email: 'foo@bar.com', password: 'password', isAdministrator: false })`
65
+
66
+ #### Api Keys:
67
+
68
+ 1. `GET #current`
69
+ 1. `POST #create(payload)`
70
+ 1. `DELETE #revoke(key)`
71
+ 1. `DELETE #revoke!`
72
+
73
+ #### Health:
74
+
75
+ 1. `GET #status`
76
+
77
+ #### Lightning:
78
+
79
+ 1. TODO - Set up local lightning network, testing, etc.
80
+
81
+ #### Pull Payments:
82
+
83
+ 1. `GET #get(pull_payment_id)`
84
+ 1. `GET #payouts`
85
+ 1. `POST #create_payout(pull_payment_id, payload)`
86
+
87
+ #### Server:
88
+
89
+ 1. `GET #info`
90
+
91
+ #### Store:
92
+
93
+ - ##### Payment Requests:
94
+
95
+ 1. `GET #all(store_id)`
96
+ 1. `POST #create(store_id, payload)`
97
+ 1. `GET #get(store_id, request_id)`
98
+ 1. `DELETE #delete(store_id, request_id)`
99
+ 1. `PUT #update(store_id, request_id, payload)`
100
+
101
+ - ##### Payouts:
102
+
103
+ 1. `POST #approve(store_id, payout_id, payload)`
104
+ 1. `DELETE #delete(store_id, payout_id)`
105
+
106
+ - ##### Pull Payments:
107
+
108
+ 1. `GET #all(store_id)`
109
+ 1. `POST #create(store_id, payload)`
110
+ 1. `DELETE #delete(store_id, pull_payment_id)`
111
+
112
+ #### Users:
113
+
114
+ 1. `GET #me`
115
+ 1. `POST #create(payload)`
116
+
117
+ ## Request helpers
118
+
119
+ #### Api Keys:
120
+
121
+ - ##### Authorize
122
+
123
+ 1. `GET #html(permissions: [], application_name:, strict: true, selective_stores: false)`
124
+ 1. `#link(permissions: [], application_name:, strict: true, selective_stores: false)`
125
+
126
+ ### Environment Variables
127
+
128
+ `btcpay` can be initialized with either arguments or ENV:
129
+
130
+ | Variable | Description | Default |
131
+ | --------------------------|:------------------------|:--------:|
132
+ | `BTCPAY_AUTH_TOKEN` | BtcPay Auth Token | - |
133
+ | `BTCPAY_BASIC_AUTH_TOKEN` | BtcPay Basic Auth Token | - |
134
+ | `BTCPAY_BASE_URL` | BtcPay Base Url | - |
135
+
136
+ ### BtcPay Docker Compose
137
+
138
+ To get up and running locally quickly, a [BTCPayServer]((https://docs.btcpayserver.org/)) docker-compose file has been added to test local API interactions. To get up and running:
139
+
140
+ 1. `$ docker-compose -f docker-compose.btcpay.yml up`
141
+ 1. `$ open http://localhost:49392`
142
+ - Note: [`regtest`](https://bisq.network/blog/how-to-set-up-bitcoin-regtest/) environment default to allow for block/coin creation for test purpose
143
+ - `testnet` environment should be used for integration/staging testing prior to production promotion.
144
+ - `mainnet` is the **real** network.
145
+
146
+ ## Development
147
+
148
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
149
+
150
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
151
+
152
+ ## Contributing
153
+
154
+ Bug reports and pull requests are welcome on Gitlab at https://gitlab.com/snogrammer/btcpay.
155
+
156
+
157
+ ## License
158
+
159
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'btcpay'
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
+ require 'pry'
10
+ Pry.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/btcpay/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'btcpay'
7
+ spec.version = BtcPay::VERSION
8
+ spec.authors = ['snogrammer']
9
+ spec.email = ['btcpay-gem@snogram.com']
10
+
11
+ spec.summary = 'BTCPay Server v1 API wrapper. Be your own Bitpay!'
12
+ spec.homepage = 'https://docs.btcpayserver.org/API/Greenfield/v1/'
13
+ spec.license = 'MIT'
14
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
15
+
16
+ spec.metadata['homepage_uri'] = spec.homepage
17
+ spec.metadata['source_code_uri'] = 'https://gitlab.com/snogrammer/btpay'
18
+ spec.metadata['changelog_uri'] = 'https://gitlab.com/snogrammer/btpay/CHANGELOG.md'
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(__dir__)) 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_dependency 'activesupport', '> 5'
30
+ spec.add_dependency 'multi_json', '~> 1.15'
31
+ spec.add_dependency 'rest-client', '~> 2.1'
32
+
33
+ spec.add_development_dependency 'bundler', '~> 2.0'
34
+ spec.add_development_dependency 'factory_bot', '~> 6.1'
35
+ spec.add_development_dependency 'pry', '> 0'
36
+ spec.add_development_dependency 'rubocop', '> 0'
37
+ spec.add_development_dependency 'simplecov', '> 0'
38
+ spec.add_development_dependency 'vcr', '~> 6.0'
39
+ spec.add_development_dependency 'webmock', '~> 3.8'
40
+ end
@@ -0,0 +1,139 @@
1
+ version: "3"
2
+
3
+ services:
4
+ # Bitcoin daemon for blockchain transaction data
5
+ bitcoind:
6
+ container_name: bitcoind
7
+ restart: unless-stopped
8
+ image: btcpayserver/bitcoin:0.19.0.1
9
+ environment:
10
+ BITCOIN_NETWORK: regtest
11
+ BITCOIN_EXTRA_ARGS: |
12
+ debug=1
13
+ regtest=1
14
+ server=1
15
+ rpcport=43782
16
+ rpcbind=0.0.0.0:43782
17
+ port=39388
18
+ whitelist=0.0.0.0/0
19
+ rpcuser=rpcuser
20
+ rpcpassword=rpcpassword
21
+ expose:
22
+ - "43782" # rpc port
23
+ - "39388" # bitcoin node can communicate
24
+ ports:
25
+ - "43782:43782"
26
+ - "39388:39388"
27
+ volumes:
28
+ - "bitcoind_data:/data"
29
+
30
+ # Blockchain explorer
31
+ nbxplorer:
32
+ container_name: nbxplorer
33
+ restart: unless-stopped
34
+ image: nicolasdorier/nbxplorer:2.1.34
35
+ ports:
36
+ - "32838:32838"
37
+ environment:
38
+ NBXPLORER_NETWORK: regtest
39
+ NBXPLORER_BIND: 0.0.0.0:32838
40
+ NBXPLORER_SIGNALFILEDIR: /datadir
41
+ NBXPLORER_NOAUTH: 1
42
+ NBXPLORER_CHAINS: btc
43
+ NBXPLORER_BTCRPCURL: http://bitcoind:43782/
44
+ NBXPLORER_BTCRPCUSER: rpcuser
45
+ NBXPLORER_BTCRPCPASSWORD: rpcpassword
46
+ NBXPLORER_BTCNODEENDPOINT: bitcoind:39388
47
+ volumes:
48
+ - "bitcoind_data:/root/.bitcoin"
49
+ - "nbxplorer_data:/datadir"
50
+ links:
51
+ - bitcoind
52
+
53
+ btcpay:
54
+ container_name: btcpay
55
+ restart: unless-stopped
56
+ image: btcpayserver/btcpayserver:1.0.5.2
57
+ ports:
58
+ - "49392:49392"
59
+ environment:
60
+ BTCPAY_BIND: 0.0.0.0:49392
61
+ BTCPAY_POSTGRES: User ID=user;Password=password;Host=btcpay_db;Port=5432;Database=btcpay_regtest
62
+ BTCPAY_NETWORK: regtest
63
+ BTCPAY_CHAINS: btc
64
+ BTCPAY_ROOTPATH: /
65
+ BTCPAY_BTCEXPLORERURL: http://nbxplorer:32838/
66
+ BTCPAY_DEBUGLOG: btcpay.log
67
+ # https://docs.btcpayserver.org/LightningNetwork/#choosing-the-lightning-network-implementation
68
+ # BTCPAYGEN_LIGHTNING: clightning
69
+ # BTCPAYGEN_LIGHTNING: lnd
70
+ volumes:
71
+ - "btcpay_data:/datadir"
72
+ - "nbxplorer_data:/root/.nbxplorer"
73
+ links:
74
+ - btcpay_db
75
+ - bitcoind
76
+ - nbxplorer
77
+ # - lightningd
78
+ # - lnd
79
+
80
+ # lnd:
81
+ # image: lightningnetwork/lnd-alpine
82
+ # container_name: lnd
83
+ # environment:
84
+ # RPCHOST: bitcoind
85
+ # RPCUSER: rpcuser
86
+ # RPCPASS: rpcpassword
87
+ # DEBUG: debug
88
+ # NETWORK: regtest
89
+ # volumes:
90
+ # - bitcoind_data:/rpc
91
+ # - lnd_data:/root/.lnd
92
+ # links:
93
+ # - bitcoind
94
+
95
+ # lightningd:
96
+ # image: elementsproject/lightningd
97
+ # container_name: lightningd
98
+ # command:
99
+ # - --bitcoin-rpcconnect=bitcoind
100
+ # - --bitcoin-rpcuser=rpcuser
101
+ # - --bitcoin-rpcpassword=rpcpassword
102
+ # - --bitcoin-rpcport=43782
103
+ # - --network=regtest
104
+ # - --alias=lightningdnode
105
+ # - --log-level=debug
106
+ # environment:
107
+ # EXPOSE_TCP: "true"
108
+ # expose:
109
+ # - "9735"
110
+ # ports:
111
+ # - "0.0.0.0:9735:9735"
112
+ # volumes:
113
+ # - "lightningd_data:/root/.lightning"
114
+ # - "bitcoind_data:/etc/bitcoin"
115
+ # links:
116
+ # - bitcoind
117
+
118
+ btcpay_db:
119
+ container_name: btcpay_db
120
+ restart: unless-stopped
121
+ image: postgres:11.5-alpine
122
+ environment:
123
+ POSTGRES_USER: user
124
+ POSTGRES_PASSWORD: password
125
+ POSTGRES_MULTIPLE_DATABASES: blocklux_development,btcpay_regtest
126
+ ports:
127
+ - "54321:5432"
128
+ volumes:
129
+ - /usr/local/var/postgres/data:/var/lib/postgresql/data
130
+ - /usr/local/var/postgres/docker/multi-db-entrypoint:/docker-entrypoint-initdb.d
131
+
132
+ volumes:
133
+ bitcoind_data:
134
+ btcpay_data:
135
+ # lightningd_data:
136
+ # lnd_data:
137
+ nbxplorer_data:
138
+
139
+ networks: {}