onchain 2.4 → 2.5

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/onchain/transaction.rb +8 -0
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 034458f790aa11b634b8bb69124f656c0eda1f9b
4
- data.tar.gz: 183a2755af1208eb7dc3c0a985986d4e5f592095
3
+ metadata.gz: 75e5c8220374d307aa3f82bdb6e216c06d2f587c
4
+ data.tar.gz: a889f8795cd4958e2f4ff95fb105e721d12857d3
5
5
  SHA512:
6
- metadata.gz: 3b257a25e848762377438c1cde57b3fc9e34d2e2329c8f9b38ee3bae30b4238e9ff7282b85681096178b40935cee8593e66f5f291b7a77df9c44b10d99f5bc11
7
- data.tar.gz: 2f4da8dda8a8b4476817a0491f01a64720f34a63868099936c72dcb464207138ca6b4815d94f3a6bd1e7b93277e00db3931d586c397abb95f28ab1ac53bb4858
6
+ metadata.gz: 9bd3003993dca0e2378427eeab184b2175acf477b89a0316bbd082f3c828d20867630792f2279f8093387198f7463d1fec8ec30e9b559439d5c8b2cffb633c5b
7
+ data.tar.gz: 2987be8bced4ef31dc15781f642f39f7b512ccf8db1385e20b0782ce571da1e1017099ac59d50cf0dd9149bddc02eaa89b1eb25a74ce0c3a1624208977ed9cdf
@@ -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'
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-16 00:00:00.000000000 Z
11
+ date: 2016-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake