bitcurve (OP)
Member

Offline
Activity: 76
Merit: 11
|
I was wondering if anyone has a minimalistic, C++ (can also be C, or any other lang, as long as it's minimalistic but complete) Implementation of the original bitcoin protocol, and by "the original bitcoin protocol" I mean just the most basic features, legacy addresses and maybe basic multisig functionality only, only what is necessary to form a working bitcoin chain.
I searched for it for sometime in github with no luck. any implementation i find is either something like btcd, with more advanced non-minimalistic features or a miniature blockchain.
|
|
|
|
|
pooya87
Legendary
Offline
Activity: 4102
Merit: 12279
|
 |
November 27, 2024, 06:27:57 AM |
|
What exactly are you trying to do and what parts of the libraries do you find non-minimalistic and why is that a problem? A Bitcoin library is either incomplete which is not a good idea to use or is a full implementation of Bitcoin Protocol. It would be pointless for someone to implement like half of the protocol. In any case since you mentioned "original protocol", here is the bitcoin core's first version that can be found on the internet: https://github.com/benjiqq/bitcoinArchive maybe that helps.
|
|
|
|
bitcurve (OP)
Member

Offline
Activity: 76
Merit: 11
|
 |
November 27, 2024, 06:49:11 AM |
|
Well the original early versions are GUI versions with outdated libraries. Any GUI version is not minimalistic...
It's not a problem, i just want a minimalistic implementation
|
|
|
|
|
vjudeu
Copper Member
Legendary
Offline
Activity: 909
Merit: 2363
|
 |
November 27, 2024, 07:32:59 AM |
|
only what is necessary to form a working bitcoin chain Then, just take version 0.1.0, and remove things, which you don't need. For example: instead of "scriptSig" and "scriptPubKey", you only need "sig" and "pubKey", and ECDSA implementation. I guess the bare minimum is hashing, so you can start from SHA-256 implementation (because then, you can form a chain). The next thing is public key cryptography, which means secp256k1 implementation. If you have those two, then you can form the basic chain. If you ignore everything else, then you will have "downgraded soft-fork", where your version will only check P2PK, and accept everything else as valid. Anyone has a minimalistic, C++ Implementation of the original bitcoin protocol? I was trying to do something like that, but it is not yet ready. What exactly are you trying to do and what parts of the libraries do you find non-minimalistic and why is that a problem? I guess it is about recreating the process of making Bitcoin from scratch. Because between empty main function, and the first released version, there are definitely more points, where you have "half-baked coin", and where you can learn, why things are set, the way they are. For example: the bare minimum doesn't need any Script. The bare minimum doesn't need versioning. And there are many other things, which you can remove, and still cover everything, what is described in the whitepaper. So, to sum up: start from SHA-256 implementation, which will give you just "something mineable, without any public keys". Then, add public keys support. And then, you will have the bare minimum. And if you want to test some basic concepts, then you can even downgrade it into SHA-1 with secp160k1, or even CRC-32 with some 32-bit elliptic curve, if you want some weaker test network.
|
I've moved on to other things.
|
|
|
ABCbits
Legendary
Offline
Activity: 3570
Merit: 9884
|
 |
November 27, 2024, 08:54:37 AM |
|
I searched for it for sometime in github with no luck. any implementation i find is either something like btcd, with more advanced non-minimalistic features or a miniature blockchain.
Have you come across https://github.com/piotrnar/gocoin? The newest version have wallet, CLI and web UI, but the older version only have CLI and wallet where the wallet's code is separated from full node client. In addition, gocoin is created by only one person, so i expect he make things as simple as possible to make it easier to maintain. But take note that gocoin simply load entire UTXO into RAM.
|
|
|
|
bitcurve (OP)
Member

Offline
Activity: 76
Merit: 11
|
 |
November 27, 2024, 12:12:24 PM |
|
I searched for it for sometime in github with no luck. any implementation i find is either something like btcd, with more advanced non-minimalistic features or a miniature blockchain.
Have you come across https://github.com/piotrnar/gocoin? The newest version have wallet, CLI and web UI, but the older version only have CLI and wallet where the wallet's code is separated from full node client. In addition, gocoin is created by only one person, so i expect he make things as simple as possible to make it easier to maintain. But take note that gocoin simply load entire UTXO into RAM. That's something quite close to what I was looking for. Thank you so much!
|
|
|
|
|
NotATether
Legendary
Offline
Activity: 2296
Merit: 9604
┻┻ ︵㇏(°□°㇏)
|
 |
November 28, 2024, 01:01:58 PM |
|
I searched for it for sometime in github with no luck. any implementation i find is either something like btcd, with more advanced non-minimalistic features or a miniature blockchain.
Have you come across https://github.com/piotrnar/gocoin? The newest version have wallet, CLI and web UI, but the older version only have CLI and wallet where the wallet's code is separated from full node client. In addition, gocoin is created by only one person, so i expect he make things as simple as possible to make it easier to maintain. But take note that gocoin simply load entire UTXO into RAM. That's something quite close to what I was looking for. Thank you so much! There is also a similar client written in Python called pycoin, but it's no longer maintained. https://pypi.org/project/pycoin/only what is necessary to form a working bitcoin chain Then, just take version 0.1.0, and remove things, which you don't need. For example: instead of "scriptSig" and "scriptPubKey", you only need "sig" and "pubKey", and ECDSA implementation. I guess the bare minimum is hashing, so you can start from SHA-256 implementation (because then, you can form a chain). The next thing is public key cryptography, which means secp256k1 implementation. If you have those two, then you can form the basic chain. If you ignore everything else, then you will have "downgraded soft-fork", where your version will only check P2PK, and accept everything else as valid. Actually, not even 0.1.0. In fact even versions like 0.2 - 0.6 would be suitable as well, not to mention OP will be able to see things like P2PKH and even be able to sync it to the chain fully (at least 0.4.something and up [I forgot exactly which version is the minimum but achow wrote it somewhere]).
|
|
|
|
bitcurve (OP)
Member

Offline
Activity: 76
Merit: 11
|
 |
November 28, 2024, 01:45:00 PM |
|
I searched for it for sometime in github with no luck. any implementation i find is either something like btcd, with more advanced non-minimalistic features or a miniature blockchain.
Have you come across https://github.com/piotrnar/gocoin? The newest version have wallet, CLI and web UI, but the older version only have CLI and wallet where the wallet's code is separated from full node client. In addition, gocoin is created by only one person, so i expect he make things as simple as possible to make it easier to maintain. But take note that gocoin simply load entire UTXO into RAM. That's something quite close to what I was looking for. Thank you so much! There is also a similar client written in Python called pycoin, but it's no longer maintained. https://pypi.org/project/pycoin/only what is necessary to form a working bitcoin chain Then, just take version 0.1.0, and remove things, which you don't need. For example: instead of "scriptSig" and "scriptPubKey", you only need "sig" and "pubKey", and ECDSA implementation. I guess the bare minimum is hashing, so you can start from SHA-256 implementation (because then, you can form a chain). The next thing is public key cryptography, which means secp256k1 implementation. If you have those two, then you can form the basic chain. If you ignore everything else, then you will have "downgraded soft-fork", where your version will only check P2PK, and accept everything else as valid. Actually, not even 0.1.0. In fact even versions like 0.2 - 0.6 would be suitable as well, not to mention OP will be able to see things like P2PKH and even be able to sync it to the chain fully (at least 0.4.something and up [I forgot exactly which version is the minimum but achow wrote it somewhere]). I think it's better off to start with the qt versions rather than the wxwidgets versions actually, but anyhow these old bitcoin source codes are not as good looking (in the sense of code readability) as a project like gocoin. I actually found out that gocoin doesn't verify the block's hash values, it just trusts whoever sends them. I think there are many more issues with gocoin i'm yet to find. So i choose to go with btcd, I'm now stripping it down to the bare minimum.
|
|
|
|
|
pooya87
Legendary
Offline
Activity: 4102
Merit: 12279
|
 |
November 29, 2024, 06:37:39 AM |
|
I actually found out that gocoin doesn't verify the block's hash values, it just trusts whoever sends them. I think there are many more issues with gocoin i'm yet to find.
What do you mean? Gocoin is a full node which means it should verify the blocks it receives (the hash alone is not verified, the entire block is) and a quick look at the code seems like it does have the block verification code https://github.com/piotrnar/gocoin/blob/master/lib/chain/block_check.goAnd you can see it is verifying everything including but not limited to PoW, version, weight, transactions, etc.
|
|
|
|
NotATether
Legendary
Offline
Activity: 2296
Merit: 9604
┻┻ ︵㇏(°□°㇏)
|
I think it's better off to start with the qt versions rather than the wxwidgets versions actually, but anyhow these old bitcoin source codes are not as good looking (in the sense of code readability) as a project like gocoin.
Alright, but just a warning about the Qt builds: I don't know when they started building with Qt5, but old builds using Qt4 (if any) are going to be extremely hard to compile since most distros stopped shipping Qt4 libraries in their repos. You're better off using an older distribution in that case. Happened to me while I was trying to run Armory (a bitcoin wallet) so this could be relevant here.
|
|
|
|
bitcurve (OP)
Member

Offline
Activity: 76
Merit: 11
|
 |
December 01, 2024, 11:34:33 AM |
|
I think it's better off to start with the qt versions rather than the wxwidgets versions actually, but anyhow these old bitcoin source codes are not as good looking (in the sense of code readability) as a project like gocoin.
Alright, but just a warning about the Qt builds: I don't know when they started building with Qt5, but old builds using Qt4 (if any) are going to be extremely hard to compile since most distros stopped shipping Qt4 libraries in their repos. You're better off using an older distribution in that case. Happened to me while I was trying to run Armory (a bitcoin wallet) so this could be relevant here. Thanks for the information, I am currently working on some code based on btcd, however.
|
|
|
|
|
|
antanst
|
 |
December 06, 2024, 09:13:40 PM |
|
I was wondering if anyone has a minimalistic, C++ (can also be C, or any other lang, as long as it's minimalistic but complete) Implementation of the original bitcoin protocol
https://github.com/chjj/mako
|
|
|
|
alexeyneu
Member

Offline
Activity: 392
Merit: 44
|
 |
December 07, 2024, 06:35:12 PM |
|
only what is necessary to form a working bitcoin chain Then, just take version 0.1.0, and remove things, which you don't need. For example: instead of "scriptSig" and "scriptPubKey", you only need "sig" and "pubKey", and ECDSA implementation. without scriptsig you'll have no first block. https://github.com/alexeyneu/BlockZero/blob/master/BlockZero.cpp#L73-L77
|
|
|
|
|
garlonicon
Copper Member
Legendary
Offline
Activity: 944
Merit: 2317
|
 |
December 07, 2024, 08:58:36 PM |
|
without scriptsig you'll have no first block. Why not? You can for example detect, if something is P2PK, and then handle it. And in all other cases, you can just assume it as valid. Then, it will be compatible with the rest of the network, just like a downgraded soft-fork. That's why old nodes have no Taproot or Segwit, and can still follow the same chain. And you can do that too, and throw away the whole Script implementation, then hardcode just some patterns for P2PK, and implement only ECDSA, and nothing else.
|
|
|
|
|
alexeyneu
Member

Offline
Activity: 392
Merit: 44
|
 |
December 07, 2024, 09:57:46 PM Last edit: December 08, 2024, 12:18:51 AM by alexeyneu |
|
code i've posted is a collective work of 10 or so people. And it worked only after ~15 tries where we just wanna to reverse engineer satoshi stuff having easy way to test if it does right or not. where you offer to write his own .... I think you can guess the rest . All other projects eth included just copied this part with no-brainer (you can ask buterin why he'd used nbits = 486604799 for eth block #0).
|
|
|
|
|
tiltedIceCream
Newbie
Offline
Activity: 8
Merit: 21
|
 |
December 16, 2024, 12:37:55 PM |
|
only what is necessary to form a working bitcoin chain Then, just take version 0.1.0, and remove things, which you don't need. For example: instead of "scriptSig" and "scriptPubKey", you only need "sig" and "pubKey", and ECDSA implementation. I guess the bare minimum is hashing, so you can start from SHA-256 implementation (because then, you can form a chain). The next thing is public key cryptography, which means secp256k1 implementation. If you have those two, then you can form the basic chain. If you ignore everything else, then you will have "downgraded soft-fork", where your version will only check P2PK, and accept everything else as valid. Anyone has a minimalistic, C++ Implementation of the original bitcoin protocol? I was trying to do something like that, but it is not yet ready. What exactly are you trying to do and what parts of the libraries do you find non-minimalistic and why is that a problem? I guess it is about recreating the process of making Bitcoin from scratch. Because between empty main function, and the first released version, there are definitely more points, where you have "half-baked coin", and where you can learn, why things are set, the way they are. For example: the bare minimum doesn't need any Script. The bare minimum doesn't need versioning. And there are many other things, which you can remove, and still cover everything, what is described in the whitepaper. So, to sum up: start from SHA-256 implementation, which will give you just "something mineable, without any public keys". Then, add public keys support. And then, you will have the bare minimum. And if you want to test some basic concepts, then you can even downgrade it into SHA-1 with secp160k1, or even CRC-32 with some 32-bit elliptic curve, if you want some weaker test network. This is the most reasonable approach in my opinion
|
|
|
|
|
|