monero 0.0.0.2 → 0.0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8b0549acfa68f3efdc2d4a1a141a460ed180a699
4
- data.tar.gz: a554fde5c534e43c9e019ae008630f8c792c9b05
3
+ metadata.gz: 46d9e1f4f3fa414f5ee98f81eff0587179e7d698
4
+ data.tar.gz: abb4704507ed4f866e0f3a16e431777bdfcd5063
5
5
  SHA512:
6
- metadata.gz: c756cdb2a4b451692e704219ad76b768f9ea3e183618fa1de2fe4207d0b111ebcd7e9e448e5fdca044aa3f149ddabb1fca919cdd9c415e80fed53fbc25e1ef12
7
- data.tar.gz: dd78a9e2f341d2665ee4e7cb7277bde30e851914f44787723a163c9bc26cd9cc81eb9c8e8ea6c444d2675f50920af4a92ac1057b96fd94ca2c6317a4bc616684
6
+ metadata.gz: 7406a2206cb17cb7eb780d3a577f5cfe4f46996b777e8fc2588bbc5fb33ede0bbad0091418887c381edb53de1abf3de84b6b4683e6619ed106494f4b62eda111
7
+ data.tar.gz: adf0f08579354a7ee9bafa3655323ab63dbd2648e16270d0a1e99b431c28567a44656a5eeb56a73ad1ada3767e0fff409e080fe0a18c857d83f5aefc4e8a185f
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ *updating and testing for 0.12 soon*
2
+
1
3
  # Monero Ruby Client
2
4
 
3
5
  Ruby client to connect and use [Monero Wallet RPC](https://getmonero.org/resources/developer-guides/wallet-rpc.html).
@@ -67,6 +69,18 @@ To get the balance of the current wallet (we use the gem 'money')
67
69
  Monero::Wallet.balance.format
68
70
  => "9.980629640000 XMR"
69
71
 
72
+ To get the unlocked balance, which is currently available
73
+
74
+ Monero::Wallet.unlocked_balance
75
+ => #<Money fractional:10000 currency:XMR>
76
+
77
+ To get both combined
78
+
79
+ Monero::Wallet.getbalance
80
+ => {"balance"=>9961213880000, "unlocked_balance"=>10000}
81
+
82
+
83
+
70
84
  ___
71
85
  To get the current block height
72
86
 
@@ -16,8 +16,6 @@ end
16
16
  # include Monero::Model
17
17
  # end
18
18
 
19
-
20
-
21
19
  Money::Currency.register({ :priority => 1, :iso_code => "xmr", :iso_numeric => "846", :name => "Monero", :symbol => "XMR", :subunit => "", :subunit_to_unit => 1000000000000, :decimal_mark => ".", :thousands_separator => ""})
22
20
  #
23
21
  class XMR
@@ -1,5 +1,7 @@
1
1
  module Monero
2
2
  class Client
3
+ #class RequestError < StandardError; end
4
+
3
5
 
4
6
  def self.close!
5
7
  request("stop_wallet")
@@ -8,7 +10,8 @@ module Monero
8
10
  def self.request(method, params="")
9
11
  data = '{"jsonrpc":"2.0","id":"0","method": "'+method+'", "params": '+params.to_json+' }'
10
12
 
11
- args = " -s"
13
+ args = ""
14
+ args << " -s"
12
15
  args << " -u #{Monero.config.username}:#{Monero.config.password} --digest"
13
16
  args << " -X POST #{base_uri}/json_rpc"
14
17
  args << " -d '#{data}'"
@@ -17,6 +20,12 @@ module Monero
17
20
  p "curl #{args}" if Monero.config.debug
18
21
 
19
22
  json = JSON.parse(`curl #{args}`)
23
+
24
+ # Error handling
25
+ if json["error"]
26
+ raise "#{json["error"]["message"]} | code: #{json["error"]["code"]}"
27
+ end
28
+
20
29
  json["result"]
21
30
  end
22
31
 
@@ -1,3 +1,3 @@
1
1
  module Monero
2
- VERSION = "0.0.0.2"
2
+ VERSION = "0.0.0.3"
3
3
  end
@@ -2,6 +2,10 @@ module Monero
2
2
 
3
3
  class Wallet
4
4
 
5
+ def self.create_address(label="")
6
+ Monero::Client.request("create_address", label: label)
7
+ end
8
+
5
9
  def self.getaddress
6
10
  Monero::Client.request("getaddress")["address"]
7
11
  end
@@ -93,7 +97,7 @@ module Monero
93
97
  singleton_class.send(:alias_method, :create, :create_wallet)
94
98
 
95
99
  # returns current balance if open successfull
96
- def self.open_wallet(filename, password)
100
+ def self.open_wallet(filename, password="")
97
101
  options = { filename: filename, password: password}
98
102
  if Monero::Client.request("open_wallet", options)
99
103
  balance
@@ -103,7 +107,7 @@ module Monero
103
107
  end
104
108
  singleton_class.send(:alias_method, :open, :open_wallet)
105
109
 
106
- # stops current wallet
110
+ # stops current RPC process!
107
111
  def self.stop_wallet
108
112
  Monero::Client.close!
109
113
  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.2
4
+ version: 0.0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Kretschmer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-29 00:00:00.000000000 Z
11
+ date: 2018-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler