@danielabrozzoni - MIT Bitcoin Expo 2023
{ Question: how hard is it to build a Bitcoin wallet from scratch? }
{ Building from scratch sounds difficult. Is there something out there that might help us? }
<A> OP_CHECKSIGVERIFY <B> OP_CHECKSIG
and_v(v:pk(A),pk(B))
and(pk(A),pk(B))
{ Where we're at }
let database = SqliteDatabase::new("path...");
let wallet = Wallet::new(
"wpkh([c258d2e4/84h/1h/0h]tpub.../0/*)",
Some("wpkh([c258d2e4/84h/1h/0h]tpub.../1/*)"),
Network::Testnet,
database,
)?;
let blockchain = EsploraBlockchain::from("url...", 50 /* stop_gap */);
wallet.sync(&blockchain, SyncOptions::default())?;
let send_to = Address::from_string("bc1q202rwadss5k6phxjazugjp87ncjmt62szj0ylk")?;
let (psbt, _) = {
let mut builder = wallet.build_tx();
builder
.add_recipient(send_to.script_pubkey(), 50_000)
.enable_rbf()
.current_height(786693)
.fee_rate(FeeRate::from_sat_per_vb(5.0));
builder.finish()?
};
println!("Unsigned PSBT: {}", &psbt);
pub trait WalletSync {
fn wallet_sync<D: BatchDatabase>(
&self,
database: &RefCell<D>,
progress_update: Box<dyn Progress>
) -> Result<(), Error> { ... }
// Other methods omitted for clarity
}
{ Where we're going }
Eventually
Coming soon
I really don't know when
Sorry
Working on it