onchain 2.1.4 → 2.1.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 +23 -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: da08e99a19308739fd1b094c0f49fdc77a3a3a47
|
4
|
+
data.tar.gz: e18db7ffc4b67db018bac4d56dca017027e60c3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 265ecdb23042caa3d317f15c7be60297298f52b1f19d5e9fa2fbc685bd21a4a29268ca85a6c62164db97aa65d44244d3821c70ec9359cd1def352fb008822a37
|
7
|
+
data.tar.gz: 1e8245a12f81f9f916769b426a58ff89189203cf2cb7f95fef680582ccdc970bd3fdcd7bb9ac37c27eca6b259dfaa5023aec14f7b087b2f403dcb1c82129c765
|
data/lib/onchain/transaction.rb
CHANGED
@@ -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 +
|
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
|
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
|
+
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:
|
11
|
+
date: 2015-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|