diff --git a/electrumx/lib/coins.py b/electrumx/lib/coins.py index ef25c74c..0636dbcf 100644 --- a/electrumx/lib/coins.py +++ b/electrumx/lib/coins.py @@ -38,7 +38,7 @@ from typing import Sequence, Tuple import electrumx.lib.util as util -from electrumx.lib.hash import Base58, double_sha256, hash_to_hex_str +from electrumx.lib.hash import Base58, double_sha256, hash_to_hex_str, keccak_256 from electrumx.lib.hash import HASHX_LEN, hex_str_to_hash from electrumx.lib.script import (_match_ops, Script, ScriptError, ScriptPubKey, OpCodes) @@ -4239,3 +4239,28 @@ class FerriteTestnet(Ferrite): 'enode2.ferritecoin.org s t', 'enode3.ferritecoin.org s t', ] + + +class Bitgesell(Coin): + + NAME = "Bitgesell" + SHORTNAME = "BGL" + NET = "mainnet" + XPUB_VERBYTES = bytes.fromhex("0488b21e") + XPRV_VERBYTES = bytes.fromhex("0488ade4") + RPC_PORT = 8332 + GENESIS_HASH = ('00000018cdcfeeb4dfdebe9392b855cfea7d6ddb953ef13f974b58773606d53d') + PEERS = [] + DESERIALIZER = lib_tx.DeserializerSegWitBGL + MEMPOOL_HISTOGRAM_REFRESH_SECS = 120 + TX_COUNT = 14731600 + TX_COUNT_HEIGHT = 228495 + TX_PER_BLOCK = 64 + P2PKH_VERBYTE = bytes.fromhex("0a") + P2SH_VERBYTES = (bytes.fromhex("19"),) + WIF_BYTE = bytes.fromhex("80") + + @classmethod + def header_hash(cls, header): + '''Given a header return hash''' + return keccak_256(header) diff --git a/electrumx/lib/hash.py b/electrumx/lib/hash.py index fe11d913..d737198e 100644 --- a/electrumx/lib/hash.py +++ b/electrumx/lib/hash.py @@ -47,6 +47,12 @@ def double_sha256(x): return sha256(sha256(x)) +def keccak_256(s): + from Cryptodome.Hash import keccak + keccak_hash = keccak.new(data=s, digest_bits=256) + return keccak_hash.digest() + + def hash_to_hex_str(x): '''Convert a big-endian binary hash to displayed hex string. diff --git a/electrumx/lib/tx.py b/electrumx/lib/tx.py index 95d69b20..dba97d43 100644 --- a/electrumx/lib/tx.py +++ b/electrumx/lib/tx.py @@ -312,6 +312,10 @@ def read_tx_and_vsize(self): return tx, vsize +class DeserializerSegWitBGL(DeserializerSegWit): + TX_HASH_FN = staticmethod(sha256) + + class DeserializerLitecoin(DeserializerSegWit): '''Class representing Litecoin transactions, which may have the MW flag set. diff --git a/tests/blocks/bitgesell_mainnet_231411.json b/tests/blocks/bitgesell_mainnet_231411.json new file mode 100644 index 00000000..e567ea98 --- /dev/null +++ b/tests/blocks/bitgesell_mainnet_231411.json @@ -0,0 +1,17 @@ +{ + "hash": "00000000000024b897b82e99f56faf38ee16041d132e8a8e5325340c7d3d9080", + "size": 939, + "height": 231411, + "merkleroot": "d81bc554bb8be4d7f2d187bd9739e0f3cc735b152c7cbdb029e88b9876f6f164", + "tx": [ + "dd9d77e04272bf5998fdb604a42824b9fa5b4915863dd5ca1ed282a5a3a49081", + "be6b5a00c34f91ee632be06b2f3d8b5584e6e11ee5cb9af39ad7eca5fa9787a7", + "291545b7825d6cbbf41d67432ae6508a6686fee921e499c1c292f10a0bd978c8", + "7fb6119bbdafaa1eaa0deedd66f69e9f955c13425ebe1aef11bfd52e8686cc5a" + ], + "time": 1727638408, + "nonce": 811927577, + "bits": "1a2558ce", + "previousblockhash": "00000000000005da21dfcf56f25cd1d5d638d66943fe0c1132aebcbea801a283", + "block": "0000002083a201a8bebcae32110cfe4369d638d6d5d15cf256cfdf21da0500000000000064f1f676988be829b0bd7c2c155b73ccf3e03997bd87d1f2d7e48bbb54c51bd888abf966ce58251a1908653004020000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff1803f387030429abf9660881000286440000007969696d700000000000020000000000000000266a24aa21a9edda32d471ddeea67754aeef1e6b75822cc37f1f91e78d38e48a1e7551277376669b298c4a000000001976a914c9e18028eaa8e74efa6ccc2a5ebdbd08b0bb167788ac012000000000000000000000000000000000000000000000000000000000000000000000000002000000000101e801cc53772f5bff60db03b78a92e276bdd323857c387384e5365aff1c12f6850100000000feffffff021601f0992c0000001600140bc3b20f2954c344a3de451f885858d308898b2c5c470c0000000000160014e17a4efad3a02ad25f12af881468993d8fe958040247304402201a07cae2939ba1f530f0a671990af2efd8122f42258b1a1a6fa2bcb030d8393902202c26c6ebf2624d495e54e3b0f9ddb895a4400953ad2aee23dd49524a1e936172012103ccb388d88ea55306f925352c42866c77d71b65fba08978163b2b161290e4a85ff087030002000000000101a78797faa5ecd79af39acbe51ee1e684558b3d2f6be02b63ee914fc3005a6bbe0000000000feffffff02a029040000000000160014e17a4efad3a02ad25f12af881468993d8fe95804a201c3992c000000160014c2bf86058961a2ad193e428ec91bdefc19610db2024730440220678d0eac5f2cb2a46a8917d2ec6240f7075b589d4b89eae40837b7a3a79219e80220694b80a8f5d5712c0f2275d46b793791b851cd9c55a38847d9dc9a92fdb1458601210354e733d5ee1c57e2e39ca14e805048c0baa9ec473714337203b921aa9ad08798f187030002000000000101c8181fa37a212fe71e26a55e8251b9271a01164c0afdbb2ed79e687d73bf90ce0000000000fdffffff02b42208160000000016001460d0dd284fb56e367ac836d1a47d4e2a436a9f47481bfa0500000000160014bae6956fa85ca7ada1c585a73bcc70ab1598550b024730440220137f84005084f79abd3783253275fb87d3d1eff2aee33376b0b77e9499fc02a402202be215715d0f14a79838995123d69a087666a957d9a7eea33774ba5dbf027002012103738510ee99ff073df15bbdfcd7b0a38cc3013f81059af7eb815714dff90f988af2870300" +} \ No newline at end of file