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.
- checksums.yaml +4 -4
- data/lib/onchain/sweeper.rb +16 -7
- 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: c374489d69f07c18eedd7d3e2575c8eaa887d8e0
|
4
|
+
data.tar.gz: 48c3f1239dd7eeb28768aa63a78668dbb56f1561
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5977e86a3b52e628b42f59bac2638a251a44cbb7abffbd7409e3ada411db0eb89304a0e63f5d69604e7e6d7d298c88d6eccbe380527d810585c2b07abfd47cfa
|
7
|
+
data.tar.gz: c36abc4382cf2281461f33bfd04add32caba20ab4d8d4dd7003ce98d41722dda892cb4c2e018233aa976e04f5ebca7d180b1dbe781bc21de10a0f25faad2f24b
|
data/lib/onchain/sweeper.rb
CHANGED
@@ -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
|
-
|
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 =
|
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 -
|
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
|
-
|
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.
|
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-
|
11
|
+
date: 2014-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|