Added support for public key -> P2TR addresses. Also renamed Public Key to Cryptocurrency Address Operation to Public Key to Bitcoin-Like Address Operation.

This commit is contained in:
David C Goldenberg 2025-05-09 14:34:57 -04:00
parent d745a516cb
commit 5605807778
4 changed files with 155 additions and 48 deletions

View file

@ -1,5 +1,5 @@
/**
* Public Key to cryptocurrency address tests.
* Public Key To Bitcoin-Like Address tests.
*
* @author dgoldenberg [virtualcurrency@mitre.org]
* @copyright MITRE 2023
@ -16,7 +16,7 @@ TestRegister.addTests([
expectedOutput: "1MwwHqDj1FAyABeqPeiTTvJQCoCorcuFyP",
recipeConfig: [
{
"op": "Public Key To Cryptocurrency Address",
"op": "Public Key To Bitcoin-Like Address",
"args": ["BTC", "P2PKH (V1 BTC Addresses)"]
},
],
@ -27,7 +27,7 @@ TestRegister.addTests([
expectedOutput: "18wUwr4Jvor6LG1mvQcfEp1Lx51dYAXZX1",
recipeConfig: [
{
"op": "Public Key To Cryptocurrency Address",
"op": "Public Key To Bitcoin-Like Address",
"args": ["BTC", "P2PKH (V1 BTC Addresses)"]
},
],
@ -38,7 +38,7 @@ TestRegister.addTests([
expectedOutput: "LPTR2TBuF8vbwWaJdNeCAQemW4SC7q7zJP",
recipeConfig: [
{
"op": "Public Key To Cryptocurrency Address",
"op": "Public Key To Bitcoin-Like Address",
"args": ["LTC", "P2PKH (V1 BTC Addresses)"]
},
],
@ -49,7 +49,7 @@ TestRegister.addTests([
expectedOutput: "1BgRqTW8RMmcTRXHymTCVJsn5NVk9U8L9q",
recipeConfig: [
{
"op": "Public Key To Cryptocurrency Address",
"op": "Public Key To Bitcoin-Like Address",
"args": ["BTC", "P2PKH (V1 BTC Addresses)"]
},
],
@ -60,7 +60,7 @@ TestRegister.addTests([
expectedOutput: "31vhdy8RGhSYZRRGZfqvZHGzVtpcua4cQW",
recipeConfig: [
{
"op": "Public Key To Cryptocurrency Address",
"op": "Public Key To Bitcoin-Like Address",
"args": ["BTC", "P2SH-P2PWPKH (Segwit Compatible V3 Addresses)"]
},
],
@ -71,7 +71,7 @@ TestRegister.addTests([
expectedOutput: "3C9wCFwcd36MHVpontDF7zQfKPfRTNg4Fe",
recipeConfig: [
{
"op": "Public Key To Cryptocurrency Address",
"op": "Public Key To Bitcoin-Like Address",
"args": ["BTC", "P2SH-P2PWPKH (Segwit Compatible V3 Addresses)"]
},
],
@ -82,7 +82,7 @@ TestRegister.addTests([
expectedOutput: "MMwYiJmkxDKqiP2WWAHMMgkeRt2nLxGqih",
recipeConfig: [
{
"op": "Public Key To Cryptocurrency Address",
"op": "Public Key To Bitcoin-Like Address",
"args": ["LTC", "P2SH-P2PWPKH (Segwit Compatible V3 Addresses)"]
},
],
@ -93,7 +93,7 @@ TestRegister.addTests([
expectedOutput: "bc1qu37uvwyzj23a2dd3x5nd8s77nfskzu3lzkuqfm",
recipeConfig: [
{
"op": "Public Key To Cryptocurrency Address",
"op": "Public Key To Bitcoin-Like Address",
"args": ["BTC", "Segwit (P2WPKH bc1 Addresses)"]
},
],
@ -104,7 +104,7 @@ TestRegister.addTests([
expectedOutput: "bc1qrjluhfu5qr2780zlvcx3kquckpvuamwqp2sjle",
recipeConfig: [
{
"op": "Public Key To Cryptocurrency Address",
"op": "Public Key To Bitcoin-Like Address",
"args": ["BTC", "Segwit (P2WPKH bc1 Addresses)"]
},
],
@ -115,7 +115,7 @@ TestRegister.addTests([
expectedOutput: "ltc1qj587punda8h0r4m83k794xseqlnl3az4ktu2zp",
recipeConfig: [
{
"op": "Public Key To Cryptocurrency Address",
"op": "Public Key To Bitcoin-Like Address",
"args": ["LTC", "Segwit (P2WPKH bc1 Addresses)"]
},
],
@ -126,7 +126,7 @@ TestRegister.addTests([
expectedOutput: "mmuoeJDuuzeuaii1V6tPK3L5YjaJwjPqUM",
recipeConfig: [
{
"op": "Public Key To Cryptocurrency Address",
"op": "Public Key To Bitcoin-Like Address",
"args": ["Testnet", "P2PKH (V1 BTC Addresses)"]
},
],
@ -138,7 +138,7 @@ TestRegister.addTests([
expectedOutput: "Invalid length. We want either 33, 65 (if bytes) or 66, 130 (if hex) but we got: 68",
recipeConfig: [
{
"op": "Public Key To Cryptocurrency Address",
"op": "Public Key To Bitcoin-Like Address",
"args": ["BTC", "Segwit (P2WPKH bc1 Addresses)"]
},
],
@ -149,7 +149,7 @@ TestRegister.addTests([
expectedOutput: "We have a valid hex string, of reasonable length, (66) but doesn't start with the right value. Correct values are 02, or 03 but we have: 05",
recipeConfig: [
{
"op": "Public Key To Cryptocurrency Address",
"op": "Public Key To Bitcoin-Like Address",
"args": ["BTC", "Segwit (P2WPKH bc1 Addresses)"]
},
],
@ -160,7 +160,7 @@ TestRegister.addTests([
expectedOutput: "We have a valid hex string of reasonable length, (130) but doesn't start with the right value. Correct values are 04 but we have: 06",
recipeConfig: [
{
"op": "Public Key To Cryptocurrency Address",
"op": "Public Key To Bitcoin-Like Address",
"args": ["BTC", "P2PKH (V1 BTC Addresses)"]
},
],
@ -175,9 +175,28 @@ TestRegister.addTests([
"args": ["Auto"]
},
{
"op": "Public Key To Cryptocurrency Address",
"op": "Public Key To Bitcoin-Like Address",
"args": ["BTC", "P2PKH (V1 BTC Addresses)"]
}
],
},
{
name: "Public Key To Address: P2TR (From WIF Key)",
input: "L5R7GAGwrBLcpK4jK1CLDL7VjPifYZZeS1NcixKvrPxXySJWEK9h",
expectedOutput: "bc1ph6py5lduje5urxkqewpaxj8cxlmmc9uxr386e0jgvp9vzsup54dqxpxsn7",
recipeConfig: [
{
"op": "From WIF Format",
"args": []
},
{
"op": "Private EC Key to Public Key",
"args": [true]
},
{
"op": "Public Key To Bitcoin-Like Address",
"args": ["BTC", "Taproot (P2TR bc1p Addresses)"]
}
]
},
]);