xmrto 0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +43 -0
- data/LICENSE.txt +21 -0
- data/README.md +66 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/xmrto.rb +12 -0
- data/lib/xmrto/config.rb +7 -0
- data/lib/xmrto/transfer.rb +68 -0
- data/lib/xmrto/version.rb +3 -0
- data/xmrto.gemspec +30 -0
- metadata +114 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: dd36c9dbc9091fb6f3d08f32365c46872710ed06d3311010f4144bddd36faf6e
|
4
|
+
data.tar.gz: a7de49942259a872a5b01f506d8553e440a463740bfa73ae9d8c12e8de48342e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c0f2d6f8c2239bacce8df24cf980668675e676e16707264335f10a374f07145ea1683b33212ded9338386052b79ca0230785aec32df0cf08914aa6c4f4b0d971
|
7
|
+
data.tar.gz: 542a7fb52467753bb053e12f11daa3b26dee82d533871c0dee79d98313d9929f8fab7e223d565275749e14d294cc6fffae97b4065171d002d29a602109f9a6aa
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
xmrto (0.0.2)
|
5
|
+
httparty
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.3)
|
11
|
+
httparty (0.17.0)
|
12
|
+
mime-types (~> 3.0)
|
13
|
+
multi_xml (>= 0.5.2)
|
14
|
+
mime-types (3.2.2)
|
15
|
+
mime-types-data (~> 3.2015)
|
16
|
+
mime-types-data (3.2019.0331)
|
17
|
+
multi_xml (0.6.0)
|
18
|
+
rake (12.3.1)
|
19
|
+
rspec (3.8.0)
|
20
|
+
rspec-core (~> 3.8.0)
|
21
|
+
rspec-expectations (~> 3.8.0)
|
22
|
+
rspec-mocks (~> 3.8.0)
|
23
|
+
rspec-core (3.8.0)
|
24
|
+
rspec-support (~> 3.8.0)
|
25
|
+
rspec-expectations (3.8.2)
|
26
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
27
|
+
rspec-support (~> 3.8.0)
|
28
|
+
rspec-mocks (3.8.0)
|
29
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
+
rspec-support (~> 3.8.0)
|
31
|
+
rspec-support (3.8.0)
|
32
|
+
|
33
|
+
PLATFORMS
|
34
|
+
ruby
|
35
|
+
|
36
|
+
DEPENDENCIES
|
37
|
+
bundler
|
38
|
+
rake
|
39
|
+
rspec (~> 3.0)
|
40
|
+
xmrto!
|
41
|
+
|
42
|
+
BUNDLED WITH
|
43
|
+
1.17.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Tim Kretschmer
|
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,66 @@
|
|
1
|
+
|
2
|
+
# xmr.to API Wrapper
|
3
|
+
|
4
|
+
***ALWAYS DEVELOP IN THE TESTNET!***
|
5
|
+
|
6
|
+
to install
|
7
|
+
|
8
|
+
gem "xmrto"
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
default the gem wil run in `:testnet` mode. http://test.xmr.to. However, this version of xmr.to is running on the stagenet
|
14
|
+
|
15
|
+
Xmrto.config.network = :testnet #livenet
|
16
|
+
|
17
|
+
To create a transfer, simply call
|
18
|
+
|
19
|
+
transfer = Xmrto::Transfer.create("mqm6GJzsmzvwqPbH5p7tKrRRdHrMkmRXjS", 0.01333)
|
20
|
+
=> #<Xmrto::Transfer:0x000055a7dbc46908 @state="TO_BE_CREATED", @uuid="xmrto-KLYXfW">
|
21
|
+
|
22
|
+
transfer.update
|
23
|
+
=> "UNPAID"
|
24
|
+
|
25
|
+
To work with an existing transfer
|
26
|
+
|
27
|
+
transfer = Xmrto::Transfer.new("xmrto-AWYXfW")
|
28
|
+
=> #<Xmrto::Transfer:0x000055a7dbec3000 @uuid="xmrto-AWYXfW">
|
29
|
+
transfer.update
|
30
|
+
=> "BTC_SENT"
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
Errors will be thrown accordingly
|
35
|
+
|
36
|
+
transfer = Xmrto::Transfer.create("mqm6GJzsmzvwqPbH5p7tKrRRdHrMkmRXjS", 20000)
|
37
|
+
Xmrto::Error004: bitcoin amount out of bounds
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
Every Transfer object hast the same attributes as the API returns
|
43
|
+
|
44
|
+
:uuid
|
45
|
+
:xmr_price_btc
|
46
|
+
:state
|
47
|
+
:btc_amount
|
48
|
+
:btc_dest_address
|
49
|
+
:xmr_required_amount
|
50
|
+
:xmr_receiving_address
|
51
|
+
:xmr_receiving_integrated_address
|
52
|
+
:xmr_required_payment_id_long
|
53
|
+
:xmr_required_payment_id_short
|
54
|
+
:created_at
|
55
|
+
:expires_at
|
56
|
+
:seconds_till_timeout
|
57
|
+
:xmr_amount_total
|
58
|
+
:xmr_amount_remaining
|
59
|
+
:xmr_num_confirmations_remaining
|
60
|
+
:xmr_recommended_mixin
|
61
|
+
:btc_num_confirmations_before_purge
|
62
|
+
:btc_num_confirmations
|
63
|
+
:btc_transaction_id
|
64
|
+
|
65
|
+
|
66
|
+
if you need help, ask in #monero @ freenode.net
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "xmrto"
|
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
data/lib/xmrto.rb
ADDED
data/lib/xmrto/config.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
module Xmrto
|
2
|
+
|
3
|
+
(1..14).map do |i|
|
4
|
+
clazz = "class Error#{i.to_s.rjust(3, "0")} < StandardError; end"
|
5
|
+
eval(clazz)
|
6
|
+
end
|
7
|
+
|
8
|
+
class Transfer
|
9
|
+
|
10
|
+
|
11
|
+
attr_accessor :uuid, :xmr_price_btc, :state, :btc_amount, :btc_dest_address, :xmr_required_amount, :xmr_receiving_address,
|
12
|
+
:xmr_receiving_integrated_address, :xmr_required_payment_id_long, :xmr_required_payment_id_short, :created_at, :expires_at, :seconds_till_timeout, :xmr_amount_total, :xmr_amount_remaining, :xmr_num_confirmations_remaining, :xmr_recommended_mixin, :btc_num_confirmations_before_purge, :btc_num_confirmations, :btc_transaction_id
|
13
|
+
|
14
|
+
|
15
|
+
def initialize(uuid = nil)
|
16
|
+
self.uuid = uuid
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.create(btc_address, btc_amount)
|
20
|
+
new.create(btc_address, btc_amount)
|
21
|
+
end
|
22
|
+
|
23
|
+
def create(btc_address, btc_amount)
|
24
|
+
request = post_request("/order_create/", { "btc_dest_address": btc_address, "btc_amount": btc_amount })
|
25
|
+
self.uuid = request["uuid"]
|
26
|
+
self.state = request["state"]
|
27
|
+
self
|
28
|
+
end
|
29
|
+
|
30
|
+
def update
|
31
|
+
fetch_status.map {|attr, value| send("#{attr}=", value) }
|
32
|
+
state
|
33
|
+
end
|
34
|
+
|
35
|
+
def testnet?
|
36
|
+
Xmrto.config.network == :testnet
|
37
|
+
end
|
38
|
+
|
39
|
+
def livenet?
|
40
|
+
Xmrto.config.network == :livenet
|
41
|
+
end
|
42
|
+
|
43
|
+
def post_request(endpoint, args)
|
44
|
+
url = "#{base_url}#{endpoint}"
|
45
|
+
p "sending POST request to: #{url} with params: #{args.to_json}" if Xmrto.config.debug
|
46
|
+
response = HTTParty.post(url, body: args.to_json, headers: { 'Content-Type' => 'application/json' } )
|
47
|
+
if response["error"]
|
48
|
+
raise("Xmrto::Error#{response["error"][-3..-1]}".constantize, response["error_msg"] )
|
49
|
+
end
|
50
|
+
response
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def base_url
|
56
|
+
if testnet?
|
57
|
+
"https://test.xmr.to/api/v2/xmr2btc"
|
58
|
+
else
|
59
|
+
"https://xmr.to/api/v2/xmr2btc"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def fetch_status
|
64
|
+
post_request("/order_status_query/", {uuid: uuid})
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
data/xmrto.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'xmrto/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "xmrto"
|
8
|
+
spec.version = Xmrto::VERSION
|
9
|
+
spec.authors = ["Tim Kretschmer"]
|
10
|
+
spec.email = ["tim@krtschmr.de"]
|
11
|
+
spec.description = %q{A xmr.to api library}
|
12
|
+
spec.summary = %q{A xmr.to api library}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
24
|
+
|
25
|
+
spec.required_rubygems_version = '>= 1.3.6'
|
26
|
+
|
27
|
+
spec.add_dependency "httparty", ">=0.17"
|
28
|
+
|
29
|
+
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: xmrto
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.4'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tim Kretschmer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-05-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
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: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: httparty
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.17'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.17'
|
69
|
+
description: A xmr.to api library
|
70
|
+
email:
|
71
|
+
- tim@krtschmr.de
|
72
|
+
executables:
|
73
|
+
- console
|
74
|
+
- setup
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- ".gitignore"
|
79
|
+
- Gemfile
|
80
|
+
- Gemfile.lock
|
81
|
+
- LICENSE.txt
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- bin/console
|
85
|
+
- bin/setup
|
86
|
+
- lib/xmrto.rb
|
87
|
+
- lib/xmrto/config.rb
|
88
|
+
- lib/xmrto/transfer.rb
|
89
|
+
- lib/xmrto/version.rb
|
90
|
+
- xmrto.gemspec
|
91
|
+
homepage: ''
|
92
|
+
licenses:
|
93
|
+
- MIT
|
94
|
+
metadata: {}
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: 1.3.6
|
109
|
+
requirements: []
|
110
|
+
rubygems_version: 3.0.1
|
111
|
+
signing_key:
|
112
|
+
specification_version: 4
|
113
|
+
summary: A xmr.to api library
|
114
|
+
test_files: []
|