2023 Feb 02
Hooray, no headache this morning!
Back to trying to build. I think I’ll see how far I get by the end of the week and decide whether I’ll try to make another PR or keep trying to build using LDK.
- I feel like building using LDK at the same time as contributing to LDK is the ideal combo if I can manage the time. It would be cool to just build a phoenix-like self-custodial wallet with LDK + BDK.
Building with LDK
Logging is clean with macros!
Next: get electrs running or use esplora and reimplement getting fee estimates and broadcasting
Helix (idk about other editors) cannot easily let you bounce using LSP stuff in two project directories at the same time, i.e. I tried to have both ldk-sample and my project open and it could only do LSP rendering for one.
- Also you have to actually import or use a file for helix LSP to turn on, i.e. I tried to just put my file in the ldk-sample project directory, but I needed to
mod other_mod;
to use them, which messed up imports and was annoying. Have resorted to just having helix up in separate terminal windows.
- Also you have to actually import or use a file for helix LSP to turn on, i.e. I tried to just put my file in the ldk-sample project directory, but I needed to
Can definitely start doing more review that’s not just public documentation - asking more questions about how something is done or just about the area of a codebase. Should get so at least one more review like this by end of tomorrow.
Pretty fire video on Rust smart pointers - allocating on the heap intelligently. Ideally would like everything to be on the stack because it has a faster access time, however to be on the stack the size of the object must be known at compile time, which is not always the case.
Box - basically just a pointer/borrowed reference to an object. Used for when you have a trait object who’s type can’t be known at compile time, OR just when you need indirection for something like a recursive data type, e.g. self-referential struct
Rc - Reference counter. Used for when you have multiple references to an object allocated on the heap, and don’t want it to go out of scope until all those references are done being used.
Arc - Atomic reference counter. When you need an Rc to be thread-safe.
Finally getting some clarity on how Bitcoin wallets work and how they’re developed.
Electrum is a server and SPV client/wallet. The server is useful to index block data in a way that you can easily retrieve what’s needed for an SPV wallet. electrs is a re-implementation of Electrum server to be able to self host an electrum server with not much more resources than a full node. Blockstream has a fork that’s more powerful and better for public use: Esplora, which includes an HTTP API on top of electrum.
BDK has an electrum client implementation here.
BDK primarily supports electrum and esplora for getting blockchain data
Full node vs SPV wallet: SPV wallets only check that a transaction is included in a block, whereas full nodes enforce consensus no matter what. Main point: both will follow the majority of miners in the case an attacker overpowers the network, however if miners were to change consensus and fork (provided these miners had majority hashpower, say to increase block reward) SPV nodes would blindly follow the consensus change (to add onto this, there could be completely faulty transactions without signatures etc. that light clients don’t check for), whereas full nodes would maintain whatever consensus they were already validating. “It is only reasonably secure to use a lightweight node because most of the Bitcoin [network] uses full nodes.”
Nigiri - spins up bitcoin core and electrum server in a docker container
Dang this is cool, USC students built a bitcoin wallet using BDK in fall 2020
Super distracted today from messages and whatnot, need to ignore my phone tomorrow.