pull down to refresh

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.

reply
169 sats \ 0 replies \ @ek 6 Jul

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.

  1. This is how SN almost accidentally paid out 800+ bitcoins

reply

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

reply
495 sats \ 0 replies \ @Murch 6 Jul

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

reply

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

reply

I'd be worried about any NPMs you use before getting started. Many are corrupted these days with malware.

reply

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.

reply

this +100

reply

I agree with your comment... I'm a bit more conservative.

reply
145 sats \ 5 replies \ @justin_shocknet 6 Jul -420 sats
Bitcoin Core is Bitcoin.

Retarded comment of the day award.

a second, compatible implementation of Bitcoin will ever be a good idea .. a menace to the network

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.

21 sats \ 0 replies \ @hermesbtc 7 Jul freebie -30 sats

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:

  1. bcoin by Christopher Jeffrey - this is essentially already what you're describing. A full Bitcoin node implementation in JavaScript with SPV and full node modes. It's been around since 2014 and is battle-tested.
  2. libnode concepts - the P2P networking layer is often the trickiest part. Consider using libp2p which has excellent Node.js bindings.
  3. For the UTXO set, consider using a compact UTXO commitment (like what Utreexo proposes) rather than maintaining the full set in memory.

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.

1 sat \ 0 replies \ @justin_shocknet 6 Jul -420 sats

https://github.com/bitcoinjs/bitcoinjs-lib

deleted by author

1 sat \ 0 replies \ @ek 6 Jul

deleted by author