monero 0.0.0.4 → 0.0.0.5
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 +4 -4
- data/README.md +54 -6
- data/lib/monero.rb +2 -1
- data/lib/rpc/config.rb +2 -1
- data/lib/rpc/incoming_transfer.rb +26 -0
- data/lib/rpc/transfer.rb +1 -1
- data/lib/rpc/version.rb +1 -1
- data/lib/rpc/wallet.rb +16 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff055d80e0cdf7d66a72680316795f10e9abf792
|
4
|
+
data.tar.gz: a8dd18dd7b65f4686c9f28d0ee9914caa0f067c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3130170bae3a24bf8477be6c4190e8d20845b3490f76afc94025e9b9db4f8a109eec87f799022e333b53f77230d92d3641ee49ec8e261c91a222300cffb74f8
|
7
|
+
data.tar.gz: fce1451de44c1e75e350ce7742acf506b63071e2ba2d6a5b6e9bb65a63e56b373f91707e8c245b68647e2618c85b8c7bb9836085cc80a8fb589389e985b989c8
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
*
|
1
|
+
*Heavy development. Tested against 0.12.0 without issues. Please contribute. If you want to send Testnet transactions, please always send them back to https://dis.gratis*
|
2
2
|
|
3
3
|
# Monero Ruby Client
|
4
4
|
|
@@ -38,7 +38,7 @@ Start your RPC Client `./monero-wallet-rpc --testnet --rpc-bind-port 18081 --rp
|
|
38
38
|
RPC.config.port = "18081"
|
39
39
|
RPC.config.username = "username"
|
40
40
|
RPC.config.password = "password"
|
41
|
-
|
41
|
+
RPC.config.transfer_clazz = "MoneroTransfer" # you can set your own class to get incoming transfers as a model rather then a json
|
42
42
|
|
43
43
|
|
44
44
|
### Usage
|
@@ -52,6 +52,14 @@ Get the current address
|
|
52
52
|
|
53
53
|
RPC::Wallet.address
|
54
54
|
=> "9wm6oNA5nP3LnugTKRSwGJhW4vnYv8RAVdRvYyvbistbHUnojyTHyHcYpbZvbTZHDsi4rF1EK5TiYgnCN6FWM9HjTDpKXAE"
|
55
|
+
|
56
|
+
___
|
57
|
+
|
58
|
+
Create a new Subaddress with a label
|
59
|
+
|
60
|
+
RPC::Wallet.create_address "family savings"
|
61
|
+
=> {"address"=>"BZFWM5MrhK64DD5TH1JVxR4JbuQpmRSFKi4SHQD2TrSrDFU8AK16YSjN7K8WSfjAfnZeJeskBtkgr73LbPZc4vMbQr3YvHj", "address_index"=>1}
|
62
|
+
|
55
63
|
___
|
56
64
|
|
57
65
|
Create a new address for a payment (integrated address)
|
@@ -59,7 +67,15 @@ Create a new address for a payment (integrated address)
|
|
59
67
|
RPC::Wallet.make_integrated_address
|
60
68
|
=> {"integrated_address"=>"A7TmpAyaPeZLnugTKRSwGJhW4vnYv8RAVdRvYyvbistbHUnojyTHyHcYpbZvbTZHDsi4rF1EK5TiYgnCN6FWM9HjfufSYUchQ8hH2R272H",
|
61
69
|
"payment_id"=>"9d985c985ce58a8e"}
|
70
|
+
___
|
71
|
+
|
72
|
+
Get a list of all Adresses of your wallet
|
73
|
+
|
74
|
+
RPC::Wallet.get_addresses
|
75
|
+
|
62
76
|
___
|
77
|
+
|
78
|
+
|
63
79
|
To get the balance of the current wallet (we use the gem 'money')
|
64
80
|
|
65
81
|
RPC::Wallet.balance
|
@@ -117,14 +133,46 @@ To send payments to multiple recipients simply use an array of `[:recipient, :am
|
|
117
133
|
___
|
118
134
|
|
119
135
|
|
136
|
+
To get a list of transfers you call `get_transfers(args)`. Options are `in (true)`, `out (false)`, `pending (true)`, `failed (false)`, `pool (true)`, `filter_by_height (false)`, `min_height` and `max_height`
|
137
|
+
|
138
|
+
___
|
139
|
+
|
140
|
+
To get all incoming transfers use `get_all_incoming_transfers(args)`. Args can be `min_height` and `max_height` to filter accordingly. Result is a list of `RPC::IncomingTransfer` objects.
|
141
|
+
|
142
|
+
incomes = RPC::Wallet.get_all_incoming_transfers(min_height: 1087400)
|
143
|
+
=> [#<RPC::IncomingTransfer:0x000000036d3ca8 ...>, #<RPC::IncomingTransfer:0x000000036d38c0 ...>, #<RPC::IncomingTransfer:0x000000036d3258 ...>, #<RPC::IncomingTransfer:0x000000036d2c90 ...> ....
|
144
|
+
|
145
|
+
incomes.first.confirmed?
|
146
|
+
=> false
|
147
|
+
|
148
|
+
incomes.first.pending?
|
149
|
+
=> true
|
150
|
+
|
151
|
+
incomes.first.confirmations?
|
152
|
+
=> 0
|
153
|
+
|
154
|
+
incomes.first.address
|
155
|
+
=> "9vN5sHeH2a6AbRsB1dZ3APavL3YyFLguhh5pu2cAHb4CTY9GtnsEsBYTzwxzL6XH4Uby2Svju8sYvZN7mDMcd6MTKDvBgVR"
|
156
|
+
|
157
|
+
incomes.first.amount
|
158
|
+
=> 0.40123
|
159
|
+
|
160
|
+
You can use your own custom class by using the config `RPC.config.transfer_clazz = "MyCustomMoneroTransfer"`
|
161
|
+
|
162
|
+
___
|
163
|
+
|
164
|
+
For a specific Transfer simply call `get_transfer_by_txid(tx_id)`
|
165
|
+
|
166
|
+
___
|
167
|
+
|
168
|
+
|
169
|
+
|
120
170
|
## Donations
|
121
171
|
If this was useful you might consider a small donation:
|
122
172
|
|
123
|
-
- XMR:
|
124
|
-
- BTC:
|
125
|
-
- LTC:
|
126
|
-
|
173
|
+
- XMR: 48ie1HGrxvp4PE8DwSaKSSJtwnwAWitsE6U3oiybsa9VVrywayMJJZpMx1MvqJfxihBv9cnriufv5KXWd45xVQCrPAjkFBR
|
127
174
|
|
175
|
+
Even better would be your contribution to the code. Let's work together and make this gem a great place for all Monero fans! Don't just fork and do your own thing. My idea for this gem isn't the way we have to do. Feel free to bring yourself into this project. I'm willing to change everything from scratch if it will benefit the future.
|
128
176
|
|
129
177
|
|
130
178
|
## LICENSE
|
data/lib/monero.rb
CHANGED
data/lib/rpc/config.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
module RPC
|
2
|
+
class IncomingTransfer
|
3
|
+
|
4
|
+
attr_accessor :address, :amount, :double_spend_seen, :fee, :height, :note, :payment_id, :subaddr_index, :timestamp, :txid, :type, :unlock_time
|
5
|
+
|
6
|
+
def initialize(args={})
|
7
|
+
args.each do |k,v|
|
8
|
+
self.send("#{k}=", v)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def confirmations
|
13
|
+
pending? ? 0 : RPC::Wallet.getheight - height
|
14
|
+
end
|
15
|
+
|
16
|
+
def confirmed?
|
17
|
+
confirmations >= 10
|
18
|
+
end
|
19
|
+
|
20
|
+
def pending?
|
21
|
+
height == 0
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
data/lib/rpc/transfer.rb
CHANGED
@@ -44,7 +44,7 @@ module RPC
|
|
44
44
|
|
45
45
|
|
46
46
|
options = {
|
47
|
-
destinations: destinations, fee: fee, mixin: mixin, unlock_time: unlock_time,
|
47
|
+
destinations: destinations, fee: fee, mixin: mixin, unlock_time: unlock_time,
|
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
|
|
data/lib/rpc/version.rb
CHANGED
data/lib/rpc/wallet.rb
CHANGED
@@ -81,9 +81,23 @@ module RPC
|
|
81
81
|
min_height = args.fetch(:min_height, 0)
|
82
82
|
max_height = args.fetch(:max_height, 0)
|
83
83
|
|
84
|
-
options = {in: f_in, out: out, pending: pending, failed: failed, pool: pool, filter_by_height: filter_by_height, min_height: min_height
|
84
|
+
options = {in: f_in, out: out, pending: pending, failed: failed, pool: pool, filter_by_height: filter_by_height, min_height: min_height}
|
85
|
+
options[:max_height] = max_height if max_height > min_height
|
85
86
|
|
86
|
-
|
87
|
+
h = Hash.new
|
88
|
+
json = RPC::Client.request("get_transfers", options)
|
89
|
+
json.map{|k, v|
|
90
|
+
h[k] = v.collect{|transfer| (RPC.config.transfer_clazz || "RPC::IncomingTransfer").constantize.new(transfer)}
|
91
|
+
}
|
92
|
+
return h
|
93
|
+
end
|
94
|
+
|
95
|
+
def self.get_all_incoming_transfers(args={})
|
96
|
+
min_height = args.fetch(:min_height, 0)
|
97
|
+
max_height = args.fetch(:max_height, 0)
|
98
|
+
|
99
|
+
all = get_transfers(filter_by_height: true, min_height: min_height, max_height: max_height, in: true, out: false, pending: true, pool: true)
|
100
|
+
[ all["in"], all["pending"], all["pool"]].flatten.compact
|
87
101
|
end
|
88
102
|
|
89
103
|
def self.get_transfer_by_txid(txid)
|
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.5
|
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-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -78,6 +78,7 @@ files:
|
|
78
78
|
- lib/monero.rb
|
79
79
|
- lib/rpc/client.rb
|
80
80
|
- lib/rpc/config.rb
|
81
|
+
- lib/rpc/incoming_transfer.rb
|
81
82
|
- lib/rpc/payment.rb
|
82
83
|
- lib/rpc/transfer.rb
|
83
84
|
- lib/rpc/version.rb
|