onchain 2.1.4 → 2.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/onchain/transaction.rb +23 -2
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8b99554b564369f04613638da0a8f4e2e65bb218
4
- data.tar.gz: 6ec490f1bbc99024e18c75fdf72ccdf20c1557e9
3
+ metadata.gz: da08e99a19308739fd1b094c0f49fdc77a3a3a47
4
+ data.tar.gz: e18db7ffc4b67db018bac4d56dca017027e60c3e
5
5
  SHA512:
6
- metadata.gz: 68e682b086b3074a319b67dd741e5b0ee7c2e83baaa3b1e381abf1b59b73ac11267604f4910496e15c061d147f23a0fbcc9e0c3636fed31b4f433e303e482bc2
7
- data.tar.gz: 87ddeccd270eceb66998463241f0a6dea4334d235999ea13c8d1ce560a1560544cb524f7ac60fe5286cde665260b96554b1b083b3a2b90a0becb6bb067f62cf1
6
+ metadata.gz: 265ecdb23042caa3d317f15c7be60297298f52b1f19d5e9fa2fbc685bd21a4a29268ca85a6c62164db97aa65d44244d3821c70ec9359cd1def352fb008822a37
7
+ data.tar.gz: 1e8245a12f81f9f916769b426a58ff89189203cf2cb7f95fef680582ccdc970bd3fdcd7bb9ac37c27eca6b259dfaa5023aec14f7b087b2f403dcb1c82129c765
@@ -4,8 +4,10 @@ class OnChain::Transaction
4
4
  def create_single_address_transaction(orig_addr, dest_addr, amount, fee_percent, fee_addr)
5
5
 
6
6
  tx = Bitcoin::Protocol::Tx.new
7
+
8
+ fee = calculate_fee(amount, fee_percent)
7
9
 
8
- total_amount = amount + calculate_fee(amount, fee_percent)
10
+ total_amount = amount + fee
9
11
 
10
12
  unspents, indexes, change = OnChain::BlockChain.get_unspent_for_amount(
11
13
  [orig_addr], total_amount)
@@ -21,6 +23,25 @@ class OnChain::Transaction
21
23
  txout = Bitcoin::Protocol::TxOut.new(amount, Bitcoin::Script.to_address_script(dest_addr))
22
24
 
23
25
  tx.add_out(txout)
26
+
27
+ # Add wallet fee
28
+ if fee > 0 and (fee - 10000) > 0
29
+
30
+ # Take the miners fee from the wallet fees
31
+ fee = fee - 10000
32
+
33
+ # Check for affiliate
34
+ if fee_addr.kind_of?(Array)
35
+ affil_fee = fee / 2
36
+ txout1 = Bitcoin::Protocol::TxOut.new(affil_fee, Bitcoin::Script.to_address_script(fee_addr[0]))
37
+ txout2 = Bitcoin::Protocol::TxOut.new(affil_fee, Bitcoin::Script.to_address_script(fee_addr[1]))
38
+ tx.add_out(txout1)
39
+ tx.add_out(txout2)
40
+ else
41
+ txout = Bitcoin::Protocol::TxOut.new(fee, Bitcoin::Script.to_address_script(fee_addr))
42
+ tx.add_out(txout)
43
+ end
44
+ end
24
45
 
25
46
  # Send the change back.
26
47
  if change > 0
@@ -40,7 +61,7 @@ class OnChain::Transaction
40
61
  fee = (amount * (fee_percent / 100.0)).to_i
41
62
 
42
63
  if fee < 10000
43
- return 0
64
+ return 10000
44
65
  end
45
66
 
46
67
  return fee
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.1.4
4
+ version: 2.1.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: 2014-12-15 00:00:00.000000000 Z
11
+ date: 2015-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake