commit
533d6c2e6d
7 changed files with 25 additions and 20 deletions
|
@ -95,7 +95,8 @@ function p2sh(a, opts) {
|
||||||
});
|
});
|
||||||
lazy.prop(o, 'name', () => {
|
lazy.prop(o, 'name', () => {
|
||||||
const nameParts = ['p2sh'];
|
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('-');
|
return nameParts.join('-');
|
||||||
});
|
});
|
||||||
if (opts.validate) {
|
if (opts.validate) {
|
||||||
|
|
|
@ -118,7 +118,8 @@ function p2wsh(a, opts) {
|
||||||
});
|
});
|
||||||
lazy.prop(o, 'name', () => {
|
lazy.prop(o, 'name', () => {
|
||||||
const nameParts = ['p2wsh'];
|
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('-');
|
return nameParts.join('-');
|
||||||
});
|
});
|
||||||
// extended validation
|
// extended validation
|
||||||
|
|
16
test/fixtures/p2sh.json
vendored
16
test/fixtures/p2sh.json
vendored
|
@ -52,7 +52,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"expected": {
|
"expected": {
|
||||||
"name": "p2sh-p2pkh",
|
"name": "p2sh",
|
||||||
"address": "3GETYP4cuSesh2zsPEEYVZqnRedwe4FwUT",
|
"address": "3GETYP4cuSesh2zsPEEYVZqnRedwe4FwUT",
|
||||||
"hash": "9f840a5fc02407ef0ad499c2ec0eb0b942fb0086",
|
"hash": "9f840a5fc02407ef0ad499c2ec0eb0b942fb0086",
|
||||||
"output": "OP_HASH160 9f840a5fc02407ef0ad499c2ec0eb0b942fb0086 OP_EQUAL",
|
"output": "OP_HASH160 9f840a5fc02407ef0ad499c2ec0eb0b942fb0086 OP_EQUAL",
|
||||||
|
@ -69,7 +69,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"expected": {
|
"expected": {
|
||||||
"name": "p2sh-p2wpkh",
|
"name": "p2sh",
|
||||||
"address": "325CuTNSYmvurXaBmhNFer5zDkKnDXZggu",
|
"address": "325CuTNSYmvurXaBmhNFer5zDkKnDXZggu",
|
||||||
"hash": "0432515d8fe8de31be8207987fc6d67b29d5e7cc",
|
"hash": "0432515d8fe8de31be8207987fc6d67b29d5e7cc",
|
||||||
"output": "OP_HASH160 0432515d8fe8de31be8207987fc6d67b29d5e7cc OP_EQUAL",
|
"output": "OP_HASH160 0432515d8fe8de31be8207987fc6d67b29d5e7cc OP_EQUAL",
|
||||||
|
@ -86,7 +86,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"expected": {
|
"expected": {
|
||||||
"name": "p2sh-p2pk",
|
"name": "p2sh",
|
||||||
"address": "36TibC8RrPB9WrBdPoGXhHqDHJosyFVtVQ",
|
"address": "36TibC8RrPB9WrBdPoGXhHqDHJosyFVtVQ",
|
||||||
"hash": "3454c084887afe854e80221c69d6282926f809c4",
|
"hash": "3454c084887afe854e80221c69d6282926f809c4",
|
||||||
"output": "OP_HASH160 3454c084887afe854e80221c69d6282926f809c4 OP_EQUAL",
|
"output": "OP_HASH160 3454c084887afe854e80221c69d6282926f809c4 OP_EQUAL",
|
||||||
|
@ -103,7 +103,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"expected": {
|
"expected": {
|
||||||
"name": "p2sh-p2pkh",
|
"name": "p2sh",
|
||||||
"address": "3GETYP4cuSesh2zsPEEYVZqnRedwe4FwUT",
|
"address": "3GETYP4cuSesh2zsPEEYVZqnRedwe4FwUT",
|
||||||
"hash": "9f840a5fc02407ef0ad499c2ec0eb0b942fb0086",
|
"hash": "9f840a5fc02407ef0ad499c2ec0eb0b942fb0086",
|
||||||
"output": "OP_HASH160 9f840a5fc02407ef0ad499c2ec0eb0b942fb0086 OP_EQUAL",
|
"output": "OP_HASH160 9f840a5fc02407ef0ad499c2ec0eb0b942fb0086 OP_EQUAL",
|
||||||
|
@ -124,7 +124,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"expected": {
|
"expected": {
|
||||||
"name": "p2sh-p2wpkh",
|
"name": "p2sh",
|
||||||
"address": "325CuTNSYmvurXaBmhNFer5zDkKnDXZggu",
|
"address": "325CuTNSYmvurXaBmhNFer5zDkKnDXZggu",
|
||||||
"hash": "0432515d8fe8de31be8207987fc6d67b29d5e7cc",
|
"hash": "0432515d8fe8de31be8207987fc6d67b29d5e7cc",
|
||||||
"output": "OP_HASH160 0432515d8fe8de31be8207987fc6d67b29d5e7cc OP_EQUAL",
|
"output": "OP_HASH160 0432515d8fe8de31be8207987fc6d67b29d5e7cc OP_EQUAL",
|
||||||
|
@ -141,7 +141,7 @@
|
||||||
"input": "3045022100e4fce9ec72b609a2df1dc050c20dcf101d27faefb3e686b7a4cb067becdd5e8e022071287fced53806b08cf39b5ad58bbe614775b3776e98a9f8760af0d4d1d47a9501 2103e15819590382a9dd878f01e2f0cbce541564eb415e43b440472d883ecd283058ac"
|
"input": "3045022100e4fce9ec72b609a2df1dc050c20dcf101d27faefb3e686b7a4cb067becdd5e8e022071287fced53806b08cf39b5ad58bbe614775b3776e98a9f8760af0d4d1d47a9501 2103e15819590382a9dd878f01e2f0cbce541564eb415e43b440472d883ecd283058ac"
|
||||||
},
|
},
|
||||||
"expected": {
|
"expected": {
|
||||||
"name": "p2sh-p2pk",
|
"name": "p2sh",
|
||||||
"address": "36TibC8RrPB9WrBdPoGXhHqDHJosyFVtVQ",
|
"address": "36TibC8RrPB9WrBdPoGXhHqDHJosyFVtVQ",
|
||||||
"hash": "3454c084887afe854e80221c69d6282926f809c4",
|
"hash": "3454c084887afe854e80221c69d6282926f809c4",
|
||||||
"output": "OP_HASH160 3454c084887afe854e80221c69d6282926f809c4 OP_EQUAL",
|
"output": "OP_HASH160 3454c084887afe854e80221c69d6282926f809c4 OP_EQUAL",
|
||||||
|
@ -163,7 +163,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"expected": {
|
"expected": {
|
||||||
"name": "p2sh-p2wpkh",
|
"name": "p2sh",
|
||||||
"address": "325CuTNSYmvurXaBmhNFer5zDkKnDXZggu",
|
"address": "325CuTNSYmvurXaBmhNFer5zDkKnDXZggu",
|
||||||
"hash": "0432515d8fe8de31be8207987fc6d67b29d5e7cc",
|
"hash": "0432515d8fe8de31be8207987fc6d67b29d5e7cc",
|
||||||
"output": "OP_HASH160 0432515d8fe8de31be8207987fc6d67b29d5e7cc OP_EQUAL",
|
"output": "OP_HASH160 0432515d8fe8de31be8207987fc6d67b29d5e7cc OP_EQUAL",
|
||||||
|
@ -187,7 +187,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"expected": {
|
"expected": {
|
||||||
"name": "p2sh-p2pkh",
|
"name": "p2sh",
|
||||||
"address": "2N7nfc7zeWuADtpdR4MrR7Wq3dzr7LxTCgS",
|
"address": "2N7nfc7zeWuADtpdR4MrR7Wq3dzr7LxTCgS",
|
||||||
"hash": "9f840a5fc02407ef0ad499c2ec0eb0b942fb0086",
|
"hash": "9f840a5fc02407ef0ad499c2ec0eb0b942fb0086",
|
||||||
"output": "OP_HASH160 9f840a5fc02407ef0ad499c2ec0eb0b942fb0086 OP_EQUAL",
|
"output": "OP_HASH160 9f840a5fc02407ef0ad499c2ec0eb0b942fb0086 OP_EQUAL",
|
||||||
|
|
16
test/fixtures/p2wsh.json
vendored
16
test/fixtures/p2wsh.json
vendored
|
@ -52,7 +52,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"expected": {
|
"expected": {
|
||||||
"name": "p2wsh-p2pkh",
|
"name": "p2wsh",
|
||||||
"address": "bc1qusxlgq9quu27ucxs7a2fg8nv0pycdzvxsjk9npyupupxw3y892ss2cq5ar",
|
"address": "bc1qusxlgq9quu27ucxs7a2fg8nv0pycdzvxsjk9npyupupxw3y892ss2cq5ar",
|
||||||
"hash": "e40df400a0e715ee60d0f754941e6c784986898684ac59849c0f026744872aa1",
|
"hash": "e40df400a0e715ee60d0f754941e6c784986898684ac59849c0f026744872aa1",
|
||||||
"output": "OP_0 e40df400a0e715ee60d0f754941e6c784986898684ac59849c0f026744872aa1",
|
"output": "OP_0 e40df400a0e715ee60d0f754941e6c784986898684ac59849c0f026744872aa1",
|
||||||
|
@ -69,7 +69,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"expected": {
|
"expected": {
|
||||||
"name": "p2wsh-p2wpkh",
|
"name": "p2wsh",
|
||||||
"address": "bc1qpsl7el8wcx22f3fpdt3lm2wmzug7yyx2q3n8wzgtf37kps9tqy7skc7m3e",
|
"address": "bc1qpsl7el8wcx22f3fpdt3lm2wmzug7yyx2q3n8wzgtf37kps9tqy7skc7m3e",
|
||||||
"hash": "0c3fecfceec194a4c5216ae3fda9db1711e210ca046677090b4c7d60c0ab013d",
|
"hash": "0c3fecfceec194a4c5216ae3fda9db1711e210ca046677090b4c7d60c0ab013d",
|
||||||
"output": "OP_0 0c3fecfceec194a4c5216ae3fda9db1711e210ca046677090b4c7d60c0ab013d",
|
"output": "OP_0 0c3fecfceec194a4c5216ae3fda9db1711e210ca046677090b4c7d60c0ab013d",
|
||||||
|
@ -86,7 +86,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"expected": {
|
"expected": {
|
||||||
"name": "p2wsh-p2pk",
|
"name": "p2wsh",
|
||||||
"address": "bc1q6rgl33d3s9dugudw7n68yrryajkr3ha9q8q24j20zs62se4q9tsqdy0t2q",
|
"address": "bc1q6rgl33d3s9dugudw7n68yrryajkr3ha9q8q24j20zs62se4q9tsqdy0t2q",
|
||||||
"hash": "d0d1f8c5b1815bc471aef4f4720c64ecac38dfa501c0aac94f1434a866a02ae0",
|
"hash": "d0d1f8c5b1815bc471aef4f4720c64ecac38dfa501c0aac94f1434a866a02ae0",
|
||||||
"output": "OP_0 d0d1f8c5b1815bc471aef4f4720c64ecac38dfa501c0aac94f1434a866a02ae0",
|
"output": "OP_0 d0d1f8c5b1815bc471aef4f4720c64ecac38dfa501c0aac94f1434a866a02ae0",
|
||||||
|
@ -103,7 +103,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"expected": {
|
"expected": {
|
||||||
"name": "p2wsh-p2pkh",
|
"name": "p2wsh",
|
||||||
"address": "bc1qusxlgq9quu27ucxs7a2fg8nv0pycdzvxsjk9npyupupxw3y892ss2cq5ar",
|
"address": "bc1qusxlgq9quu27ucxs7a2fg8nv0pycdzvxsjk9npyupupxw3y892ss2cq5ar",
|
||||||
"hash": "e40df400a0e715ee60d0f754941e6c784986898684ac59849c0f026744872aa1",
|
"hash": "e40df400a0e715ee60d0f754941e6c784986898684ac59849c0f026744872aa1",
|
||||||
"output": "OP_0 e40df400a0e715ee60d0f754941e6c784986898684ac59849c0f026744872aa1",
|
"output": "OP_0 e40df400a0e715ee60d0f754941e6c784986898684ac59849c0f026744872aa1",
|
||||||
|
@ -131,7 +131,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"expected": {
|
"expected": {
|
||||||
"name": "p2wsh-p2wpkh",
|
"name": "p2wsh",
|
||||||
"address": "bc1qpsl7el8wcx22f3fpdt3lm2wmzug7yyx2q3n8wzgtf37kps9tqy7skc7m3e",
|
"address": "bc1qpsl7el8wcx22f3fpdt3lm2wmzug7yyx2q3n8wzgtf37kps9tqy7skc7m3e",
|
||||||
"hash": "0c3fecfceec194a4c5216ae3fda9db1711e210ca046677090b4c7d60c0ab013d",
|
"hash": "0c3fecfceec194a4c5216ae3fda9db1711e210ca046677090b4c7d60c0ab013d",
|
||||||
"output": "OP_0 0c3fecfceec194a4c5216ae3fda9db1711e210ca046677090b4c7d60c0ab013d",
|
"output": "OP_0 0c3fecfceec194a4c5216ae3fda9db1711e210ca046677090b4c7d60c0ab013d",
|
||||||
|
@ -152,7 +152,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"expected": {
|
"expected": {
|
||||||
"name": "p2wsh-p2pk",
|
"name": "p2wsh",
|
||||||
"address": "bc1q6rgl33d3s9dugudw7n68yrryajkr3ha9q8q24j20zs62se4q9tsqdy0t2q",
|
"address": "bc1q6rgl33d3s9dugudw7n68yrryajkr3ha9q8q24j20zs62se4q9tsqdy0t2q",
|
||||||
"hash": "d0d1f8c5b1815bc471aef4f4720c64ecac38dfa501c0aac94f1434a866a02ae0",
|
"hash": "d0d1f8c5b1815bc471aef4f4720c64ecac38dfa501c0aac94f1434a866a02ae0",
|
||||||
"output": "OP_0 d0d1f8c5b1815bc471aef4f4720c64ecac38dfa501c0aac94f1434a866a02ae0",
|
"output": "OP_0 d0d1f8c5b1815bc471aef4f4720c64ecac38dfa501c0aac94f1434a866a02ae0",
|
||||||
|
@ -176,7 +176,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"expected": {
|
"expected": {
|
||||||
"name": "p2wsh-p2wpkh",
|
"name": "p2wsh",
|
||||||
"address": "bc1qpsl7el8wcx22f3fpdt3lm2wmzug7yyx2q3n8wzgtf37kps9tqy7skc7m3e",
|
"address": "bc1qpsl7el8wcx22f3fpdt3lm2wmzug7yyx2q3n8wzgtf37kps9tqy7skc7m3e",
|
||||||
"hash": "0c3fecfceec194a4c5216ae3fda9db1711e210ca046677090b4c7d60c0ab013d",
|
"hash": "0c3fecfceec194a4c5216ae3fda9db1711e210ca046677090b4c7d60c0ab013d",
|
||||||
"output": "OP_0 0c3fecfceec194a4c5216ae3fda9db1711e210ca046677090b4c7d60c0ab013d",
|
"output": "OP_0 0c3fecfceec194a4c5216ae3fda9db1711e210ca046677090b4c7d60c0ab013d",
|
||||||
|
@ -200,7 +200,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"expected": {
|
"expected": {
|
||||||
"name": "p2wsh-p2pkh",
|
"name": "p2wsh",
|
||||||
"address": "tb1qusxlgq9quu27ucxs7a2fg8nv0pycdzvxsjk9npyupupxw3y892ssaskm8v",
|
"address": "tb1qusxlgq9quu27ucxs7a2fg8nv0pycdzvxsjk9npyupupxw3y892ssaskm8v",
|
||||||
"hash": "e40df400a0e715ee60d0f754941e6c784986898684ac59849c0f026744872aa1",
|
"hash": "e40df400a0e715ee60d0f754941e6c784986898684ac59849c0f026744872aa1",
|
||||||
"output": "OP_0 e40df400a0e715ee60d0f754941e6c784986898684ac59849c0f026744872aa1",
|
"output": "OP_0 e40df400a0e715ee60d0f754941e6c784986898684ac59849c0f026744872aa1",
|
||||||
|
|
|
@ -81,6 +81,7 @@ export function equate(a: any, b: any, args?: any): void {
|
||||||
if (b.signature === null) b.signature = undefined;
|
if (b.signature === null) b.signature = undefined;
|
||||||
if (b.signatures === null) b.signatures = undefined;
|
if (b.signatures === null) b.signatures = undefined;
|
||||||
if ('address' in b) t.strictEqual(a.address, b.address, 'Inequal *.address');
|
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)
|
if ('hash' in b)
|
||||||
t.strictEqual(tryHex(a.hash), tryHex(b.hash), 'Inequal *.hash');
|
t.strictEqual(tryHex(a.hash), tryHex(b.hash), 'Inequal *.hash');
|
||||||
if ('pubkey' in b)
|
if ('pubkey' in b)
|
||||||
|
|
|
@ -118,7 +118,8 @@ export function p2sh(a: Payment, opts?: PaymentOpts): Payment {
|
||||||
});
|
});
|
||||||
lazy.prop(o, 'name', () => {
|
lazy.prop(o, 'name', () => {
|
||||||
const nameParts = ['p2sh'];
|
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('-');
|
return nameParts.join('-');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -132,7 +132,8 @@ export function p2wsh(a: Payment, opts?: PaymentOpts): Payment {
|
||||||
});
|
});
|
||||||
lazy.prop(o, 'name', () => {
|
lazy.prop(o, 'name', () => {
|
||||||
const nameParts = ['p2wsh'];
|
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('-');
|
return nameParts.join('-');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue