Class: Blockchain::Wallet
Defined Under Namespace
Classes: BlockchainException
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
-
#address_balance(address, confirmations = 0) ⇒ Object
-
#addresses ⇒ Object
-
#archive_address(address) ⇒ Object
-
#auto_consolidate(days) ⇒ Object
-
#initialize(guid, password, second_password) ⇒ Wallet
constructor
A new instance of Wallet.
-
#new_address(label = nil) ⇒ Object
-
#payment(address, amount, from = nil, shared = nil, fee = nil, note = nil) ⇒ Object
-
#sendmany(recipients, from = nil, shared = nil, fee = nil, note = nil) ⇒ Object
-
#unarchive_address(address) ⇒ Object
Methods inherited from WebAPI
#build_url
Constructor Details
#initialize(guid, password, second_password) ⇒ Wallet
Returns a new instance of Wallet.
10
11
12
13
14
15
|
# File 'lib/blockchain/wallet.rb', line 10
def initialize(guid, password, second_password)
super("https://blockchain.info/merchant/#{guid}/")
@guid = guid
@password = password
@second_password = second_password
end
|
Instance Attribute Details
#guid ⇒ Object
Returns the value of attribute guid.
68
69
70
|
# File 'lib/blockchain/wallet.rb', line 68
def guid
@guid
end
|
Class Method Details
.bitcoins_to_satoshi(bitcoins) ⇒ Object
22
23
24
|
# File 'lib/blockchain/wallet.rb', line 22
def self.bitcoins_to_satoshi(bitcoins)
bitcoins * (10 ** 8)
end
|
.satoshi_to_bitcoins(satoshi) ⇒ Object
18
19
20
|
# File 'lib/blockchain/wallet.rb', line 18
def self.satoshi_to_bitcoins(satoshi)
satoshi / (10 ** 8)
end
|
Instance Method Details
#address_balance(address, confirmations = 0) ⇒ Object
31
32
33
34
|
# File 'lib/blockchain/wallet.rb', line 31
def address_balance(address, confirmations = 0)
url = build_url("address_balance", {:password => @password, :address => address, :confirmations => confirmations})
handle(url) { |answer| answer }
end
|
#addresses ⇒ Object
26
27
28
29
|
# File 'lib/blockchain/wallet.rb', line 26
def addresses
url = build_url("list", {:password => @password})
handle(url) { |answer| answer.addresses }
end
|
#archive_address(address) ⇒ Object
41
42
43
44
|
# File 'lib/blockchain/wallet.rb', line 41
def archive_address(address)
url = build_url("archive_address", {:password => @password, :second_password => @second_password, :address => address})
handle(url) { |answer| answer.archived == address }
end
|
#auto_consolidate(days) ⇒ Object
51
52
53
54
|
# File 'lib/blockchain/wallet.rb', line 51
def auto_consolidate(days)
url = build_url("auto_consolidate", {:password => @password, :second_password => @second_password, :days => days})
handle(url) { |answer| answer.consolidated }
end
|
#new_address(label = nil) ⇒ Object
36
37
38
39
|
# File 'lib/blockchain/wallet.rb', line 36
def new_address(label = nil)
url = build_url("new_address", {:password => @password, :second_password => @second_password, :label => label})
handle(url) { |answer| answer }
end
|
#payment(address, amount, from = nil, shared = nil, fee = nil, note = nil) ⇒ Object
56
57
58
59
60
|
# File 'lib/blockchain/wallet.rb', line 56
def payment(address, amount, from = nil, shared = nil, fee = nil, note = nil)
url = build_url("payment", {:password => @password, :second_password => @second_password, :to => address, :amount => Wallet::bitcoins_to_satoshi(amount),
:from => from, :shared => shared, :fee => fee, :note => note})
handle(url) { |answer| answer }
end
|
#sendmany(recipients, from = nil, shared = nil, fee = nil, note = nil) ⇒ Object
62
63
64
65
66
|
# File 'lib/blockchain/wallet.rb', line 62
def sendmany(recipients, from = nil, shared = nil, fee = nil, note = nil)
url = build_url("sendmany", {:password => @password, :second_password => @second_password, :recipients => recipients,
:from => from, :shared => shared, :fee => fee, :note => note})
handle(url) { |answer| answer }
end
|
#unarchive_address(address) ⇒ Object
46
47
48
49
|
# File 'lib/blockchain/wallet.rb', line 46
def unarchive_address(address)
url = build_url("unarchive_address", {:password => @password, :second_password => @second_password, :address => address})
handle(url) { |answer| answer.active == address }
end
|