From 0aba8a687d710d11f216c415f7d75e8f1be99889 Mon Sep 17 00:00:00 2001 From: Julian Gonzalez Date: Fri, 5 Apr 2024 16:36:49 +0200 Subject: [PATCH] Add Koinos --- README.md | 1 + package.json | 1 + src/currencies.js | 5 +++++ test/wallet_address_validator.js | 24 ++++++++++++++++++++++++ 4 files changed, 31 insertions(+) diff --git a/README.md b/README.md index b498858b..060e5bab 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,7 @@ npm install multicoin-address-validator * Illuvium/ilv `'Illuvium'` or `'ilv'` * Immutable/imx `'Immutable'` or `'imx'` * Injective/inj `'Injective'` or `'inj'` +* Koinos/koin `'Koinos'` or `'koin'` * Komodo/kmd `'Komodo'` or `'kmd'` * LBRY Credits/lbc `'LBRY Credits'` or `'lbc'` * Lido DAO Token/ldo `'Lido DAO Token'` or `'ldo'` diff --git a/package.json b/package.json index 779c3e11..a18be0f7 100644 --- a/package.json +++ b/package.json @@ -74,6 +74,7 @@ "Illuvium","ilv", "Immutable","imx", "Injective","inj", + "Koinos","koin", "Komodo","kmd", "LBRY Credits","lbc", "Lido DAO Token","ldo", diff --git a/src/currencies.js b/src/currencies.js index 6f1d6489..7202576e 100644 --- a/src/currencies.js +++ b/src/currencies.js @@ -109,6 +109,11 @@ var CURRENCIES = [{ symbol: 'btg', addressTypes: { prod: ['26', '17'], testnet: ['6f', 'c4'] }, validator: BTCValidator + }, { + name: 'Koinos', + symbol: 'koin', + addressTypes: { prod: ['00'], testnet: ['00'] }, + validator: BTCValidator }, { name: 'Komodo', symbol: 'kmd', diff --git a/test/wallet_address_validator.js b/test/wallet_address_validator.js index 36924f67..db370017 100644 --- a/test/wallet_address_validator.js +++ b/test/wallet_address_validator.js @@ -445,6 +445,12 @@ describe('WAValidator.validate()', function () { valid('ztmWMDLWjbruCJxKmmfAZiT6QAQdiv5F291', 'zencash', 'testnet'); }); + it('should return true for correct koin addresses', function () { + valid('1Dq1YYNrC3yLEDax527yVhX8Y66xCoJ684', 'koinos'); + valid('1PRMZdT8me6eugZBpHihXYZKiHJMFUvpDh', 'KOIN'); + valid('1McpB177XmfVzyQSFfi8XKV5LCDrY4GUM8', 'koinos', 'testnet'); + }); + it('should return true for correct komodo addresses', function () { valid('R9R5HirAzqDcWrWGiJEL115dpV3QB3hobH', 'komodo'); valid('RAvj2KKVUohTu3hVdNJ4U6hQi7TNawpacH', 'KMD'); @@ -1095,6 +1101,15 @@ describe('WAValidator.validate()', function () { invalid('ztYWMDLWjbruCJxKmmfAZiT6QAQdiv5F291', 'zencash', 'testnet'); }); + it('should return false for incorrect koinos addresses', function () { + commonTests('koinos'); + // koinos only supports p2pkh. No p2sh or segwit + invalid('3FyVFsEyyBPzHjD3qUEgX7Jsn4tcHNZFkn', 'koinos'); + invalid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'KOIN'); + invalid('BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4', 'koinos'); + invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'koinos', 'testnet'); + }); + it('should return false for incorrect komodo addresses', function () { commonTests('komodo'); invalid('R9Y5HirAzqDcWrWGiJEL115dpV3QB3hobH', 'komodo'); @@ -1430,6 +1445,15 @@ describe('invalid results', function () { invalid('ztYWMDLWjbruCJxKmmfAZiT6QAQdiv5F291', 'zencash', 'testnet'); }); + it('should return false for incorrect koinos addresses', function () { + commonTests('koinos'); + // koinos only supports p2pkh. No p2sh or segwit + invalid('3FyVFsEyyBPzHjD3qUEgX7Jsn4tcHNZFkn', 'koinos'); + invalid('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'KOIN'); + invalid('BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4', 'koinos'); + invalid('t2YNzUUx8mWBCRYPRezvA363EYXyEpHokyi', 'koinos', 'testnet'); + }); + it('should return false for incorrect komodo addresses', function () { commonTests('komodo'); invalid('R9Y5HirAzqDcWrWGiJEL115dpV3QB3hobH', 'komodo');