onchain 2.4 → 2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/onchain/transaction.rb +8 -0
- 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: 75e5c8220374d307aa3f82bdb6e216c06d2f587c
|
4
|
+
data.tar.gz: a889f8795cd4958e2f4ff95fb105e721d12857d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9bd3003993dca0e2378427eeab184b2175acf477b89a0316bbd082f3c828d20867630792f2279f8093387198f7463d1fec8ec30e9b559439d5c8b2cffb633c5b
|
7
|
+
data.tar.gz: 2987be8bced4ef31dc15781f642f39f7b512ccf8db1385e20b0782ce571da1e1017099ac59d50cf0dd9149bddc02eaa89b1eb25a74ce0c3a1624208977ed9cdf
|
data/lib/onchain/transaction.rb
CHANGED
@@ -17,6 +17,7 @@ class OnChain::Transaction
|
|
17
17
|
# Get the amount for the previous output
|
18
18
|
prevhex = OnChain::BlockChain.get_transaction(prev_hash)
|
19
19
|
prev_tx = Bitcoin::Protocol::Tx.new OnChain::hex_to_bin(prevhex)
|
20
|
+
|
20
21
|
input_amount += prev_tx.out[prev_index].value
|
21
22
|
|
22
23
|
if ! orig_addresses.include? prev_tx.out[prev_index].parsed_script.get_hash160_address
|
@@ -24,6 +25,13 @@ class OnChain::Transaction
|
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
28
|
+
# subtract the the chnage amounts
|
29
|
+
tx.out.each do |txout|
|
30
|
+
if orig_addresses.include? txout.parsed_script.get_address
|
31
|
+
input_amount = input_amount - txout.value
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
27
35
|
tolerence = (amount * (1 + tolerence))
|
28
36
|
if input_amount > tolerence
|
29
37
|
raise "Transaction has more input value (#{input_amount}) than the tolerence #{tolerence}"
|
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: '2.
|
4
|
+
version: '2.5'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ian Purton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|