From e56140ca416a8c0fb364321c80b89c0a2386257f Mon Sep 17 00:00:00 2001 From: samooth Date: Sun, 30 Mar 2025 00:24:19 +0100 Subject: [PATCH 1/4] added GroestlCoin ($GRS) --- packages/docs/index.md | 2 +- packages/nakamotojs/src/networks.d.ts | 3 + packages/nakamotojs/src/networks.js | 48 +++++++++++ packages/nakamotojs/ts_src/networks.ts | 47 ++++++++++ .../node/chain-setup/GRS/mainnet/.env.example | 85 ++++++++++++++++++ .../GRS/mainnet/groestlcoin.conf.example | 27 ++++++ .../node/chain-setup/GRS/regtest/.env.example | 86 +++++++++++++++++++ .../GRS/regtest/groestlcoin.conf.example | 17 ++++ .../node/chain-setup/GRS/testnet/.env.example | 86 +++++++++++++++++++ .../GRS/testnet/groestlcoin.conf.example | 31 +++++++ packages/node/package.json | 1 + 11 files changed, 432 insertions(+), 1 deletion(-) create mode 100644 packages/node/chain-setup/GRS/mainnet/.env.example create mode 100644 packages/node/chain-setup/GRS/mainnet/groestlcoin.conf.example create mode 100644 packages/node/chain-setup/GRS/regtest/.env.example create mode 100644 packages/node/chain-setup/GRS/regtest/groestlcoin.conf.example create mode 100644 packages/node/chain-setup/GRS/testnet/.env.example create mode 100644 packages/node/chain-setup/GRS/testnet/groestlcoin.conf.example diff --git a/packages/docs/index.md b/packages/docs/index.md index efe43a70a..94a41bf29 100644 --- a/packages/docs/index.md +++ b/packages/docs/index.md @@ -12,7 +12,7 @@ _The Bitcoin Computer is a protocol for building applications that are as secure **Free Computation** - Smart contracts are executed on the client. Execution costs are fixed and independent of the number of computational steps. -**Multicoin**. Deploy on Bitcoin, Litecoin, Dogecoin, and Pepecoin (Bitcoin Cash coming soon) using the same code. +**Multicoin**. Deploy on Bitcoin, Litecoin, Dogecoin, Pepecoin and Groestlcoin (Bitcoin Cash coming soon) using the same code. **JavaScript & Typescript** - Build decentralized applications that integrate seamlessly into web applications using your favorite tools and execute on high performance JavaScript engines. diff --git a/packages/nakamotojs/src/networks.d.ts b/packages/nakamotojs/src/networks.d.ts index 808619a57..61b9663a7 100644 --- a/packages/nakamotojs/src/networks.d.ts +++ b/packages/nakamotojs/src/networks.d.ts @@ -19,6 +19,9 @@ export declare const litecointestnet: Network; export declare const pepecoin: Network; export declare const pepecoinregtest: Network; export declare const pepecointestnet: Network; +export declare const groestlcoin: Network; +export declare const groestlcoinregtest: Network; +export declare const groestlcointestnet: Network; export declare const dogecoin: Network; export declare const dogecoinregtest: Network; export declare const dogecointestnet: Network; diff --git a/packages/nakamotojs/src/networks.js b/packages/nakamotojs/src/networks.js index 459c10d6a..2aeff0eba 100644 --- a/packages/nakamotojs/src/networks.js +++ b/packages/nakamotojs/src/networks.js @@ -97,6 +97,39 @@ export const pepecointestnet = { scriptHash: 0xc4, wif: 0xf1, }; +export const groestlcoin = { + messagePrefix: '\x1cGroestlCoin Signed Message:\n', + bech32: 'grs', + bip32: { + public: 0x0488b21e, + private: 0x0488ade4, + }, + pubKeyHash: 0x24, + scriptHash: 0x05, + wif: 0x80, +}; +export const groestlcoinregtest = { + messagePrefix: '\x1cGroestlCoin Signed Message:\n', + bech32: 'grsrt', + bip32: { + public: 0x043587cf, + private: 0x04358394, + }, + pubKeyHash: 0x6f, + scriptHash: 0xc4, + wif: 0xef, +}; +export const groestlcointestnet = { + messagePrefix: '\x1cGroestlCoin Signed Message:\n', + bech32: 'tgrs', + bip32: { + public: 0x043587cf, + private: 0x04358394, + }, + pubKeyHash: 0x71, + scriptHash: 0xc4, + wif: 0xef, +}; export const dogecoin = { messagePrefix: '\x19Dogecoin Signed Message:\n', bech32: 'doge', // TODO: Dogecoin doesn't use bech32, make type optional @@ -176,6 +209,17 @@ export function getNetwork(chain, network) { default: throw new Error(`Invalid network ${network}`); } + case 'GRS': + switch (network) { + case 'mainnet': + return groestlcoin; + case 'testnet': + return groestlcointestnet; + case 'regtest': + return groestlcoinregtest; + default: + throw new Error(`Invalid network ${network}`); + } default: throw new Error(`Invalid chain ${network}`); } @@ -197,4 +241,8 @@ export const NETWORKS = { dogecoin, dogecoinregtest, dogecointestnet, + // Groestlcoin + groestlcoin, + groestlcoinregtest, + groestlcointestnet, }; diff --git a/packages/nakamotojs/ts_src/networks.ts b/packages/nakamotojs/ts_src/networks.ts index 10c267d3c..49baa08c5 100644 --- a/packages/nakamotojs/ts_src/networks.ts +++ b/packages/nakamotojs/ts_src/networks.ts @@ -122,6 +122,42 @@ export const pepecointestnet: Network = { wif: 0xf1, }; +export const groestlcoin: Network = { + messagePrefix: '\x1cGroestlCoin Signed Message:\n', + bech32: 'grs', + bip32: { + public: 0x0488b21e, + private: 0x0488ade4, + }, + pubKeyHash: 0x24, + scriptHash: 0x05, + wif: 0x80, +}; + +export const groestlcoinregtest: Network = { + messagePrefix: '\x1cGroestlCoin Signed Message:\n', + bech32: 'grsrt', + bip32: { + public: 0x043587cf, + private: 0x04358394, + }, + pubKeyHash: 0x6f, + scriptHash: 0xc4, + wif: 0xef, +}; + +export const groestlcointestnet: Network = { + messagePrefix: '\x1cGroestlCoin Signed Message:\n', + bech32: 'tgrs', + bip32: { + public: 0x043587cf, + private: 0x04358394, + }, + pubKeyHash: 0x6f, + scriptHash: 0xc4, + wif: 0xef, +}; + export const dogecoin: Network = { messagePrefix: '\x19Dogecoin Signed Message:\n', bech32: 'doge', // TODO: Dogecoin doesn't use bech32, make type optional @@ -203,6 +239,17 @@ export function getNetwork(chain: string, network: string): Network { default: throw new Error(`Invalid network ${network}`); } + case 'GRS': + switch (network) { + case 'mainnet': + return groestlcoin; + case 'testnet': + return groestlcointestnet; + case 'regtest': + return groestlcoinregtest; + default: + throw new Error(`Invalid network ${network}`); + } default: throw new Error(`Invalid chain ${network}`); } diff --git a/packages/node/chain-setup/GRS/mainnet/.env.example b/packages/node/chain-setup/GRS/mainnet/.env.example new file mode 100644 index 000000000..842c349d4 --- /dev/null +++ b/packages/node/chain-setup/GRS/mainnet/.env.example @@ -0,0 +1,85 @@ +# Chain: BTC, LTC, PEPE or GRS +BCN_CHAIN='GRS' +# Network: mainnet, testnet, or regtest +BCN_NETWORK='mainnet' + +# Postgres Connection Credentials +POSTGRES_USER='bcn' +POSTGRES_PASSWORD='bcn' +POSTGRES_DB='bcn' +POSTGRES_HOST='db' +POSTGRES_PORT='5432' +POSTGRES_MAX_CONNECTIONS='20' +POSTGRES_IDLE_TIMEOUT_MILLIS='3000' + +# Bitcoin Node Settings +BITCOIN_IMAGE='groestlcoin/groestlcoin-core:28-alpine' +BITCOIN_DATA_DIR='/home/groestlcoin/.groestlcoin' +BITCOIN_CONF_FILE='groestlcoin.conf' + +# Node Settings +# RPC Client Credentials +BITCOIN_RPC_USER='bcn-admin' +BITCOIN_RPC_PASSWORD='kH4nU5Okm6-uyC0_mA5ztVNacJqZbYd_KGLl6mx722A=' +BITCOIN_RPC_HOST='node' +BITCOIN_RPC_PORT='33873' +BITCOIN_P2P_PORT='33874' +BITCOIN_RPC_PROTOCOL='http' +# Default wallet name +BITCOIN_DEFAULT_WALLET='defaultwallet' + +# Port for Bitcoin Computer Node +BCN_PORT='1031' + +# Enable to launch with fixed number of parallel workers +# BCN_NUM_WORKERS='6' + +BCN_ZMQ_URL='tcp://node:28332' +BCN_ZMQ_PORT='28332' +# Height of the block at which the zmq connection should start +BCN_ZMQ_ACTIVATION_HEIGHT=300000 + + +# Url of the Bitcoin Computer Node, defaults to localhost +BCN_URL='http://127.0.0.1:1031' + +# Allowed RPC Methods +BCN_ALLOWED_RPC_METHODS='^get|^gen|^send|^lis' + +# Setup the environment to 'prod' (no console logs) or 'dev' +BCN_ENV='dev' + +# Winston Logger Settings +# Log levels +# 0: Error logs only +# 1: Error and warning logs +# 2: Error, warning and info logs +# 3: Error, warning, info and http logs +# 4: Error, warning, info, http and debug logs +BCN_LOG_LEVEL='2' +# Maximum number of logs to keep. If not set, no logs will be removed. This can be +# a number of files or number of days. If using days, add 'd' as the suffix. +BCN_LOG_MAX_FILES='14d' +# Maximum log file size. You can use 'k' for KB, 'm' for MB, and 'g' for GB. Once +# the size of the log file exceeds the specified size, the log is rotated. If no +# size is specified the log is not rotated. +BCN_LOG_MAX_SIZE='20m' +# A boolean to define whether or not to gzip archived log files. +BCN_LOG_ZIP='false' + +# Show logs at db service +BCN_SHOW_DB_LOGS='false' + +# Rate Limiting Settings +BCN_RATE_LIMIT_ENABLED='false' +BCN_RATE_LIMIT_WINDOW='900000' +BCN_RATE_LIMIT_MAX='300' +BCN_RATE_LIMIT_STANDARD_HEADERS='true' +BCN_RATE_LIMIT_LEGACY_HEADERS='false' + +# Comma separated list of banned countries, encoded as ISO-3166 alpha2 country. +# codes (see https://www.geonames.org/countries/) +BCN_BANNED_COUNTRIES= + +# Default value for protocol in the _url parameter. Set to https if behind a load balancer. +BCN_OFFCHAIN_PROTOCOL= diff --git a/packages/node/chain-setup/GRS/mainnet/groestlcoin.conf.example b/packages/node/chain-setup/GRS/mainnet/groestlcoin.conf.example new file mode 100644 index 000000000..4b1a4ee87 --- /dev/null +++ b/packages/node/chain-setup/GRS/mainnet/groestlcoin.conf.example @@ -0,0 +1,27 @@ +dbcache=4000 +txindex=1 +printtoconsole=1 + +# [rpc] +# Accept command line and JSON-RPC commands. +server=1 +# Username for JSON-RPC connections +rpcauth=bcn-admin:c71460f0f08e4eeec90e033c04f7bb82$c36e8561d46abbf3bf13da6b88612c19d758d46d02c45cd2716f06a13ec407af +rpcallowip=0.0.0.0/0 +rpcbind=0.0.0.0 +# Rpc work queue increase +rpcworkqueue=512 +rpcport=1441 +port=1331 + +relaypriority=false +prematurewitness=1 + +# [wallet] +wallet=defaultwallet + +printtoconsole=1 + +zmqpubhashtx=tcp://0.0.0.0:28332 +zmqpubrawtx=tcp://0.0.0.0:28332 + diff --git a/packages/node/chain-setup/GRS/regtest/.env.example b/packages/node/chain-setup/GRS/regtest/.env.example new file mode 100644 index 000000000..6056acb0e --- /dev/null +++ b/packages/node/chain-setup/GRS/regtest/.env.example @@ -0,0 +1,86 @@ +# Chain: BTC, LTC, PEPE or GRS +BCN_CHAIN='GRS' +# Network: mainnet, testnet, or regtest +BCN_NETWORK='regtest' + +# Postgres Connection Credentials +POSTGRES_USER='bcn' +POSTGRES_PASSWORD='bcn' +POSTGRES_DB='bcn' +POSTGRES_HOST='db' +POSTGRES_PORT='5432' +POSTGRES_MAX_CONNECTIONS='20' +POSTGRES_IDLE_TIMEOUT_MILLIS='3000' + +# Bitcoin Node Settings +BITCOIN_IMAGE='groestlcoin/groestlcoin-core:28-alpine' +BITCOIN_DATA_DIR='/home/groestlcoin/.groestlcoin' +BITCOIN_CONF_FILE='groestlcoin.conf' + +# Node Settings +# RPC Client Credentials +BITCOIN_RPC_USER='bcn-admin' +BITCOIN_RPC_PASSWORD='kH4nU5Okm6-uyC0_mA5ztVNacJqZbYd_KGLl6mx722A=' +BITCOIN_RPC_HOST='node' +BITCOIN_RPC_PORT='18443' +BITCOIN_P2P_PORT='18888' +BITCOIN_RPC_PROTOCOL='http' + +# Default wallet name +BITCOIN_DEFAULT_WALLET='defaultwallet' + +# Port for Bitcoin Computer Node +BCN_PORT='1031' + +# Enable to launch with fixed number of parallel workers +# BCN_NUM_WORKERS='6' + +BCN_ZMQ_URL='tcp://node:28332' +BCN_ZMQ_PORT='28332' +# Height of the block at which the zmq connection should start +BCN_ZMQ_ACTIVATION_HEIGHT=1 + + +# Url of the Bitcoin Computer Node, defaults to localhost +BCN_URL='http://127.0.0.1:1031' + +# Allowed RPC Methods +BCN_ALLOWED_RPC_METHODS='^get|^gen|^send|^lis' + +# Setup the environment to 'prod' (no console logs) or 'dev' +BCN_ENV='dev' + +# Winston Logger Settings +# Log levels +# 0: Error logs only +# 1: Error and warning logs +# 2: Error, warning and info logs +# 3: Error, warning, info and http logs +# 4: Error, warning, info, http and debug logs +BCN_LOG_LEVEL='2' +# Maximum number of logs to keep. If not set, no logs will be removed. This can be +# a number of files or number of days. If using days, add 'd' as the suffix. +BCN_LOG_MAX_FILES='14d' +# Maximum log file size. You can use 'k' for KB, 'm' for MB, and 'g' for GB. Once +# the size of the log file exceeds the specified size, the log is rotated. If no +# size is specified the log is not rotated. +BCN_LOG_MAX_SIZE='20m' +# A boolean to define whether or not to gzip archived log files. +BCN_LOG_ZIP='false' + +# Show logs at db service +BCN_SHOW_DB_LOGS='false' + +# Rate Limiting Settings +BCN_RATE_LIMIT_ENABLED='false' +BCN_RATE_LIMIT_WINDOW='900000' +BCN_RATE_LIMIT_MAX='300' +BCN_RATE_LIMIT_STANDARD_HEADERS='true' +BCN_RATE_LIMIT_LEGACY_HEADERS='false' + +# Comma separated list of banned countries, encoded as ISO-3166 alpha2 country. +# codes (see https://www.geonames.org/countries/) +BCN_BANNED_COUNTRIES= + +# Default value for protocol in the _url parameter. Set to https if behind a load balancer. +BCN_OFFCHAIN_PROTOCOL= diff --git a/packages/node/chain-setup/GRS/regtest/groestlcoin.conf.example b/packages/node/chain-setup/GRS/regtest/groestlcoin.conf.example new file mode 100644 index 000000000..e2f2ee724 --- /dev/null +++ b/packages/node/chain-setup/GRS/regtest/groestlcoin.conf.example @@ -0,0 +1,17 @@ +printtoconsole=1 +regtest=1 + +server=1 +txindex=1 + +rpcbind=0.0.0.0 +rpcallowip=0.0.0.0/0 +rpcauth=bcn-admin:c71460f0f08e4eeec90e033c04f7bb82$c36e8561d46abbf3bf13da6b88612c19d758d46d02c45cd2716f06a13ec407af +zmqpubhashtx=tcp://0.0.0.0:28332 +zmqpubrawtx=tcp://0.0.0.0:28332 +prematurewitness=1 +relaypriority=false + +[regtest] +rpcport=18332 +port=18444 \ No newline at end of file diff --git a/packages/node/chain-setup/GRS/testnet/.env.example b/packages/node/chain-setup/GRS/testnet/.env.example new file mode 100644 index 000000000..c98f24cf2 --- /dev/null +++ b/packages/node/chain-setup/GRS/testnet/.env.example @@ -0,0 +1,86 @@ +# Chain: GRS +BCN_CHAIN='GRS' +# Network: mainnet, testnet, or regtest +BCN_NETWORK='testnet' + +# Postgres Connection Credentials +POSTGRES_USER='bcn' +POSTGRES_PASSWORD='bcn' +POSTGRES_DB='bcn' +POSTGRES_HOST='db' +POSTGRES_PORT='5432' +POSTGRES_MAX_CONNECTIONS='20' +POSTGRES_IDLE_TIMEOUT_MILLIS='3000' + +# Bitcoin Node Settings +BITCOIN_IMAGE='groestlcoin/groestlcoin-core:28-alpine' +BITCOIN_DATA_DIR='/home/groestlcoin/.groestlcoin' +BITCOIN_CONF_FILE='groestlcoin.conf' + +# Node Settings +# RPC Client Credentials +BITCOIN_RPC_USER='bcn-admin' +BITCOIN_RPC_PASSWORD='kH4nU5Okm6-uyC0_mA5ztVNacJqZbYd_KGLl6mx722A=' +BITCOIN_RPC_HOST='node' +BITCOIN_RPC_PORT='17766' +BITCOIN_P2P_PORT='17777' +BITCOIN_RPC_PROTOCOL='http' + +# Default wallet name +BITCOIN_DEFAULT_WALLET='defaultwallet' + +# Bitcoin Computer Node (BCN) Settings +# Port for Bitcoin Computer Node +BCN_PORT='1031' + +# Enable to launch with fixed number of parallel workers +# BCN_NUM_WORKERS='6' + +BCN_ZMQ_URL='tcp://node:28332' +BCN_ZMQ_PORT='28332' +# Height of the block at which the zmq connection should start +BCN_ZMQ_ACTIVATION_HEIGHT=80000 + +# Url of the Bitcoin Computer Node, defaults to localhost +BCN_URL='http://127.0.0.1:1031' + +# Allowed RPC Methods +BCN_ALLOWED_RPC_METHODS='^get|^gen|^send|^lis' + +# Setup the environment to 'prod' (no console logs) or 'dev' +BCN_ENV='dev' + +# Winston Logger Settings +# Log levels +# 0: Error logs only +# 1: Error and warning logs +# 2: Error, warning and info logs +# 3: Error, warning, info and http logs +# 4: Error, warning, info, http and debug logs +BCN_LOG_LEVEL='2' +# Maximum number of logs to keep. If not set, no logs will be removed. This can be +# a number of files or number of days. If using days, add 'd' as the suffix. +BCN_LOG_MAX_FILES='14d' +# Maximum log file size. You can use 'k' for KB, 'm' for MB, and 'g' for GB. Once +# the size of the log file exceeds the specified size, the log is rotated. If no +# size is specified the log is not rotated. +BCN_LOG_MAX_SIZE='20m' +# A boolean to define whether or not to gzip archived log files. +BCN_LOG_ZIP='false' + +# Show logs at db service +BCN_SHOW_DB_LOGS='false' + +# Rate Limiting Settings +BCN_RATE_LIMIT_ENABLED='false' +BCN_RATE_LIMIT_WINDOW='900000' +BCN_RATE_LIMIT_MAX='300' +BCN_RATE_LIMIT_STANDARD_HEADERS='true' +BCN_RATE_LIMIT_LEGACY_HEADERS='false' + +# Comma separated list of banned countries, encoded as ISO-3166 alpha2 country. +# codes (see https://www.geonames.org/countries/) +BCN_BANNED_COUNTRIES= + +# Default value for protocol in the _url parameter. Set to https if behind a load balancer. +BCN_OFFCHAIN_PROTOCOL= diff --git a/packages/node/chain-setup/GRS/testnet/groestlcoin.conf.example b/packages/node/chain-setup/GRS/testnet/groestlcoin.conf.example new file mode 100644 index 000000000..eebb91078 --- /dev/null +++ b/packages/node/chain-setup/GRS/testnet/groestlcoin.conf.example @@ -0,0 +1,31 @@ +testnet=1 + +printtoconsole=1 + +dbcache=4000 +txindex=1 + +# [rpc] +# Accept command line and JSON-RPC commands. +server=1 +# Username for JSON-RPC connections +rpcauth=bcn-admin:c71460f0f08e4eeec90e033c04f7bb82$c36e8561d46abbf3bf13da6b88612c19d758d46d02c45cd2716f06a13ec407af +rpcallowip=0.0.0.0/0 + +rpcbind=0.0.0.0 + +# [wallet] +wallet=defaultwallet + +zmqpubhashtx=tcp://0.0.0.0:28332 +zmqpubrawtx=tcp://0.0.0.0:28332 + +relaypriority=false +prematurewitness=1 + +# Rpc work queue increase +rpcworkqueue=512 + +[testnet] +rpcport=17766 +port=17777 \ No newline at end of file diff --git a/packages/node/package.json b/packages/node/package.json index 5a4582e88..11a7a8e48 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -8,6 +8,7 @@ "Litecoin", "Dogecoin", "Pepecoin", + "Groestlcoin", "Smart Contracts", "JavaScript" ], From 2adb3565a31424cd5f0e188715963b7110d6a76b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20D=C3=ADaz?= Date: Sat, 26 Apr 2025 22:18:31 +0200 Subject: [PATCH 2/4] updating for GRS and adding missing deps and fixes to build --- packages/components/built/Auth.d.ts | 2 +- packages/components/built/Auth.js | 4 +++- packages/components/built/common/types.d.ts | 2 +- packages/components/package.json | 5 ++++- packages/components/src/Auth.tsx | 22 +++++++++++++++++++-- packages/components/src/common/types.ts | 2 +- 6 files changed, 30 insertions(+), 7 deletions(-) diff --git a/packages/components/built/Auth.d.ts b/packages/components/built/Auth.d.ts index 340c8e34e..92f9f6c0a 100644 --- a/packages/components/built/Auth.d.ts +++ b/packages/components/built/Auth.d.ts @@ -1,6 +1,6 @@ import { Computer } from '@bitcoin-computer/lib'; import type { Chain, Network, ModuleStorageType } from './common/types'; -export type TBCChain = 'LTC' | 'BTC' | 'PEPE' | 'DOGE'; +export type TBCChain = 'LTC' | 'BTC' | 'PEPE' | 'DOGE' | 'GRS'; export type TBCNetwork = 'testnet' | 'mainnet' | 'regtest'; export type AddressType = 'p2pkh' | 'p2wpkh' | 'p2tr'; export type ComputerOptions = Partial<{ diff --git a/packages/components/built/Auth.js b/packages/components/built/Auth.js index a05b8d018..806188d98 100644 --- a/packages/components/built/Auth.js +++ b/packages/components/built/Auth.js @@ -41,6 +41,8 @@ function getCoinType(chain, network) { return 3434; if (chain === 'BCH') return 145; + if (chain === 'GRS') + return 17; throw new Error("Unsupported chain ".concat(chain, " or network ").concat(network)); } function getBip44Path(_a) { @@ -75,7 +77,7 @@ function MnemonicInput(_a) { } function ChainInput(_a) { var chain = _a.chain, setChain = _a.setChain; - return (_jsxs(_Fragment, { children: [_jsx("label", { className: "block mt-4 mb-2 text-sm font-medium text-gray-900 dark:text-white", children: "Chain" }), _jsxs("fieldset", { className: "flex", children: [_jsx("legend", { className: "sr-only", children: "Chain" }), _jsxs("div", { className: "flex items-center mr-4", children: [_jsx("input", { onChange: function () { return setChain('LTC'); }, checked: chain === 'LTC', id: "chain-ltc", type: "radio", name: "chain", value: "LTC", className: "w-4 h-4 border-gray-300 focus:ring-2 focus:ring-blue-300 dark:focus:ring-blue-600 dark:focus:bg-blue-600 dark:bg-gray-700 dark:border-gray-600" }), _jsx("label", { htmlFor: "chain-ltc", className: "block ms-2 text-sm font-medium text-gray-900 dark:text-gray-300", children: "LTC" })] }), _jsxs("div", { className: "flex items-center mr-4", children: [_jsx("input", { onChange: function () { return setChain('BTC'); }, checked: chain === 'BTC', id: "chain-btc", type: "radio", name: "chain", value: "BTC", className: "w-4 h-4 border-gray-300 focus:ring-2 focus:ring-blue-300 dark:focus:ring-blue-600 dark:focus:bg-blue-600 dark:bg-gray-700 dark:border-gray-600" }), _jsx("label", { htmlFor: "chain-btc", className: "block ms-2 text-sm font-medium text-gray-900 dark:text-gray-300", children: "BTC" })] }), _jsxs("div", { className: "flex items-center mr-4", children: [_jsx("input", { onChange: function () { return setChain('PEPE'); }, id: "chain-pepe", type: "radio", name: "chain", value: "PEPE", className: "w-4 h-4 border-gray-200 focus:ring-2 focus:ring-blue-300 dark:focus:ring-blue-600 dark:bg-gray-700 dark:border-gray-600" }), _jsx("label", { htmlFor: "chain-pepe", className: "block ms-2 text-sm font-medium text-gray-900 dark:text-gray-300", children: "PEPE" })] }), _jsxs("div", { className: "flex items-center mr-4", children: [_jsx("input", { onChange: function () { return setChain('DOGE'); }, id: "chain-doge", type: "radio", name: "chain", value: "DOGE", className: "w-4 h-4 border-gray-200 focus:ring-2 focus:ring-blue-300 dark:focus:ring-blue-600 dark:bg-gray-700 dark:border-gray-600", disabled: true }), _jsx("label", { htmlFor: "chain-doge", className: "block ms-2 text-sm font-medium text-gray-900 dark:text-gray-300", children: "DOGE" })] })] })] })); + return (_jsxs(_Fragment, { children: [_jsx("label", { className: "block mt-4 mb-2 text-sm font-medium text-gray-900 dark:text-white", children: "Chain" }), _jsxs("fieldset", { className: "flex", children: [_jsx("legend", { className: "sr-only", children: "Chain" }), _jsxs("div", { className: "flex items-center mr-4", children: [_jsx("input", { onChange: function () { return setChain('LTC'); }, checked: chain === 'LTC', id: "chain-ltc", type: "radio", name: "chain", value: "LTC", className: "w-4 h-4 border-gray-300 focus:ring-2 focus:ring-blue-300 dark:focus:ring-blue-600 dark:focus:bg-blue-600 dark:bg-gray-700 dark:border-gray-600" }), _jsx("label", { htmlFor: "chain-ltc", className: "block ms-2 text-sm font-medium text-gray-900 dark:text-gray-300", children: "LTC" })] }), _jsxs("div", { className: "flex items-center mr-4", children: [_jsx("input", { onChange: function () { return setChain('BTC'); }, checked: chain === 'BTC', id: "chain-btc", type: "radio", name: "chain", value: "BTC", className: "w-4 h-4 border-gray-300 focus:ring-2 focus:ring-blue-300 dark:focus:ring-blue-600 dark:focus:bg-blue-600 dark:bg-gray-700 dark:border-gray-600" }), _jsx("label", { htmlFor: "chain-btc", className: "block ms-2 text-sm font-medium text-gray-900 dark:text-gray-300", children: "BTC" })] }), _jsxs("div", { className: "flex items-center mr-4", children: [_jsx("input", { onChange: function () { return setChain('PEPE'); }, id: "chain-pepe", type: "radio", name: "chain", value: "PEPE", className: "w-4 h-4 border-gray-200 focus:ring-2 focus:ring-blue-300 dark:focus:ring-blue-600 dark:bg-gray-700 dark:border-gray-600" }), _jsx("label", { htmlFor: "chain-pepe", className: "block ms-2 text-sm font-medium text-gray-900 dark:text-gray-300", children: "PEPE" })] }), _jsxs("div", { className: "flex items-center mr-4", children: [_jsx("input", { onChange: function () { return setChain('DOGE'); }, id: "chain-doge", type: "radio", name: "chain", value: "DOGE", className: "w-4 h-4 border-gray-200 focus:ring-2 focus:ring-blue-300 dark:focus:ring-blue-600 dark:bg-gray-700 dark:border-gray-600", disabled: true }), _jsx("label", { htmlFor: "chain-doge", className: "block ms-2 text-sm font-medium text-gray-900 dark:text-gray-300", children: "DOGE" })] }), _jsxs("div", { className: "flex items-center mr-4", children: [_jsx("input", { onChange: function () { return setChain('GRS'); }, id: "chain-grs", type: "radio", name: "chain", value: "GRS", className: "w-4 h-4 border-gray-200 focus:ring-2 focus:ring-blue-300 dark:focus:ring-blue-600 dark:bg-gray-700 dark:border-gray-600", disabled: true }), _jsx("label", { htmlFor: "chain-grs", className: "block ms-2 text-sm font-medium text-gray-900 dark:text-gray-300", children: "GRS" })] })] })] })); } function NetworkInput(_a) { var network = _a.network, setNetwork = _a.setNetwork; diff --git a/packages/components/built/common/types.d.ts b/packages/components/built/common/types.d.ts index 1ba18503f..d1ce6f18d 100644 --- a/packages/components/built/common/types.d.ts +++ b/packages/components/built/common/types.d.ts @@ -1,3 +1,3 @@ -export type Chain = 'LTC' | 'BTC' | 'DOGE' | 'PEPE'; +export type Chain = 'LTC' | 'BTC' | 'DOGE' | 'PEPE' | 'GRS'; export type Network = 'testnet' | 'mainnet' | 'regtest'; export type ModuleStorageType = 'taproot' | 'multisig'; diff --git a/packages/components/package.json b/packages/components/package.json index 7e0b5a6c6..d419a1844 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -43,7 +43,10 @@ }, "devDependencies": { "@babel/preset-react": "^7.23.3", + "@types/node": "^22.15.2", + "@types/react": "^19.1.2", "@typescript-eslint/eslint-plugin": "^7.9.0", - "@typescript-eslint/parser": "^7.9.0" + "@typescript-eslint/parser": "^7.9.0", + "vite": "^6.3.3" } } diff --git a/packages/components/src/Auth.tsx b/packages/components/src/Auth.tsx index b62bef060..79ab7f724 100644 --- a/packages/components/src/Auth.tsx +++ b/packages/components/src/Auth.tsx @@ -7,7 +7,7 @@ import { Modal } from './Modal' import type { Chain, Network, ModuleStorageType } from './common/types' import { getEnv } from './common/utils' -export type TBCChain = 'LTC' | 'BTC' | 'PEPE' | 'DOGE' +export type TBCChain = 'LTC' | 'BTC' | 'PEPE' | 'DOGE' | 'GRS' export type TBCNetwork = 'testnet' | 'mainnet' | 'regtest' export type AddressType = 'p2pkh' | 'p2wpkh' | 'p2tr' @@ -48,6 +48,7 @@ function getCoinType(chain: string, network: string): number { if (chain === 'DOGE') return 3 if (chain === 'PEPE') return 3434 if (chain === 'BCH') return 145 + if (chain === 'GRS') return 17 throw new Error(`Unsupported chain ${chain} or network ${network}`) } @@ -187,6 +188,23 @@ function ChainInput({ chain, setChain }: { chain: Chain | undefined; setChain: D DOGE +
+ setChain('GRS')} + id="chain-grs" + type="radio" + name="chain" + value="GRS" + className="w-4 h-4 border-gray-200 focus:ring-2 focus:ring-blue-300 dark:focus:ring-blue-600 dark:bg-gray-700 dark:border-gray-600" + disabled + /> + +
) @@ -332,7 +350,7 @@ function LoginForm() { {!chain && } {!network && } - {!url && } + {!url && } />} diff --git a/packages/components/src/common/types.ts b/packages/components/src/common/types.ts index e2f7dc2d4..6b130a619 100644 --- a/packages/components/src/common/types.ts +++ b/packages/components/src/common/types.ts @@ -1,3 +1,3 @@ -export type Chain = 'LTC' | 'BTC' | 'DOGE' | 'PEPE' +export type Chain = 'LTC' | 'BTC' | 'DOGE' | 'PEPE' | 'GRS' export type Network = 'testnet' | 'mainnet' | 'regtest' export type ModuleStorageType = 'taproot' | 'multisig' From 2605597058b7b7a090a8c7ca44cfb1f224a93cf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20D=C3=ADaz?= Date: Sat, 26 Apr 2025 22:34:52 +0200 Subject: [PATCH 3/4] adding groestl hash deps & funcs --- packages/lib/computer.d.ts | 2 +- packages/nakamotojs/package.json | 2 ++ packages/nakamotojs/src/crypto.js | 8 ++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/lib/computer.d.ts b/packages/lib/computer.d.ts index 16a16a88e..57609b4ce 100644 --- a/packages/lib/computer.d.ts +++ b/packages/lib/computer.d.ts @@ -72,7 +72,7 @@ declare class Update { isValid(fromTx: Update): boolean } -type TBCChain = 'LTC' | 'BTC' | 'PEPE' | string +type TBCChain = 'LTC' | 'BTC' | 'PEPE' | 'DOGE' | 'GRS' | string type TBCNetwork = 'testnet' | 'mainnet' | 'regtest' | string type Fee = Partial<{ fee: number diff --git a/packages/nakamotojs/package.json b/packages/nakamotojs/package.json index f5845ca1c..d1121e249 100644 --- a/packages/nakamotojs/package.json +++ b/packages/nakamotojs/package.json @@ -58,6 +58,7 @@ "bip174": "^2.1.0", "bs58check": "^3.0.1", "buffer": "^6.0.3", + "hashes-grs": "^1.2.0", "typeforce": "^1.11.3", "varuint-bitcoin": "^1.1.2" }, @@ -78,6 +79,7 @@ "bs58": "^4.0.0", "dotenv": "^16.4.5", "ecpair": "^2.0.1", + "ecpairgrs": "^2.0.2", "elliptic": "^6.6.1", "hoodwink": "^2.0.0", "minimaldata": "^1.0.2", diff --git a/packages/nakamotojs/src/crypto.js b/packages/nakamotojs/src/crypto.js index 55a549cef..e4450676b 100644 --- a/packages/nakamotojs/src/crypto.js +++ b/packages/nakamotojs/src/crypto.js @@ -1,6 +1,7 @@ import { ripemd160 as _ripemd160 } from '@noble/hashes/ripemd160'; import { sha1 as _sha1 } from '@noble/hashes/sha1'; import { sha256 as _sha256 } from '@noble/hashes/sha256'; +import { groestl512 } from 'hashes-grs/groestl512' import { Buffer } from 'buffer'; export function ripemd160(buffer) { return Buffer.from(_ripemd160(Uint8Array.from(buffer))); @@ -17,6 +18,13 @@ export function hash160(buffer) { export function hash256(buffer) { return Buffer.from(_sha256(_sha256(Uint8Array.from(buffer)))); } +export function grs512(buf){ + return Buffer.from(groestl512(buf)) +} +export function grs512d(buf){ + return Buffer.from(groestl512(groestl512(buf))) +} + export const TAGS = [ 'BIP0340/challenge', 'BIP0340/aux', From 4fe119b7d6a1791b2deb5ff227c38322566538b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20D=C3=ADaz?= Date: Sat, 26 Apr 2025 22:50:47 +0200 Subject: [PATCH 4/4] adding missing deps and passing tests --- packages/nakamotojs/package.json | 9 +++++++-- packages/nakamotojs/src/crypto.js | 8 -------- packages/nakamotojs/src/networks.js | 8 ++------ packages/nakamotojs/ts_src/networks.ts | 2 +- 4 files changed, 10 insertions(+), 17 deletions(-) diff --git a/packages/nakamotojs/package.json b/packages/nakamotojs/package.json index d1121e249..98b8e27a8 100644 --- a/packages/nakamotojs/package.json +++ b/packages/nakamotojs/package.json @@ -66,29 +66,34 @@ "@bitcoin-computer/secp256k1": "^0.24.3-beta.0", "@types/bs58": "^4.0.0", "@types/bs58check": "^2.1.0", + "@types/chai": "^5.2.1", "@types/mocha": "^5.2.7", "@types/node": "^16.11.7", "@types/proxyquire": "^1.3.28", "@typescript-eslint/eslint-plugin": "^7.9.0", "@typescript-eslint/parser": "^7.9.0", + "axios": "^1.9.0", "bip32": "^4.0.0", "bip39": "^3.1.0", "bip65": "^1.0.1", "bip68": "^1.0.3", "bitcoind-rpc": "^0.9.1", "bs58": "^4.0.0", + "chai": "^5.2.0", "dotenv": "^16.4.5", "ecpair": "^2.0.1", "ecpairgrs": "^2.0.2", "elliptic": "^6.6.1", + "eslint-config-prettier": "^10.1.2", + "eslint-plugin-prettier": "^5.2.6", "hoodwink": "^2.0.0", "minimaldata": "^1.0.2", "mocha": "^10.0.0", "nyc": "^15.1.0", - "prettier": "^3.2.5", + "prettier": "^3.5.3", "proxyquire": "^2.0.1", "ts-node": "^8.3.0", - "typescript": "^5.5.3" + "typescript": "^5.8.3" }, "engines": { "node": ">=8.0.0" diff --git a/packages/nakamotojs/src/crypto.js b/packages/nakamotojs/src/crypto.js index e4450676b..55a549cef 100644 --- a/packages/nakamotojs/src/crypto.js +++ b/packages/nakamotojs/src/crypto.js @@ -1,7 +1,6 @@ import { ripemd160 as _ripemd160 } from '@noble/hashes/ripemd160'; import { sha1 as _sha1 } from '@noble/hashes/sha1'; import { sha256 as _sha256 } from '@noble/hashes/sha256'; -import { groestl512 } from 'hashes-grs/groestl512' import { Buffer } from 'buffer'; export function ripemd160(buffer) { return Buffer.from(_ripemd160(Uint8Array.from(buffer))); @@ -18,13 +17,6 @@ export function hash160(buffer) { export function hash256(buffer) { return Buffer.from(_sha256(_sha256(Uint8Array.from(buffer)))); } -export function grs512(buf){ - return Buffer.from(groestl512(buf)) -} -export function grs512d(buf){ - return Buffer.from(groestl512(groestl512(buf))) -} - export const TAGS = [ 'BIP0340/challenge', 'BIP0340/aux', diff --git a/packages/nakamotojs/src/networks.js b/packages/nakamotojs/src/networks.js index 2aeff0eba..fe352d3a8 100644 --- a/packages/nakamotojs/src/networks.js +++ b/packages/nakamotojs/src/networks.js @@ -126,7 +126,7 @@ export const groestlcointestnet = { public: 0x043587cf, private: 0x04358394, }, - pubKeyHash: 0x71, + pubKeyHash: 0x6f, scriptHash: 0xc4, wif: 0xef, }; @@ -219,7 +219,7 @@ export function getNetwork(chain, network) { return groestlcoinregtest; default: throw new Error(`Invalid network ${network}`); - } + } default: throw new Error(`Invalid chain ${network}`); } @@ -241,8 +241,4 @@ export const NETWORKS = { dogecoin, dogecoinregtest, dogecointestnet, - // Groestlcoin - groestlcoin, - groestlcoinregtest, - groestlcointestnet, }; diff --git a/packages/nakamotojs/ts_src/networks.ts b/packages/nakamotojs/ts_src/networks.ts index 49baa08c5..02941f15f 100644 --- a/packages/nakamotojs/ts_src/networks.ts +++ b/packages/nakamotojs/ts_src/networks.ts @@ -249,7 +249,7 @@ export function getNetwork(chain: string, network: string): Network { return groestlcoinregtest; default: throw new Error(`Invalid network ${network}`); - } + } default: throw new Error(`Invalid chain ${network}`); }