Skip to content

Instantly share code, notes, and snippets.

@danielabrozzoni
danielabrozzoni / spiegazione.md
Last active January 18, 2024 23:14
Spendere Bitcoin dal terminale usando bitcoin-cli

Spendere Bitcoin dal terminale usando bitcoin-cli

In questo (si spera corto) tutorial proveremo a spendere alcuni Bitcoin utilizzando bitcoin-cli.

In questo tutorial uso la rete signet, ma ovviamente gli stessi passaggi funzionano anche per mainnet, testnet, e regtest.

Prerequisiti:

  • bitcoind avviato e syncato
  • Avere alcuni sats da spendere con bitcoin-cli (potete ottenerli con un faucet se siete su signet/testnet, o minando su regtest)
@danielabrozzoni
danielabrozzoni / main.rs
Created July 4, 2023 22:14
Cubo+ BDK example
use bdk::{Wallet, SyncOptions, FeeRate, SignOptions};
use bdk::wallet::AddressIndex;
use bdk::database::MemoryDatabase;
use bdk::blockchain::ElectrumBlockchain;
use bdk::electrum_client::Client;
use bdk::bitcoin::{self, Address};
use std::str::FromStr;
use bdk::blockchain::Blockchain;
fn main() -> Result<(), bdk::Error> {

Planning module

  • Right now BDK has a policy module: when creating a transaction I can specify which policy I want to use to spend my utxos
    • or(and(A,B), C): either A+B or C by themselves
    • when I create the transaction, I decide if I want to spend with the A+B path, or if I want to spend with the C path
    • UX is not great, specifying which policy to use can be difficult
  • Replacing the policy module with this planning idea
  • Instead of specifying the policy I want to use to spend, I specify the “assets” (keys, timelocks, hash preimages) I have/want to use, and the planning module will find out the cheapest way for me to spend my coins
    • or(and(A,B),C), I tell the planning module that I own the keys A, B, C
      • The planning module will tell me to spend using the key C -> it’s cheaper than using A+B
    • or(A, and(B, older(10))), I tell the planning module I only have B
daemon = false
log_level = "trace"
data_dir = "./data/coordinatord_data"
postgres_uri = "postgresql://revault:revault@localhost/postgres"
managers = [
# REPLACE ME
"60eefc8ffef57c9e3d36d68a7ffdde21b10d3ec5cdcfa9e9a5e24349ef51cc0a",
]
@danielabrozzoni
danielabrozzoni / main.py
Created May 4, 2020 11:00
Given n, find k such that first n digits of 2^k == first n digits of 5^k == first n digits of sqrt(10)
digits = "31622776601683795"
def find(n):
k = 0
last_2 = 1
last_5 = 1
while True:
if first_n_digits(last_2, n) == digits[:n] \
and first_n_digits(last_5, n) == digits[:n]:
return k
@danielabrozzoni
danielabrozzoni / compton.conf
Last active March 15, 2020 20:24
Dell XPS 7390 compton configuration
backend = "glx";
glx-no-stencil = true;
paint-on-overlay = true;
vsync = "opengl-swc";
syntax on
set nocompatible " be iMproved, required
filetype indent on
set expandtab " use spaces
set shiftwidth=4
set softtabstop=4
set autoindent
set smartindent
set relativenumber
set number
@danielabrozzoni
danielabrozzoni / i3-config
Last active March 4, 2021 12:09
default i3 config + i3lock as screen locker + shortcuts for lock/logout/shutdown/reboot + status bar + compton
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout some time, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see https://i3wm.org/docs/userguide.html for a complete reference!