onchain 1.4.2 → 1.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/onchain/block_chain.rb +31 -0
- data/lib/onchain/payments.rb +0 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e400fdca7f552c5ffb962ac42282e9b7bf65874c
|
4
|
+
data.tar.gz: 36ff64450f51c01f276f8364ca25b75743dbe35e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe0905bdfb048d425fb1216b2c008704dc2000bfead2e228be7777e560a91b841c2b8e37b3de888dc2852f842c40f48ff6d8eb2c9e91876f394715d52238f553
|
7
|
+
data.tar.gz: 9f4f5fa17a7b4c2bd7c57bb65f13215f9c184fb92987a26ee9c8908f038a5c7ba953004205adfd0f59f812711c52535bb1dbd2c12633554699651634a812f5e4
|
data/lib/onchain/block_chain.rb
CHANGED
@@ -75,6 +75,37 @@ class OnChain::BlockChain
|
|
75
75
|
return ret
|
76
76
|
end
|
77
77
|
|
78
|
+
def get_unspent_for_amount(addresses, amount_in_satoshi)
|
79
|
+
|
80
|
+
unspents = []
|
81
|
+
indexes = []
|
82
|
+
amount_so_far = 0
|
83
|
+
|
84
|
+
addresses.each_with_index do |address, index|
|
85
|
+
|
86
|
+
if amount_so_far >= amount_in_satoshi
|
87
|
+
break
|
88
|
+
end
|
89
|
+
|
90
|
+
unspent_outs = get_unspent_outs(address)
|
91
|
+
|
92
|
+
unspent_outs.each do |spent|
|
93
|
+
|
94
|
+
unspents << spent
|
95
|
+
indexes << index
|
96
|
+
|
97
|
+
amount_so_far = amount_so_far + spent[3].to_i
|
98
|
+
if amount_so_far >= amount_in_satoshi
|
99
|
+
break
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
change = amount_so_far - amount_in_satoshi
|
105
|
+
return unspents, indexes, change
|
106
|
+
|
107
|
+
end
|
108
|
+
|
78
109
|
def get_balance_satoshi(address)
|
79
110
|
return (get_balance(address).to_f * 100000000).to_i
|
80
111
|
end
|
data/lib/onchain/payments.rb
CHANGED
@@ -16,8 +16,6 @@ class OnChain::Payments
|
|
16
16
|
return Bitcoin::Script.new(OnChain::hex_to_bin(hex))
|
17
17
|
end
|
18
18
|
|
19
|
-
# With a bunch of HD wallet paths, build a transaction
|
20
|
-
# That pays all the coins to a certain address
|
21
19
|
def create_payment_tx(redemption_script, payments)
|
22
20
|
|
23
21
|
begin
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onchain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ian Purton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|