blockchain-wallet 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cf8b849e11d5dadb5af3bfa31bc78025295a5eb5
4
- data.tar.gz: 4be8ac44d67885e26cc8bc31345b9860931e2f19
3
+ metadata.gz: 0c19df85920bdf7ce3d19981e4fd01b3132ec25d
4
+ data.tar.gz: 15f47e399bb7d36b5ee88cd3317fa5b0f9f86e11
5
5
  SHA512:
6
- metadata.gz: fcfc3f27d50a70ddc6954ef4c412cf05e3b66d569af135a38bf7cec49deafd4ae2a4d9eb35a1d96ca72b0900af17478e20ccc7fa3640534b9d005ca63006e144
7
- data.tar.gz: 5bc2c022e9546cb1a5f87c6f724ad145a2c7e8f2399af4b88e0c26312f7360f10a5bab1437a6ba3d2c00a283176735f2000234fe14fd17ebb87e5264fcf470df
6
+ metadata.gz: d79f215b66c3445c92f8480fdcb13f7a75574f553727306cd5a899c84634b13730fd885bff556247156892213d5dc88a1f682cadcd0fea85e721bfd4e9016441
7
+ data.tar.gz: a17704649606f9fb2e4b234e99f66f696be80c8ea29c4dd9d2efd2b789e89a56d6750470c51546cc956b3c02c0be5a8bb676f9f23aebb2a6dca377b95af69ba7
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # BlockchainWallet
1
+ # Blockchain.info Wallet API for Ruby
2
2
 
3
- Blockchain.info Wallet API for Ruby
3
+ Provides access to all blockchain.info Wallet API functions ( https://blockchain.info/api/blockchain_wallet_api )
4
4
 
5
5
  ## Installation
6
6
 
@@ -18,7 +18,13 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
21
+ First you need to create wallet object with your guid, password and second password:
22
+
23
+ wallet = BlockchainWallet::Wallet.new("b14d36af-2fa6-4d76-91b5-ff70b8370ec7", "n$grJ74hAshfggnb6864%j78@#^hChttp://ya.ru@contentpurl", nil)
24
+
25
+ Then your can call any API method to invoke him. For example:
26
+
27
+ wallet.addresses
22
28
 
23
29
  ## Contributing
24
30
 
@@ -8,9 +8,9 @@ Gem::Specification.new do |spec|
8
8
  spec.version = BlockchainWallet::VERSION
9
9
  spec.authors = ["Sergey Tolmachev"]
10
10
  spec.email = ["tolsi.ru@gmail.com"]
11
- spec.description = "Blockchain.info Wallet API for Ruby"
12
- spec.summary = ""
13
- spec.homepage = ""
11
+ spec.description = "Provides access to all blockchain.info Wallet API functions ( https://blockchain.info/api/blockchain_wallet_api )"
12
+ spec.summary = "Blockchain.info Wallet API for Ruby"
13
+ spec.homepage = "https://github.com/Tolsi/blockchain-wallet-ruby"
14
14
  spec.license = "CC-BY"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
@@ -21,8 +21,6 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
22
  spec.add_development_dependency "rake"
23
23
  spec.add_development_dependency "rspec"
24
- spec.add_development_dependency "debase"
25
- spec.add_development_dependency "ruby-debug-ide"
26
24
 
27
25
  spec.add_dependency "immutable_struct"
28
26
  spec.add_dependency "oj"
@@ -44,6 +44,13 @@ module BlockchainWallet
44
44
  handle(url) { |answer| answer.consolidated }
45
45
  end
46
46
 
47
+ def payment(address, amount, from, shared, fee, note)
48
+ url = build_url("payment", {:password => @password, :second_password => @second_password, :to => address, :amount => bitcoins_to_satoshi(amount),
49
+ :from => from, :shared => shared, :fee => fee, :note => note})
50
+ handle(url) { |answer| answer }
51
+ end
52
+
53
+
47
54
  attr_reader :guid
48
55
 
49
56
  private
@@ -54,6 +61,7 @@ module BlockchainWallet
54
61
  def handle(url)
55
62
  answer = execute_request(url)
56
63
  check_error(answer)
64
+ answer['balance'] = satoshi_to_bitcoins(answer['balance']) if answer['balance']
57
65
  yield ImmutableStruct.new(*answer.keys.map(&:to_sym)).new(*answer.values)
58
66
  end
59
67
 
@@ -64,6 +72,14 @@ module BlockchainWallet
64
72
  raise BlockchainException, ex.message
65
73
  end
66
74
 
75
+ def satoshi_to_bitcoins(satoshi)
76
+ satoshi / (10 ** 8)
77
+ end
78
+
79
+ def bitcoins_to_satoshi(bitcoins)
80
+ satoshi * (10 ** 8)
81
+ end
82
+
67
83
  def check_error(answer)
68
84
  error = answer['error']
69
85
  raise WebApiException, error if error
@@ -1,3 +1,3 @@
1
1
  module BlockchainWallet
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -6,7 +6,7 @@ class WebAPI
6
6
  end
7
7
 
8
8
  def build_url(operation_name, params)
9
- @url + operation_name + "?" + params.map { |param, value| "#{param}=#{value}" }.join("&")
9
+ @url + operation_name + "?" + params.map { |param, value| "#{param}=#{value}" if value }.join("&")
10
10
  end
11
11
 
12
12
 
@@ -8,8 +8,8 @@ describe BlockchainWallet, ".addresses" do
8
8
  end
9
9
  end
10
10
 
11
- describe BlockchainWallet, "#addresses" do
12
- it "returns all addresses" do
11
+ describe BlockchainWallet, ".address_balance" do
12
+ it "should return '1JX7FrBm4Y96Z8BN6m9fWLN3bWVrEZ7dVs' balance >=0" do
13
13
  wallet = BlockchainWallet::Wallet.new("b14d36af-2fa6-4d76-91b5-ff70b8370ec7", "n$grJ74hAshfggnb6864%j78@#^hChttp://ya.ru@contentpurl", nil)
14
14
  address_balance=wallet.address_balance("1JX7FrBm4Y96Z8BN6m9fWLN3bWVrEZ7dVs")
15
15
  address_balance.balance.should >=(0)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blockchain-wallet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Tolmachev
@@ -52,34 +52,6 @@ dependencies:
52
52
  - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: debase
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - '>='
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: ruby-debug-ide
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - '>='
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - '>='
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
55
  - !ruby/object:Gem::Dependency
84
56
  name: immutable_struct
85
57
  requirement: !ruby/object:Gem::Requirement
@@ -108,7 +80,8 @@ dependencies:
108
80
  - - '>='
109
81
  - !ruby/object:Gem::Version
110
82
  version: '0'
111
- description: Blockchain.info Wallet API for Ruby
83
+ description: Provides access to all blockchain.info Wallet API functions ( https://blockchain.info/api/blockchain_wallet_api
84
+ )
112
85
  email:
113
86
  - tolsi.ru@gmail.com
114
87
  executables: []
@@ -125,7 +98,7 @@ files:
125
98
  - lib/blockchain/wallet/version.rb
126
99
  - lib/blockchain/web_api.rb
127
100
  - spec/BlockChainWalletSpec.rb
128
- homepage: ''
101
+ homepage: https://github.com/Tolsi/blockchain-wallet-ruby
129
102
  licenses:
130
103
  - CC-BY
131
104
  metadata: {}
@@ -148,6 +121,6 @@ rubyforge_project:
148
121
  rubygems_version: 2.1.9
149
122
  signing_key:
150
123
  specification_version: 4
151
- summary: ''
124
+ summary: Blockchain.info Wallet API for Ruby
152
125
  test_files:
153
126
  - spec/BlockChainWalletSpec.rb