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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/onchain/payments.rb +12 -1
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 429a0f9abce6c457a94880105930acd85f3cc951
4
- data.tar.gz: 1e703f989156b93816b8f50e320ddcf7578b47c1
3
+ metadata.gz: 347bb7fa07b5d79c3122d761a990c916da555a7f
4
+ data.tar.gz: b836d647239835e38eb1dd33afd8c9fdf4c0449d
5
5
  SHA512:
6
- metadata.gz: 5357381557a5d0f4fddc909ea61f1122abec7bfde506a39a0b4a6dd02cd122ad38cd6a6a798652052d4af32c076b5f0c9c512013fcce713ec0d8f2f4ee5533fe
7
- data.tar.gz: 929bb1c704c84282d559fcc2efe0085db922cfdcc83551ab4f085729415cdc3ea4a61dbecfec122c3aeca7756d21d646af8d29642fa05ed19ea766b9c30b4a01
6
+ metadata.gz: 29e19e69652a5593f68110296c498c3ae93d547ee2ad54b20a79277e11ab78dc47bf7cb5e5c188a0995848c08f22f74f997cf0641dcd9813caa1cc695bf670f5
7
+ data.tar.gz: f230c061fc8a000716f8aa8638a76a0012c7d1d3cc65ecafcdd545f8fedb079e02172167a6ac7905a622bc8df70d4b24a6f1bc0cb4b81b753a1a0d1ac4787f5a
@@ -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 = 0
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.9
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-06 00:00:00.000000000 Z
11
+ date: 2014-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake