bc 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/lib/bc.rb +34 -7
- metadata +4 -4
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/bc.rb
CHANGED
@@ -79,6 +79,14 @@ module Bitcoin
|
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
+
# EmptyKeypool is raised when the Bitcoin keypool is empty, but the wallet is
|
83
|
+
# locked. Call refill_key_pool() on the Bitcoin::Client instance to refill it.
|
84
|
+
class EmptyKeypool < Error
|
85
|
+
def initialize()
|
86
|
+
super('The Bitcoin key pool ran out.')
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
82
90
|
# This class represents a block in the Bitcoin block chain. (c.f.
|
83
91
|
# https://en.bitcoin.it/wiki/Block and
|
84
92
|
# https://en.bitcoin.it/wiki/Block_hashing_algorithm)
|
@@ -320,12 +328,28 @@ module Bitcoin
|
|
320
328
|
# Get an unused Address associated with this account, or create one if one
|
321
329
|
# doesn't already exist.
|
322
330
|
def unused_address
|
323
|
-
|
331
|
+
begin
|
332
|
+
@bc.get_address(@bc.jr.getaccountaddress(@name))
|
333
|
+
rescue Jr::ServerError => ex
|
334
|
+
if ex.code == -12
|
335
|
+
raise EmptyKeypool
|
336
|
+
else
|
337
|
+
raise
|
338
|
+
end
|
339
|
+
end
|
324
340
|
end
|
325
341
|
|
326
342
|
# Get a new Address associated with this account.
|
327
343
|
def new_address
|
328
|
-
|
344
|
+
begin
|
345
|
+
@bc.get_address(@bc.jr.getnewaddress(@name))
|
346
|
+
rescue Jr::ServerError => ex
|
347
|
+
if ex.code == -12
|
348
|
+
raise EmptyKeypool
|
349
|
+
else
|
350
|
+
raise
|
351
|
+
end
|
352
|
+
end
|
329
353
|
end
|
330
354
|
|
331
355
|
# Send +amount+ Bitcoin to +dest+. +amount+ should be a positive real
|
@@ -584,16 +608,13 @@ module Bitcoin
|
|
584
608
|
# UnknownTransaction if we don't know about a Transaction with that ID.
|
585
609
|
# The result of this function is cached.
|
586
610
|
def get_transaction(transaction_id)
|
587
|
-
if transaction_id.is_a?(Fixnum)
|
588
|
-
end
|
589
|
-
|
590
611
|
@transactions[transaction_id] ||= Transaction.new(self, transaction_id)
|
591
612
|
end
|
592
613
|
|
593
614
|
# Call the (Ruby) block passed for every transaction that has occurred since
|
594
615
|
# +block+ (which may be a Block, a block ID, or a block height). We return
|
595
616
|
# the last Block processed.
|
596
|
-
def
|
617
|
+
def each_transaction_since(block)
|
597
618
|
unless block.is_a?(Block)
|
598
619
|
block = get_block(block)
|
599
620
|
end
|
@@ -614,7 +635,13 @@ module Bitcoin
|
|
614
635
|
|
615
636
|
# Get an Array of every Transaction involving one of our addresses.
|
616
637
|
def transactions
|
617
|
-
|
638
|
+
transactions = Array.new
|
639
|
+
|
640
|
+
each_transaction_since(0) do |tx|
|
641
|
+
transactions << tx
|
642
|
+
end
|
643
|
+
|
644
|
+
transactions
|
618
645
|
end
|
619
646
|
|
620
647
|
# This is the latest Block we've processed.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -50,11 +50,11 @@ cert_chain:
|
|
50
50
|
-----END CERTIFICATE-----
|
51
51
|
|
52
52
|
'
|
53
|
-
date: 2012-03-
|
53
|
+
date: 2012-03-19 00:00:00.000000000 Z
|
54
54
|
dependencies:
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: jr
|
57
|
-
requirement: &
|
57
|
+
requirement: &72538340 !ruby/object:Gem::Requirement
|
58
58
|
none: false
|
59
59
|
requirements:
|
60
60
|
- - ! '>='
|
@@ -62,7 +62,7 @@ dependencies:
|
|
62
62
|
version: '0'
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
|
-
version_requirements: *
|
65
|
+
version_requirements: *72538340
|
66
66
|
description: bc is a Ruby interface to bitcoind.
|
67
67
|
email: the.magical.kat@gmail.com
|
68
68
|
executables: []
|
metadata.gz.sig
CHANGED
Binary file
|