monero 0.0.0.3 → 0.0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -16
- data/lib/monero.rb +16 -15
- data/lib/{monero → rpc}/client.rb +4 -4
- data/lib/{monero → rpc}/config.rb +1 -1
- data/lib/{monero → rpc}/payment.rb +1 -1
- data/lib/{monero → rpc}/transfer.rb +2 -2
- data/lib/rpc/version.rb +3 -0
- data/lib/{monero → rpc}/wallet.rb +21 -17
- data/monero.gemspec +3 -3
- metadata +8 -9
- data/lib/monero/version.rb +0 -3
- data/lib/xmr.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbd4e0ebaccaf5e0403f30225b9d4b0f86938ed7
|
4
|
+
data.tar.gz: '091d45b2d5e0d3f387377378b52bccfbadddd867'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc029a7f1a811bedaa291cf0d66fe9f22c5d94e13033d8a2919aacbce10d901af59f5188ff80f6be8fde43d4ba7a95a6effd7d280cd0a03b50cc4518a0273908
|
7
|
+
data.tar.gz: cbf6720305f05f4cc0594bdae8c947ead71d644e96a2e3fd9da9e90b82a52c3f7346c21fb64bd9d0b6de54522a28df151ae1321c1ae020f9ccb7209f99640f1d
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
*updating and testing for 0.12 soon*
|
1
|
+
*updating and testing for 0.12 ~~soon~~ in progress*
|
2
2
|
|
3
3
|
# Monero Ruby Client
|
4
4
|
|
@@ -24,7 +24,7 @@ For easy installation add `gem 'monero'` to your Gemfile or run `gem install mon
|
|
24
24
|
|
25
25
|
Start your daemon `./monerod --testnet`
|
26
26
|
|
27
|
-
Start your RPC Client `./monero-wallet-rpc --testnet --rpc-bind-port 18081 --rpc-bind-ip 127.0.0.1 --rpc-login username:password --log-level 4
|
27
|
+
Start your RPC Client `./monero-wallet-rpc --testnet --rpc-bind-port 18081 --rpc-bind-ip 127.0.0.1 --rpc-login username:password --log-level 4`
|
28
28
|
|
29
29
|
- To open a wallet at start use `--wallet-file filename` and `--password pass`
|
30
30
|
- In case you need to access the client from another machine, you need to set `--confirm-external-bind`.
|
@@ -34,10 +34,10 @@ Start your RPC Client `./monero-wallet-rpc --testnet --rpc-bind-port 18081 --rp
|
|
34
34
|
## Getting started
|
35
35
|
|
36
36
|
### Configuration
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
RPC.config.host = "127.0.0.1"
|
38
|
+
RPC.config.port = "18081"
|
39
|
+
RPC.config.username = "username"
|
40
|
+
RPC.config.password = "password"
|
41
41
|
|
42
42
|
|
43
43
|
|
@@ -50,33 +50,33 @@ ___
|
|
50
50
|
|
51
51
|
Get the current address
|
52
52
|
|
53
|
-
|
53
|
+
RPC::Wallet.address
|
54
54
|
=> "9wm6oNA5nP3LnugTKRSwGJhW4vnYv8RAVdRvYyvbistbHUnojyTHyHcYpbZvbTZHDsi4rF1EK5TiYgnCN6FWM9HjTDpKXAE"
|
55
55
|
___
|
56
56
|
|
57
57
|
Create a new address for a payment (integrated address)
|
58
58
|
|
59
|
-
|
59
|
+
RPC::Wallet.make_integrated_address
|
60
60
|
=> {"integrated_address"=>"A7TmpAyaPeZLnugTKRSwGJhW4vnYv8RAVdRvYyvbistbHUnojyTHyHcYpbZvbTZHDsi4rF1EK5TiYgnCN6FWM9HjfufSYUchQ8hH2R272H",
|
61
61
|
"payment_id"=>"9d985c985ce58a8e"}
|
62
62
|
___
|
63
63
|
To get the balance of the current wallet (we use the gem 'money')
|
64
64
|
|
65
|
-
|
65
|
+
RPC::Wallet.balance
|
66
66
|
# returns an ::XMR object which is just a shortcut for ::Money(amount, :xmr)
|
67
67
|
=> #<Money fractional:9980629640000 currency:XMR>
|
68
68
|
|
69
|
-
|
69
|
+
RPC::Wallet.balance.format
|
70
70
|
=> "9.980629640000 XMR"
|
71
71
|
|
72
72
|
To get the unlocked balance, which is currently available
|
73
73
|
|
74
|
-
|
74
|
+
RPC::Wallet.unlocked_balance
|
75
75
|
=> #<Money fractional:10000 currency:XMR>
|
76
76
|
|
77
77
|
To get both combined
|
78
78
|
|
79
|
-
|
79
|
+
RPC::Wallet.getbalance
|
80
80
|
=> {"balance"=>9961213880000, "unlocked_balance"=>10000}
|
81
81
|
|
82
82
|
|
@@ -84,16 +84,16 @@ To get both combined
|
|
84
84
|
___
|
85
85
|
To get the current block height
|
86
86
|
|
87
|
-
|
87
|
+
RPC::Wallet.getheight
|
88
88
|
=> 1008032
|
89
89
|
|
90
90
|
|
91
91
|
___
|
92
92
|
|
93
|
-
Send XMR to an address via `
|
93
|
+
Send XMR to an address via `RPC::Transfer.create`. If successfull you will get the transaction details. If not succesfull you'll get returned nil.
|
94
94
|
|
95
95
|
amount= 20075 #in atomic units. 1000000000000 == 1.0 XMR
|
96
|
-
|
96
|
+
RPC::Transfer.create("A7TmpAyaPeZLnugTKRSwGJhW4vnYv8RAVdRvYyvbistbHUnojyTHyHcYpbZvbTZHDsi4rF1EK5TiYgnCN6FWM9HjfwGRvbCHYCZAaKSzDx", amount)
|
97
97
|
=> {"fee"=>19415760000,
|
98
98
|
"tx_blob"=>"020001020005bbcf0896e3.......
|
99
99
|
|
@@ -112,7 +112,7 @@ To send payments to multiple recipients simply use an array of `[:recipient, :am
|
|
112
112
|
{address:A7TmpAyaPeZLnugTKRSwGJhW4vnYv8RAVdRvYyvbistbHUnojyTHyHcYpbZvbTZHDsi4rF1EK5TiYgnCN6FWM9HjfrgPgAEasYGSVhUdwe amount: 442130000}
|
113
113
|
]
|
114
114
|
|
115
|
-
|
115
|
+
RPC::Transfer.send_bulk(recipients, options)
|
116
116
|
|
117
117
|
___
|
118
118
|
|
data/lib/monero.rb
CHANGED
@@ -1,24 +1,25 @@
|
|
1
1
|
require 'money'
|
2
|
-
require '
|
3
|
-
require '
|
4
|
-
require '
|
5
|
-
require '
|
6
|
-
require '
|
7
|
-
require '
|
2
|
+
require 'rpc/config'
|
3
|
+
require 'rpc/payment'
|
4
|
+
require 'rpc/client'
|
5
|
+
require 'rpc/version'
|
6
|
+
require 'rpc/wallet'
|
7
|
+
require 'rpc/transfer'
|
8
8
|
|
9
|
-
module
|
9
|
+
module RPC
|
10
10
|
def self.config
|
11
|
-
@@config ||=
|
11
|
+
@@config ||= RPC::Config.instance
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
# ActiveSupport.on_load(:active_record) do
|
16
|
-
# include Monero::Model
|
17
|
-
# end
|
18
|
-
|
19
15
|
Money::Currency.register({ :priority => 1, :iso_code => "xmr", :iso_numeric => "846", :name => "Monero", :symbol => "XMR", :subunit => "", :subunit_to_unit => 1000000000000, :decimal_mark => ".", :thousands_separator => ""})
|
20
16
|
#
|
21
|
-
|
22
|
-
|
23
|
-
|
17
|
+
|
18
|
+
unless Object.const_defined?('XMR')
|
19
|
+
|
20
|
+
class XMR
|
21
|
+
def self.new(amount); Money.new(amount, :xmr); end
|
22
|
+
def to_s; Money.new(amount, :xmr).format.to_s; end
|
23
|
+
end
|
24
|
+
|
24
25
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module RPC
|
2
2
|
class Client
|
3
3
|
#class RequestError < StandardError; end
|
4
4
|
|
@@ -12,12 +12,12 @@ module Monero
|
|
12
12
|
|
13
13
|
args = ""
|
14
14
|
args << " -s"
|
15
|
-
args << " -u #{
|
15
|
+
args << " -u #{RPC.config.username}:#{RPC.config.password} --digest"
|
16
16
|
args << " -X POST #{base_uri}/json_rpc"
|
17
17
|
args << " -d '#{data}'"
|
18
18
|
args << " -H 'Content-Type: application/json'"
|
19
19
|
|
20
|
-
p "curl #{args}" if
|
20
|
+
p "curl #{args}" if RPC.config.debug
|
21
21
|
|
22
22
|
json = JSON.parse(`curl #{args}`)
|
23
23
|
|
@@ -32,7 +32,7 @@ module Monero
|
|
32
32
|
private
|
33
33
|
|
34
34
|
def self.base_uri
|
35
|
-
"http://#{
|
35
|
+
"http://#{RPC.config.host}:#{RPC.config.port}"
|
36
36
|
end
|
37
37
|
|
38
38
|
end
|
@@ -22,7 +22,7 @@
|
|
22
22
|
# get_tx_hex - boolean; Return the transaction as hex string after sending
|
23
23
|
|
24
24
|
|
25
|
-
module
|
25
|
+
module RPC
|
26
26
|
# => {"integrated_address"=>"A7TmpAyaPeZLnugTKRSwGJhW4vnYv8RAVdRvYyvbistbHUnojyTHyHcYpbZvbTZHDsi4rF1EK5TiYgnCN6FWM9HjfwGRvbCHYCZAaKSzDx", "payment_id"=>"c7e7146b3335aa54"}
|
27
27
|
|
28
28
|
class Transfer
|
@@ -48,7 +48,7 @@ module Monero
|
|
48
48
|
payment_id: payment_id, get_tx_key: get_tx_key, priority: priority, do_not_relay: do_not_relay, get_tx_hex: get_tx_hex
|
49
49
|
}
|
50
50
|
|
51
|
-
|
51
|
+
RPC::Client.request("transfer", options)
|
52
52
|
end
|
53
53
|
|
54
54
|
end
|
data/lib/rpc/version.rb
ADDED
@@ -1,18 +1,22 @@
|
|
1
|
-
module
|
1
|
+
module RPC
|
2
2
|
|
3
3
|
class Wallet
|
4
4
|
|
5
5
|
def self.create_address(label="")
|
6
|
-
|
6
|
+
RPC::Client.request("create_address", label: label)
|
7
7
|
end
|
8
8
|
|
9
|
-
def self.
|
10
|
-
|
9
|
+
def self.get_address
|
10
|
+
RPC::Client.request("get_address")["address"]
|
11
11
|
end
|
12
12
|
def self.address; getaddress; end
|
13
13
|
|
14
|
+
def self.get_addresses
|
15
|
+
RPC::Client.request("get_address")["addresses"]
|
16
|
+
end
|
17
|
+
|
14
18
|
def self.getbalance
|
15
|
-
|
19
|
+
RPC::Client.request("getbalance")
|
16
20
|
end
|
17
21
|
|
18
22
|
def self.balance
|
@@ -24,16 +28,16 @@ module Monero
|
|
24
28
|
end
|
25
29
|
|
26
30
|
def self.getaddress
|
27
|
-
|
31
|
+
RPC::Client.request("getaddress")["address"]
|
28
32
|
end
|
29
33
|
|
30
34
|
def self.getheight
|
31
|
-
|
35
|
+
RPC::Client.request("getheight")["height"]
|
32
36
|
end
|
33
37
|
|
34
38
|
def self.query_key(type)
|
35
39
|
raise ArgumentError unless ["mnemonic", "view_key"].include?(type.to_s)
|
36
|
-
|
40
|
+
RPC::Client.request("query_key", {key_type: type})["key"]
|
37
41
|
end
|
38
42
|
def self.view_key; query_key(:view_key); end
|
39
43
|
def self.mnemonic_seed; query_key(:mnemonic); end
|
@@ -42,19 +46,19 @@ module Monero
|
|
42
46
|
def self.make_integrated_address(payment_id = "")
|
43
47
|
# TODO
|
44
48
|
# Check if payment_id is correct format
|
45
|
-
|
49
|
+
RPC::Client.request("make_integrated_address", {payment_id: payment_id})
|
46
50
|
end
|
47
51
|
|
48
52
|
def self.incoming_transfers(type)
|
49
53
|
raise ArgumentError unless ["all", "available", "unavailable"].include?(type.to_s)
|
50
|
-
json =
|
54
|
+
json = RPC::Client.request("incoming_transfers", {transfer_type: type})
|
51
55
|
json["transfers"] || []
|
52
56
|
end
|
53
57
|
|
54
58
|
def self.get_payments(payment_id)
|
55
|
-
payments =
|
59
|
+
payments = RPC::Client.request("get_payments", {payment_id: payment_id})["payments"] || []
|
56
60
|
# TODO
|
57
|
-
# make it a
|
61
|
+
# make it a RPC::Payment that hase a amount as XMR and confirmations (getheight - tx.block_height)
|
58
62
|
payments.map{|x| Payment.from_raw(x) }
|
59
63
|
end
|
60
64
|
|
@@ -79,11 +83,11 @@ module Monero
|
|
79
83
|
|
80
84
|
options = {in: f_in, out: out, pending: pending, failed: failed, pool: pool, filter_by_height: filter_by_height, min_height: min_height, max_height: max_height}
|
81
85
|
|
82
|
-
|
86
|
+
RPC::Client.request("get_transfers", options)
|
83
87
|
end
|
84
88
|
|
85
89
|
def self.get_transfer_by_txid(txid)
|
86
|
-
|
90
|
+
RPC::Client.request("get_transfer_by_txid", {txid: txid })
|
87
91
|
end
|
88
92
|
|
89
93
|
# creates a wallet and uses it
|
@@ -92,14 +96,14 @@ module Monero
|
|
92
96
|
# TODO
|
93
97
|
# language correct format?
|
94
98
|
options = { filename: filename, password: password, language: language }
|
95
|
-
!!
|
99
|
+
!! RPC::Client.request("create_wallet", options)
|
96
100
|
end
|
97
101
|
singleton_class.send(:alias_method, :create, :create_wallet)
|
98
102
|
|
99
103
|
# returns current balance if open successfull
|
100
104
|
def self.open_wallet(filename, password="")
|
101
105
|
options = { filename: filename, password: password}
|
102
|
-
if
|
106
|
+
if RPC::Client.request("open_wallet", options)
|
103
107
|
balance
|
104
108
|
else
|
105
109
|
false
|
@@ -109,7 +113,7 @@ module Monero
|
|
109
113
|
|
110
114
|
# stops current RPC process!
|
111
115
|
def self.stop_wallet
|
112
|
-
|
116
|
+
RPC::Client.close!
|
113
117
|
end
|
114
118
|
singleton_class.send(:alias_method, :close, :stop_wallet)
|
115
119
|
|
data/monero.gemspec
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require '
|
4
|
+
require 'rpc/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "monero"
|
8
|
-
spec.version =
|
8
|
+
spec.version = RPC::VERSION
|
9
9
|
spec.authors = ["Tim Kretschmer"]
|
10
10
|
spec.email = ["tim@krtschmr.de"]
|
11
11
|
spec.description = %q{A Monero-Wallet-RPC ruby client}
|
@@ -24,5 +24,5 @@ Gem::Specification.new do |spec|
|
|
24
24
|
|
25
25
|
spec.required_rubygems_version = '>= 1.3.6'
|
26
26
|
|
27
|
-
spec.add_dependency "money"
|
27
|
+
spec.add_dependency "money"
|
28
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: monero
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.0.
|
4
|
+
version: 0.0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Kretschmer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -76,13 +76,12 @@ files:
|
|
76
76
|
- ".gitignore"
|
77
77
|
- README.md
|
78
78
|
- lib/monero.rb
|
79
|
-
- lib/
|
80
|
-
- lib/
|
81
|
-
- lib/
|
82
|
-
- lib/
|
83
|
-
- lib/
|
84
|
-
- lib/
|
85
|
-
- lib/xmr.rb
|
79
|
+
- lib/rpc/client.rb
|
80
|
+
- lib/rpc/config.rb
|
81
|
+
- lib/rpc/payment.rb
|
82
|
+
- lib/rpc/transfer.rb
|
83
|
+
- lib/rpc/version.rb
|
84
|
+
- lib/rpc/wallet.rb
|
86
85
|
- monero.gemspec
|
87
86
|
homepage: ''
|
88
87
|
licenses:
|
data/lib/monero/version.rb
DELETED
data/lib/xmr.rb
DELETED
File without changes
|