onchain 1.0.9 → 1.0.10
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.
- checksums.yaml +4 -4
- data/lib/onchain/payments.rb +12 -1
- 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: 347bb7fa07b5d79c3122d761a990c916da555a7f
|
4
|
+
data.tar.gz: b836d647239835e38eb1dd33afd8c9fdf4c0449d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29e19e69652a5593f68110296c498c3ae93d547ee2ad54b20a79277e11ab78dc47bf7cb5e5c188a0995848c08f22f74f997cf0641dcd9813caa1cc695bf670f5
|
7
|
+
data.tar.gz: f230c061fc8a000716f8aa8638a76a0012c7d1d3cc65ecafcdd545f8fedb079e02172167a6ac7905a622bc8df70d4b24a6f1bc0cb4b81b753a1a0d1ac4787f5a
|
data/lib/onchain/payments.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
class OnChain
|
2
2
|
class << self
|
3
3
|
|
4
|
+
FEE = 5000
|
5
|
+
|
4
6
|
def get_address_from_redemption_script(redemption_script)
|
5
7
|
|
6
8
|
sbin = redemption_script.scan(/../).map { |x| x.hex }.pack('c*')
|
@@ -25,7 +27,7 @@ class OnChain
|
|
25
27
|
|
26
28
|
tx = Bitcoin::Protocol::Tx.new
|
27
29
|
|
28
|
-
total_amount =
|
30
|
+
total_amount = FEE
|
29
31
|
|
30
32
|
payments.each do |payment|
|
31
33
|
if payment[1].is_a?(String)
|
@@ -69,6 +71,15 @@ class OnChain
|
|
69
71
|
tx.add_out(txout)
|
70
72
|
end
|
71
73
|
|
74
|
+
# Send the chnage back.
|
75
|
+
if total_in_fund > total_amount
|
76
|
+
|
77
|
+
txout = Bitcoin::Protocol::TxOut.new(total_in_fund - total_amount,
|
78
|
+
Bitcoin::Script.to_address_script(fund_address))
|
79
|
+
|
80
|
+
tx.add_out(txout)
|
81
|
+
end
|
82
|
+
|
72
83
|
return tx
|
73
84
|
|
74
85
|
rescue Exception => e
|
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.0.
|
4
|
+
version: 1.0.10
|
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-10-
|
11
|
+
date: 2014-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|