onchain 1.0.8 → 1.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/onchain/payments.rb +7 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 429a0f9abce6c457a94880105930acd85f3cc951
|
4
|
+
data.tar.gz: 1e703f989156b93816b8f50e320ddcf7578b47c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5357381557a5d0f4fddc909ea61f1122abec7bfde506a39a0b4a6dd02cd122ad38cd6a6a798652052d4af32c076b5f0c9c512013fcce713ec0d8f2f4ee5533fe
|
7
|
+
data.tar.gz: 929bb1c704c84282d559fcc2efe0085db922cfdcc83551ab4f085729415cdc3ea4a61dbecfec122c3aeca7756d21d646af8d29642fa05ed19ea766b9c30b4a01
|
data/lib/onchain/payments.rb
CHANGED
@@ -3,13 +3,18 @@ class OnChain
|
|
3
3
|
|
4
4
|
def get_address_from_redemption_script(redemption_script)
|
5
5
|
|
6
|
-
sbin =
|
6
|
+
sbin = redemption_script.scan(/../).map { |x| x.hex }.pack('c*')
|
7
7
|
hex = sbin.unpack("H*")[0]
|
8
8
|
fund_address = Bitcoin.hash160_to_p2sh_address(Bitcoin.hash160(hex))
|
9
9
|
|
10
10
|
return fund_address
|
11
11
|
end
|
12
12
|
|
13
|
+
def hex_to_script(hex)
|
14
|
+
sbin = hex.scan(/../).map { |x| x.hex }.pack('c*')
|
15
|
+
return Bitcoin::Script.new(sbin)
|
16
|
+
end
|
17
|
+
|
13
18
|
# With a bunch of HD wallet paths, build a transaction
|
14
19
|
# That pays all the coins to a certain address
|
15
20
|
def create_payment_tx(redemption_script, payments)
|
@@ -45,6 +50,7 @@ class OnChain
|
|
45
50
|
|
46
51
|
txin.prev_out = spent[0]
|
47
52
|
txin.prev_out_index = spent[1]
|
53
|
+
txin.script = hex_to_script(redemption_script).to_payload
|
48
54
|
|
49
55
|
tx.add_in(txin)
|
50
56
|
|