onchain 1.3.0 → 1.3.2

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/sweeper.rb +16 -7
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1df1d9f8e5f45a7a7c62c4af34d239203c976a92
4
- data.tar.gz: 757c03fd2a78f94ce2f2445b401ab3247facdd4e
3
+ metadata.gz: c374489d69f07c18eedd7d3e2575c8eaa887d8e0
4
+ data.tar.gz: 48c3f1239dd7eeb28768aa63a78668dbb56f1561
5
5
  SHA512:
6
- metadata.gz: 12a947e15cb74473389e57f09c00f689536eb4ea47552a36259eb41b3a10011fe7028099ee569f2a05dd7c645f3076b9138393dbded5c16924badde61c8b1243
7
- data.tar.gz: ff955c293ef7a2c9944f95caf32ba3f2163c2f11a1b777234d8de0a5194d1761497d78b7994560ce50db3a2e1e0fe0796adc401d21326c7fd36d73acc3bff298
6
+ metadata.gz: 5977e86a3b52e628b42f59bac2638a251a44cbb7abffbd7409e3ada411db0eb89304a0e63f5d69604e7e6d7d298c88d6eccbe380527d810585c2b07abfd47cfa
7
+ data.tar.gz: c36abc4382cf2281461f33bfd04add32caba20ab4d8d4dd7003ce98d41722dda892cb4c2e018233aa976e04f5ebca7d180b1dbe781bc21de10a0f25faad2f24b
@@ -5,6 +5,13 @@ class OnChain::Sweeper
5
5
  # i.e. derive the path.
6
6
  def multi_sig_address_from_mpks(mpks, path)
7
7
 
8
+ rs = generate_redemption_script_from_mpks(mpks, path)
9
+
10
+ return generate_address_of_redemption_script(rs)
11
+ end
12
+
13
+ def generate_redemption_script_from_mpks(mpks, path)
14
+
8
15
  addresses = []
9
16
  mpks.each do |mpk|
10
17
  master = MoneyTree::Node.from_serialized_address(mpk)
@@ -12,9 +19,7 @@ class OnChain::Sweeper
12
19
  addresses << m.public_key.to_hex
13
20
  end
14
21
 
15
- rs = generate_redemption_script(addresses)
16
-
17
- return generate_address_of_redemption_script(rs)
22
+ return generate_redemption_script(addresses)
18
23
  end
19
24
 
20
25
  def generate_redemption_script(addresses)
@@ -91,7 +96,7 @@ class OnChain::Sweeper
91
96
  return incoming_coins, block_height_now
92
97
  end
93
98
 
94
- def create_payment_tx_from_sweep(incoming, destination_address)
99
+ def create_payment_tx_from_sweep(incoming, destination_address, mpks)
95
100
 
96
101
  tx = Bitcoin::Protocol::Tx.new
97
102
  total_amount = 0
@@ -99,10 +104,12 @@ class OnChain::Sweeper
99
104
  incoming.each do |output|
100
105
 
101
106
  txin = Bitcoin::Protocol::TxIn.new
107
+
108
+ rs = generate_redemption_script_from_mpks(mpks, output[1])
102
109
 
103
110
  txin.prev_out = output[3].scan(/../).map { |x| x.hex }.pack('c*').reverse
104
111
  txin.prev_out_index = output[4]
105
- txin.script = Bitcoin::Script.binary_from_string(output[5])
112
+ txin.script = OnChain.hex_to_bin(rs)
106
113
 
107
114
  tx.add_in(txin)
108
115
 
@@ -110,7 +117,7 @@ class OnChain::Sweeper
110
117
 
111
118
  end
112
119
 
113
- total_amount = total_amount - 100000
120
+ total_amount = total_amount - 10000
114
121
 
115
122
  if total_amount < 0
116
123
  return "Not enough coins to create a transaction."
@@ -123,7 +130,9 @@ class OnChain::Sweeper
123
130
 
124
131
  tx.add_out(txout)
125
132
 
126
- return tx
133
+ paths = incoming.map { |i| i[1] }
134
+
135
+ return OnChain.bin_to_hex(tx.to_payload), paths
127
136
  end
128
137
 
129
138
  end
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.3.0
4
+ version: 1.3.2
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-21 00:00:00.000000000 Z
11
+ date: 2014-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake