Im not a professional engineer, just a pleb, but I've been getting more into Bitcoin dev lately and have been vibe coding a few projects in nodejs and it's honestly gone better than I expected. It's got me thinking about trying something a little more ambitious.
Basically I've been wondering... why isn't there a Bitcoin node written in nodejs?
I know Core is C++ and Knots is based on Core too, but nodejs seems like it'd be a pretty good fit. Besides already knowing it, I also can't help but think it's kind of funny that it's literally called NODEjs lol.
I know people always say C++ is faster, but hardware has gotten a lot better since Bitcoin started and nodejs can handle some pretty crazy workloads these days. Plus the developer experience is just way better in my opinion and there are way more JavaScript developers than C++ developers.
I'm not saying it'd replace Core or anything overnight, but I don't really see why it couldn't eventually become another client people could choose to run if it worked well and a strong open source community developed around it.
Am I missing something obvious here or has nobody really taken a serious shot at this? Just looking for feedback before I start putting a lot of time into it.
Best way to learn is to build. Go for it! Will it be safe? Probably not so don't expect anyone to take early work seriously, but it would be a fun and interesting experiment. As others have mentioned, bcoin was the first attempt, but it has sat untouched for ~3 years. Good place to dig in though.
I wouldn’t want to build something as important as a bitcoin node in a dynamic, interpreted language. There’s no compiler to tell you your code doesn’t even pass sanity checks, like using a string where you only expect numbers.[1]
A JavaScript interpreter will happily run your code until it crashes because of a
ReferenceError(you used a variable you didn’t declare).That doesn’t mean compiled languages don’t have runtime errors, just less obvious ones.
This is how SN almost accidentally paid out 800+ bitcoins ↩
Obvious thing you're missing: if you have no idea what you're doing (you don't, or you'd not post this post) then it is better for someone else that has no idea what they are doing to let an LLM vibe code their own node software rather than using whatever you vibe coded. After all, then they're responsible for the mess, not you, and as a bonus, the cost of telling a bot to greenfield build something is lower than trying to figure out everything someone else's poor prompts messed up.
@remindme in 5 years so that I can be proven wrong about this
A Bitcoin full node project in NodeJS already exists, although it looks like nobody is working on it anymore: https://github.com/bcoin-org/bcoin
I thinking about food and eating and eating the food in bed and missing my mouth and taking seroquel and sleeping in food then dreaming about all this in a different spastic order
I'd be worried about any NPMs you use before getting started. Many are corrupted these days with malware.
Don't -- This adds very little except fork risk that puts your users money at risk. This applies to Knots too -- Don't touch it. Its a menace.
Bitcoin Core is Bitcoin.
"I don't believe a second, compatible implementation of Bitcoin will ever be a good idea. So much of the design depends on all nodes getting exactly identical results in lockstep that a second implementation would be a menace to the network. The MIT license is compatible with all other licenses and commercial uses, so there is no need to rewrite it from a licensing standpoint." -- Satoshi, 2010
There is very little reason to do this (beyond your education in the protocol), and many reasons not to.
this +100
I agree with your comment... I'm a bit more conservative.
Retarded comment of the day award.
Literally every new version of Core is a second compatible implementation, relative to older versions pre-existing on the network.
If Core pushes a bad update, it effects much of the network in a uniquely dangerous way. A diverse network of many implementations don't carry this risk as damage is isolated to the users of that implementation and not the network as a whole.
The same systems that keep continuity from one Core version to the next applies equally to new implementations, test vectors. A solved problem.
BTCD has been reliable for years and powers most of the Lightning Network.
Afaik Libbitcoin consensus has too been stable for years.
Since every new Core version is the only potential menace to the network at large, it's far better there be more implementations, causing more frequent issues, as a trade-off for limiting the damage by some future Core version going wrong.
If you're going to build a Bitcoin node client in Node.js, I'd strongly recommend looking at existing implementations before starting from scratch:
The main challenge with any Node.js Bitcoin implementation is garbage collection pauses during IBD. V8's GC can cause noticeable latency spikes. Rust-based implementations like Bitcoin Core's C++ don't have this issue. That said, for a learning project or specific use cases (like a lightweight SPV client), Node.js is perfectly fine.
What's your specific use case? That would help determine whether a new implementation makes sense vs. contributing to bcoin.
https://github.com/bitcoinjs/bitcoinjs-lib
deleted by author
deleted by author