Merge pull request #1627 from bitcoincoretech/issue_4d

Issue 4d
This commit is contained in:
Jonathan Underwood 2020-10-01 22:23:08 +09:00 committed by GitHub
commit 533d6c2e6d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 25 additions and 20 deletions

View file

@ -95,7 +95,8 @@ function p2sh(a, opts) {
});
lazy.prop(o, 'name', () => {
const nameParts = ['p2sh'];
if (o.redeem !== undefined) nameParts.push(o.redeem.name);
if (o.redeem !== undefined && o.redeem.name !== undefined)
nameParts.push(o.redeem.name);
return nameParts.join('-');
});
if (opts.validate) {

View file

@ -118,7 +118,8 @@ function p2wsh(a, opts) {
});
lazy.prop(o, 'name', () => {
const nameParts = ['p2wsh'];
if (o.redeem !== undefined) nameParts.push(o.redeem.name);
if (o.redeem !== undefined && o.redeem.name !== undefined)
nameParts.push(o.redeem.name);
return nameParts.join('-');
});
// extended validation

View file

@ -52,7 +52,7 @@
}
},
"expected": {
"name": "p2sh-p2pkh",
"name": "p2sh",
"address": "3GETYP4cuSesh2zsPEEYVZqnRedwe4FwUT",
"hash": "9f840a5fc02407ef0ad499c2ec0eb0b942fb0086",
"output": "OP_HASH160 9f840a5fc02407ef0ad499c2ec0eb0b942fb0086 OP_EQUAL",
@ -69,7 +69,7 @@
}
},
"expected": {
"name": "p2sh-p2wpkh",
"name": "p2sh",
"address": "325CuTNSYmvurXaBmhNFer5zDkKnDXZggu",
"hash": "0432515d8fe8de31be8207987fc6d67b29d5e7cc",
"output": "OP_HASH160 0432515d8fe8de31be8207987fc6d67b29d5e7cc OP_EQUAL",
@ -86,7 +86,7 @@
}
},
"expected": {
"name": "p2sh-p2pk",
"name": "p2sh",
"address": "36TibC8RrPB9WrBdPoGXhHqDHJosyFVtVQ",
"hash": "3454c084887afe854e80221c69d6282926f809c4",
"output": "OP_HASH160 3454c084887afe854e80221c69d6282926f809c4 OP_EQUAL",
@ -103,7 +103,7 @@
}
},
"expected": {
"name": "p2sh-p2pkh",
"name": "p2sh",
"address": "3GETYP4cuSesh2zsPEEYVZqnRedwe4FwUT",
"hash": "9f840a5fc02407ef0ad499c2ec0eb0b942fb0086",
"output": "OP_HASH160 9f840a5fc02407ef0ad499c2ec0eb0b942fb0086 OP_EQUAL",
@ -124,7 +124,7 @@
}
},
"expected": {
"name": "p2sh-p2wpkh",
"name": "p2sh",
"address": "325CuTNSYmvurXaBmhNFer5zDkKnDXZggu",
"hash": "0432515d8fe8de31be8207987fc6d67b29d5e7cc",
"output": "OP_HASH160 0432515d8fe8de31be8207987fc6d67b29d5e7cc OP_EQUAL",
@ -141,7 +141,7 @@
"input": "3045022100e4fce9ec72b609a2df1dc050c20dcf101d27faefb3e686b7a4cb067becdd5e8e022071287fced53806b08cf39b5ad58bbe614775b3776e98a9f8760af0d4d1d47a9501 2103e15819590382a9dd878f01e2f0cbce541564eb415e43b440472d883ecd283058ac"
},
"expected": {
"name": "p2sh-p2pk",
"name": "p2sh",
"address": "36TibC8RrPB9WrBdPoGXhHqDHJosyFVtVQ",
"hash": "3454c084887afe854e80221c69d6282926f809c4",
"output": "OP_HASH160 3454c084887afe854e80221c69d6282926f809c4 OP_EQUAL",
@ -163,7 +163,7 @@
]
},
"expected": {
"name": "p2sh-p2wpkh",
"name": "p2sh",
"address": "325CuTNSYmvurXaBmhNFer5zDkKnDXZggu",
"hash": "0432515d8fe8de31be8207987fc6d67b29d5e7cc",
"output": "OP_HASH160 0432515d8fe8de31be8207987fc6d67b29d5e7cc OP_EQUAL",
@ -187,7 +187,7 @@
}
},
"expected": {
"name": "p2sh-p2pkh",
"name": "p2sh",
"address": "2N7nfc7zeWuADtpdR4MrR7Wq3dzr7LxTCgS",
"hash": "9f840a5fc02407ef0ad499c2ec0eb0b942fb0086",
"output": "OP_HASH160 9f840a5fc02407ef0ad499c2ec0eb0b942fb0086 OP_EQUAL",

View file

@ -52,7 +52,7 @@
}
},
"expected": {
"name": "p2wsh-p2pkh",
"name": "p2wsh",
"address": "bc1qusxlgq9quu27ucxs7a2fg8nv0pycdzvxsjk9npyupupxw3y892ss2cq5ar",
"hash": "e40df400a0e715ee60d0f754941e6c784986898684ac59849c0f026744872aa1",
"output": "OP_0 e40df400a0e715ee60d0f754941e6c784986898684ac59849c0f026744872aa1",
@ -69,7 +69,7 @@
}
},
"expected": {
"name": "p2wsh-p2wpkh",
"name": "p2wsh",
"address": "bc1qpsl7el8wcx22f3fpdt3lm2wmzug7yyx2q3n8wzgtf37kps9tqy7skc7m3e",
"hash": "0c3fecfceec194a4c5216ae3fda9db1711e210ca046677090b4c7d60c0ab013d",
"output": "OP_0 0c3fecfceec194a4c5216ae3fda9db1711e210ca046677090b4c7d60c0ab013d",
@ -86,7 +86,7 @@
}
},
"expected": {
"name": "p2wsh-p2pk",
"name": "p2wsh",
"address": "bc1q6rgl33d3s9dugudw7n68yrryajkr3ha9q8q24j20zs62se4q9tsqdy0t2q",
"hash": "d0d1f8c5b1815bc471aef4f4720c64ecac38dfa501c0aac94f1434a866a02ae0",
"output": "OP_0 d0d1f8c5b1815bc471aef4f4720c64ecac38dfa501c0aac94f1434a866a02ae0",
@ -103,7 +103,7 @@
}
},
"expected": {
"name": "p2wsh-p2pkh",
"name": "p2wsh",
"address": "bc1qusxlgq9quu27ucxs7a2fg8nv0pycdzvxsjk9npyupupxw3y892ss2cq5ar",
"hash": "e40df400a0e715ee60d0f754941e6c784986898684ac59849c0f026744872aa1",
"output": "OP_0 e40df400a0e715ee60d0f754941e6c784986898684ac59849c0f026744872aa1",
@ -131,7 +131,7 @@
}
},
"expected": {
"name": "p2wsh-p2wpkh",
"name": "p2wsh",
"address": "bc1qpsl7el8wcx22f3fpdt3lm2wmzug7yyx2q3n8wzgtf37kps9tqy7skc7m3e",
"hash": "0c3fecfceec194a4c5216ae3fda9db1711e210ca046677090b4c7d60c0ab013d",
"output": "OP_0 0c3fecfceec194a4c5216ae3fda9db1711e210ca046677090b4c7d60c0ab013d",
@ -152,7 +152,7 @@
]
},
"expected": {
"name": "p2wsh-p2pk",
"name": "p2wsh",
"address": "bc1q6rgl33d3s9dugudw7n68yrryajkr3ha9q8q24j20zs62se4q9tsqdy0t2q",
"hash": "d0d1f8c5b1815bc471aef4f4720c64ecac38dfa501c0aac94f1434a866a02ae0",
"output": "OP_0 d0d1f8c5b1815bc471aef4f4720c64ecac38dfa501c0aac94f1434a866a02ae0",
@ -176,7 +176,7 @@
]
},
"expected": {
"name": "p2wsh-p2wpkh",
"name": "p2wsh",
"address": "bc1qpsl7el8wcx22f3fpdt3lm2wmzug7yyx2q3n8wzgtf37kps9tqy7skc7m3e",
"hash": "0c3fecfceec194a4c5216ae3fda9db1711e210ca046677090b4c7d60c0ab013d",
"output": "OP_0 0c3fecfceec194a4c5216ae3fda9db1711e210ca046677090b4c7d60c0ab013d",
@ -200,7 +200,7 @@
}
},
"expected": {
"name": "p2wsh-p2pkh",
"name": "p2wsh",
"address": "tb1qusxlgq9quu27ucxs7a2fg8nv0pycdzvxsjk9npyupupxw3y892ssaskm8v",
"hash": "e40df400a0e715ee60d0f754941e6c784986898684ac59849c0f026744872aa1",
"output": "OP_0 e40df400a0e715ee60d0f754941e6c784986898684ac59849c0f026744872aa1",

View file

@ -81,6 +81,7 @@ export function equate(a: any, b: any, args?: any): void {
if (b.signature === null) b.signature = undefined;
if (b.signatures === null) b.signatures = undefined;
if ('address' in b) t.strictEqual(a.address, b.address, 'Inequal *.address');
if ('name' in b) t.strictEqual(a.name, b.name, 'Inequal *.name');
if ('hash' in b)
t.strictEqual(tryHex(a.hash), tryHex(b.hash), 'Inequal *.hash');
if ('pubkey' in b)

View file

@ -118,7 +118,8 @@ export function p2sh(a: Payment, opts?: PaymentOpts): Payment {
});
lazy.prop(o, 'name', () => {
const nameParts = ['p2sh'];
if (o.redeem !== undefined) nameParts.push(o.redeem.name!);
if (o.redeem !== undefined && o.redeem.name !== undefined)
nameParts.push(o.redeem.name!);
return nameParts.join('-');
});

View file

@ -132,7 +132,8 @@ export function p2wsh(a: Payment, opts?: PaymentOpts): Payment {
});
lazy.prop(o, 'name', () => {
const nameParts = ['p2wsh'];
if (o.redeem !== undefined) nameParts.push(o.redeem.name!);
if (o.redeem !== undefined && o.redeem.name !== undefined)
nameParts.push(o.redeem.name!);
return nameParts.join('-');
});