Skip to content

Commit b7e144b

Browse files
committed
Add test cases to test new bitcoin-tx functionality
This commit add testcases to test the following functions in bitcoin-tx: - add a pay to non-standard script output - add a P2SH output - add a P2WSH output - add a P2WSH wrapped in a P2SH output - add a pay to pub key output - add a P2WPKH output - add a P2WPKH wrapped in a P2SH output - add a bare multisig output - add a multisig in P2SH output - add a multisig in a P2WSH output - add a multisig in a P2WSH wrapped in as P2SH output
1 parent 61a1534 commit b7e144b

23 files changed

+377
-0
lines changed

src/test/data/bitcoin-util-test.json

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,46 @@
117117
"output_cmp": "txcreate2.json",
118118
"description": "Parses a transation with no inputs and a single output script (output in json)"
119119
},
120+
{ "exec": "./bitcoin-tx",
121+
"args": ["-create", "outscript=0:OP_DROP"],
122+
"output_cmp": "txcreatescript1.hex",
123+
"description": "Create a new transaction with a single output script (OP_DROP)"
124+
},
125+
{ "exec": "./bitcoin-tx",
126+
"args": ["-json", "-create", "outscript=0:OP_DROP"],
127+
"output_cmp": "txcreatescript1.json",
128+
"description": "Create a new transaction with a single output script (OP_DROP) (output as json)"
129+
},
130+
{ "exec": "./bitcoin-tx",
131+
"args": ["-create", "outscript=0:OP_DROP:S"],
132+
"output_cmp": "txcreatescript2.hex",
133+
"description": "Create a new transaction with a single output script (OP_DROP) in a P2SH"
134+
},
135+
{ "exec": "./bitcoin-tx",
136+
"args": ["-json", "-create", "outscript=0:OP_DROP:S"],
137+
"output_cmp": "txcreatescript2.json",
138+
"description": "Create a new transaction with a single output script (OP_DROP) in a P2SH (output as json)"
139+
},
140+
{ "exec": "./bitcoin-tx",
141+
"args": ["-create", "outscript=0:OP_DROP:W"],
142+
"output_cmp": "txcreatescript3.hex",
143+
"description": "Create a new transaction with a single output script (OP_DROP) in a P2WSH"
144+
},
145+
{ "exec": "./bitcoin-tx",
146+
"args": ["-json", "-create", "outscript=0:OP_DROP:W"],
147+
"output_cmp": "txcreatescript3.json",
148+
"description": "Create a new transaction with a single output script (OP_DROP) in a P2WSH (output as json)"
149+
},
150+
{ "exec": "./bitcoin-tx",
151+
"args": ["-create", "outscript=0:OP_DROP:WS"],
152+
"output_cmp": "txcreatescript4.hex",
153+
"description": "Create a new transaction with a single output script (OP_DROP) in a P2WSH, wrapped in a P2SH"
154+
},
155+
{ "exec": "./bitcoin-tx",
156+
"args": ["-json", "-create", "outscript=0:OP_DROP:WS"],
157+
"output_cmp": "txcreatescript4.json",
158+
"description": "Create a new transaction with a single output script (OP_DROP) in a P2SH, wrapped in a P2SH (output as json)"
159+
},
120160
{ "exec": "./bitcoin-tx",
121161
"args":
122162
["-create", "nversion=1",
@@ -151,6 +191,42 @@
151191
"output_cmp": "txcreatesignv2.hex",
152192
"description": "Creates a new transaction with a single input and a single output, and then signs the transaction"
153193
},
194+
{ "exec": "./bitcoin-tx",
195+
"args":
196+
["-create", "outpubkey=0:02a5613bd857b7048924264d1e70e08fb2a7e6527d32b7ab1bb993ac59964ff397"],
197+
"output_cmp": "txcreateoutpubkey1.hex",
198+
"description": "Creates a new transaction with a single pay-to-pubkey output"
199+
},
200+
{ "exec": "./bitcoin-tx",
201+
"args":
202+
["-json", "-create", "outpubkey=0:02a5613bd857b7048924264d1e70e08fb2a7e6527d32b7ab1bb993ac59964ff397"],
203+
"output_cmp": "txcreateoutpubkey1.json",
204+
"description": "Creates a new transaction with a single pay-to-pubkey output (output as json)"
205+
},
206+
{ "exec": "./bitcoin-tx",
207+
"args":
208+
["-create", "outpubkey=0:02a5613bd857b7048924264d1e70e08fb2a7e6527d32b7ab1bb993ac59964ff397:W"],
209+
"output_cmp": "txcreateoutpubkey2.hex",
210+
"description": "Creates a new transaction with a single pay-to-witness-pubkey output"
211+
},
212+
{ "exec": "./bitcoin-tx",
213+
"args":
214+
["-json", "-create", "outpubkey=0:02a5613bd857b7048924264d1e70e08fb2a7e6527d32b7ab1bb993ac59964ff397:W"],
215+
"output_cmp": "txcreateoutpubkey2.json",
216+
"description": "Creates a new transaction with a single pay-to-witness-pubkey output (output as json)"
217+
},
218+
{ "exec": "./bitcoin-tx",
219+
"args":
220+
["-create", "outpubkey=0:02a5613bd857b7048924264d1e70e08fb2a7e6527d32b7ab1bb993ac59964ff397:WS"],
221+
"output_cmp": "txcreateoutpubkey3.hex",
222+
"description": "Creates a new transaction with a single pay-to-witness-pubkey, wrapped in P2SH output"
223+
},
224+
{ "exec": "./bitcoin-tx",
225+
"args":
226+
["-json", "-create", "outpubkey=0:02a5613bd857b7048924264d1e70e08fb2a7e6527d32b7ab1bb993ac59964ff397:WS"],
227+
"output_cmp": "txcreateoutpubkey3.json",
228+
"description": "Creates a new transaction with a single pay-to-pub-key output, wrapped in P2SH (output as json)"
229+
},
154230
{ "exec": "./bitcoin-tx",
155231
"args":
156232
["-create",
@@ -236,5 +312,45 @@
236312
"in=5897de6bd6027a475eadd57019d4e6872c396d0716c4875a5f1a6fcfdf385c1f:0:1"],
237313
"output_cmp": "txcreatedata_seq1.json",
238314
"description": "Adds a new input with sequence number to a transaction (output in json)"
315+
},
316+
{ "exec": "./bitcoin-tx",
317+
"args": ["-create", "outmultisig=1:2:3:02a5613bd857b7048924264d1e70e08fb2a7e6527d32b7ab1bb993ac59964ff397:021ac43c7ff740014c3b33737ede99c967e4764553d1b2b83db77c83b8715fa72d:02df2089105c77f266fa11a9d33f05c735234075f2e8780824c6b709415f9fb485"],
318+
"output_cmp": "txcreatemultisig1.hex",
319+
"description": "Creates a new transaction with a single 2-of-3 multisig output"
320+
},
321+
{ "exec": "./bitcoin-tx",
322+
"args": ["-json", "-create", "outmultisig=1:2:3:02a5613bd857b7048924264d1e70e08fb2a7e6527d32b7ab1bb993ac59964ff397:021ac43c7ff740014c3b33737ede99c967e4764553d1b2b83db77c83b8715fa72d:02df2089105c77f266fa11a9d33f05c735234075f2e8780824c6b709415f9fb485"],
323+
"output_cmp": "txcreatemultisig1.json",
324+
"description": "Creates a new transaction with a single 2-of-3 multisig output (output in json)"
325+
},
326+
{ "exec": "./bitcoin-tx",
327+
"args": ["-create", "outmultisig=1:2:3:02a5613bd857b7048924264d1e70e08fb2a7e6527d32b7ab1bb993ac59964ff397:021ac43c7ff740014c3b33737ede99c967e4764553d1b2b83db77c83b8715fa72d:02df2089105c77f266fa11a9d33f05c735234075f2e8780824c6b709415f9fb485:S"],
328+
"output_cmp": "txcreatemultisig2.hex",
329+
"description": "Creates a new transaction with a single 2-of-3 multisig in a P2SH output"
330+
},
331+
{ "exec": "./bitcoin-tx",
332+
"args": ["-json", "-create", "outmultisig=1:2:3:02a5613bd857b7048924264d1e70e08fb2a7e6527d32b7ab1bb993ac59964ff397:021ac43c7ff740014c3b33737ede99c967e4764553d1b2b83db77c83b8715fa72d:02df2089105c77f266fa11a9d33f05c735234075f2e8780824c6b709415f9fb485:S"],
333+
"output_cmp": "txcreatemultisig2.json",
334+
"description": "Creates a new transaction with a single 2-of-3 multisig in a P2SH output (output in json)"
335+
},
336+
{ "exec": "./bitcoin-tx",
337+
"args": ["-create", "outmultisig=1:2:3:02a5613bd857b7048924264d1e70e08fb2a7e6527d32b7ab1bb993ac59964ff397:021ac43c7ff740014c3b33737ede99c967e4764553d1b2b83db77c83b8715fa72d:02df2089105c77f266fa11a9d33f05c735234075f2e8780824c6b709415f9fb485:W"],
338+
"output_cmp": "txcreatemultisig3.hex",
339+
"description": "Creates a new transaction with a single 2-of-3 multisig in a P2WSH output"
340+
},
341+
{ "exec": "./bitcoin-tx",
342+
"args": ["-json", "-create", "outmultisig=1:2:3:02a5613bd857b7048924264d1e70e08fb2a7e6527d32b7ab1bb993ac59964ff397:021ac43c7ff740014c3b33737ede99c967e4764553d1b2b83db77c83b8715fa72d:02df2089105c77f266fa11a9d33f05c735234075f2e8780824c6b709415f9fb485:W"],
343+
"output_cmp": "txcreatemultisig3.json",
344+
"description": "Creates a new transaction with a single 2-of-3 multisig in a P2WSH output (output in json)"
345+
},
346+
{ "exec": "./bitcoin-tx",
347+
"args": ["-create", "outmultisig=1:2:3:02a5613bd857b7048924264d1e70e08fb2a7e6527d32b7ab1bb993ac59964ff397:021ac43c7ff740014c3b33737ede99c967e4764553d1b2b83db77c83b8715fa72d:02df2089105c77f266fa11a9d33f05c735234075f2e8780824c6b709415f9fb485:WS"],
348+
"output_cmp": "txcreatemultisig4.hex",
349+
"description": "Creates a new transaction with a single 2-of-3 multisig in a P2WSH output, wrapped in P2SH"
350+
},
351+
{ "exec": "./bitcoin-tx",
352+
"args": ["-json", "-create", "outmultisig=1:2:3:02a5613bd857b7048924264d1e70e08fb2a7e6527d32b7ab1bb993ac59964ff397:021ac43c7ff740014c3b33737ede99c967e4764553d1b2b83db77c83b8715fa72d:02df2089105c77f266fa11a9d33f05c735234075f2e8780824c6b709415f9fb485:WS"],
353+
"output_cmp": "txcreatemultisig4.json",
354+
"description": "Creates a new transaction with a single 2-of-3 multisig in a P2WSH output, wrapped in P2SH (output in json)"
239355
}
240356
]

src/test/data/txcreatemultisig1.hex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
01000000000100e1f5050000000069522102a5613bd857b7048924264d1e70e08fb2a7e6527d32b7ab1bb993ac59964ff39721021ac43c7ff740014c3b33737ede99c967e4764553d1b2b83db77c83b8715fa72d2102df2089105c77f266fa11a9d33f05c735234075f2e8780824c6b709415f9fb48553ae00000000

src/test/data/txcreatemultisig1.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"txid": "0d1d4edfc217d9db3ab6a9298f26a52eae3c52f55a6cb8ccbc14f7c727572894",
3+
"hash": "0d1d4edfc217d9db3ab6a9298f26a52eae3c52f55a6cb8ccbc14f7c727572894",
4+
"version": 1,
5+
"locktime": 0,
6+
"vin": [
7+
],
8+
"vout": [
9+
{
10+
"value": 1.00,
11+
"n": 0,
12+
"scriptPubKey": {
13+
"asm": "2 02a5613bd857b7048924264d1e70e08fb2a7e6527d32b7ab1bb993ac59964ff397 021ac43c7ff740014c3b33737ede99c967e4764553d1b2b83db77c83b8715fa72d 02df2089105c77f266fa11a9d33f05c735234075f2e8780824c6b709415f9fb485 3 OP_CHECKMULTISIG",
14+
"hex": "522102a5613bd857b7048924264d1e70e08fb2a7e6527d32b7ab1bb993ac59964ff39721021ac43c7ff740014c3b33737ede99c967e4764553d1b2b83db77c83b8715fa72d2102df2089105c77f266fa11a9d33f05c735234075f2e8780824c6b709415f9fb48553ae",
15+
"reqSigs": 2,
16+
"type": "multisig",
17+
"addresses": [
18+
"1FoG2386FG2tAJS9acMuiDsKy67aGg9MKz",
19+
"1FXtz9KU8JNmQDyHdiEm5HDiALuP3zdHvV",
20+
"14LuavcBbXZYJ6Tsz3cAUQj9SuQoL2xCQX"
21+
]
22+
}
23+
}
24+
],
25+
"hex": "01000000000100e1f5050000000069522102a5613bd857b7048924264d1e70e08fb2a7e6527d32b7ab1bb993ac59964ff39721021ac43c7ff740014c3b33737ede99c967e4764553d1b2b83db77c83b8715fa72d2102df2089105c77f266fa11a9d33f05c735234075f2e8780824c6b709415f9fb48553ae00000000"
26+
}

src/test/data/txcreatemultisig2.hex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
01000000000100e1f5050000000017a9141c6fbaf46d64221e80cbae182c33ddf81b9294ac8700000000

src/test/data/txcreatemultisig2.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"txid": "0d861f278a3b7bce7cb5a88d71e6e6a903336f95ad5a2c29b295b63835b6eee3",
3+
"hash": "0d861f278a3b7bce7cb5a88d71e6e6a903336f95ad5a2c29b295b63835b6eee3",
4+
"version": 1,
5+
"locktime": 0,
6+
"vin": [
7+
],
8+
"vout": [
9+
{
10+
"value": 1.00,
11+
"n": 0,
12+
"scriptPubKey": {
13+
"asm": "OP_HASH160 1c6fbaf46d64221e80cbae182c33ddf81b9294ac OP_EQUAL",
14+
"hex": "a9141c6fbaf46d64221e80cbae182c33ddf81b9294ac87",
15+
"reqSigs": 1,
16+
"type": "scripthash",
17+
"addresses": [
18+
"34HNh57oBCRKkxNyjTuWAJkTbuGh6jg2Ms"
19+
]
20+
}
21+
}
22+
],
23+
"hex": "01000000000100e1f5050000000017a9141c6fbaf46d64221e80cbae182c33ddf81b9294ac8700000000"
24+
}

src/test/data/txcreatemultisig3.hex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
01000000000100e1f50500000000220020e15a86a23178f433d514dbbce042e87d72662b8b5edcacfd2e37ab7a2d135f0500000000

src/test/data/txcreatemultisig3.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"txid": "ccc552220b46a3b5140048b03395987ce4f0fa1ddf8c635bba1fa44e0f8c1d7f",
3+
"hash": "ccc552220b46a3b5140048b03395987ce4f0fa1ddf8c635bba1fa44e0f8c1d7f",
4+
"version": 1,
5+
"locktime": 0,
6+
"vin": [
7+
],
8+
"vout": [
9+
{
10+
"value": 1.00,
11+
"n": 0,
12+
"scriptPubKey": {
13+
"asm": "0 e15a86a23178f433d514dbbce042e87d72662b8b5edcacfd2e37ab7a2d135f05",
14+
"hex": "0020e15a86a23178f433d514dbbce042e87d72662b8b5edcacfd2e37ab7a2d135f05",
15+
"type": "witness_v0_scripthash"
16+
}
17+
}
18+
],
19+
"hex": "01000000000100e1f50500000000220020e15a86a23178f433d514dbbce042e87d72662b8b5edcacfd2e37ab7a2d135f0500000000"
20+
}

src/test/data/txcreatemultisig4.hex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
01000000000100e1f5050000000017a9146edf12858999f0dae74f9c692e6694ee3621b2ac8700000000

src/test/data/txcreatemultisig4.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"txid": "5e8b1cc73234e208d4b7ca9075f136b908c34101be7a048df4ba9ac758b61567",
3+
"hash": "5e8b1cc73234e208d4b7ca9075f136b908c34101be7a048df4ba9ac758b61567",
4+
"version": 1,
5+
"locktime": 0,
6+
"vin": [
7+
],
8+
"vout": [
9+
{
10+
"value": 1.00,
11+
"n": 0,
12+
"scriptPubKey": {
13+
"asm": "OP_HASH160 6edf12858999f0dae74f9c692e6694ee3621b2ac OP_EQUAL",
14+
"hex": "a9146edf12858999f0dae74f9c692e6694ee3621b2ac87",
15+
"reqSigs": 1,
16+
"type": "scripthash",
17+
"addresses": [
18+
"3BoFUz1StqcNcgUTZE5cC1eFhuYFzj3fGH"
19+
]
20+
}
21+
}
22+
],
23+
"hex": "01000000000100e1f5050000000017a9146edf12858999f0dae74f9c692e6694ee3621b2ac8700000000"
24+
}

src/test/data/txcreateoutpubkey1.hex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0100000000010000000000000000232102a5613bd857b7048924264d1e70e08fb2a7e6527d32b7ab1bb993ac59964ff397ac00000000

0 commit comments

Comments
 (0)