Skip to content

Instantly share code, notes, and snippets.

@kdmukai
kdmukai / Flow-based test pseudocode changes
Last active April 14, 2023 13:33
SeedSigner main loop pseudocode to demonstrate changes in the Flow-based testing PR #339
Controller:
create initial Destination (** configurable; MainMenuView by default)
infinite while loop:
next_destination.run()
Destination.run():
** Destination._instantiate_view():
instantiate View
** Destination._run_view():
View.run():
do some setup
@kdmukai
kdmukai / README.md
Last active March 18, 2023 02:48
Creating a custom SeedSigner SD card image

Configure the SD card on a dev SeedSigner.

Bring the SD card over to a Mac and run:

diskutil list

and identify the name of the SD card (e.g. /dev/disk4).

Unmount the SD card and run dd to copy its contents:

@kdmukai
kdmukai / README.md
Last active February 12, 2024 18:38
Configuring a Raspberry Pi to relay an ethernet-connected device over wifi to a Tailscale exit node

The problem

You want a device, let's call it a BRoku, to route its traffic through your home IP even though it's actually physically located in someone else's house on their wifi network.

The solution

  • BRoku connects over wired ethernet directly to a Raspberry Pi (3B+ or 4).
  • Raspi connects to local wifi.
  • Raspi's traffic is routed to a Tailscale exit node (potentially another Raspi) in your home LAN.
@kdmukai
kdmukai / README.md
Last active February 2, 2023 00:45
Airgapped NIP-26 Nostr key delegation via SeedSigner
@kdmukai
kdmukai / README.md
Last active September 2, 2023 21:08
Airgapped Nostr event signing via SeedSigner
@kdmukai
kdmukai / README.md
Last active February 2, 2023 00:43
Generate a new airgapped Nostr key via SeedSigner

Generate a new airgapped Nostr key via SeedSigner

Create a new key with your own entropy, save it as a standard bitcoin BIP-39 mnemonic phrase and/or SeedQR, then export for use in Nostr.


Demo of Keith's experimental Nostr integration.

Other posts:

  • Generate a new airgapped Nostr key via SeedSigner
@kdmukai
kdmukai / nostr_delegation.py
Last active December 20, 2022 16:48
Trying (and failing) to reproduce Nostr NIP-26 delegation signature
"""
see: https://github.com/nostr-protocol/nips/blob/master/26.md
"""
import hashlib
from binascii import unhexlify
from embit import bip39
from embit.bip32 import HDKey
from embit.ec import PrivateKey
@kdmukai
kdmukai / wallet_basic.py
Created December 5, 2022 18:29
Snippet: edits to wallet_basic.py to accommodate new, lower maxfeerate default
# check if we can list zero value tx as available coins
# 1. create raw_tx
# 2. hex-changed one output to 0.0
# 3. sign and send
# 4. check if recipient (node0) can list the zero value tx
usp = self.nodes[1].listunspent(query_options={'minimumAmount': '49.998'})[0]
inputs = [{"txid": usp['txid'], "vout": usp['vout']}]
test_amount = Decimal("0.00001000") # this output amount will be zeroed and thereby added to the fee
fee = Decimal("0.00000400") # start with a modest fee so our final fee won't exceed default maxfeerate
outputs = {self.nodes[1].getnewaddress(): usp['amount'] - test_amount - fee, self.nodes[0].getnewaddress(): test_amount}
@kdmukai
kdmukai / generate_mnemonic_and_addr.py
Last active November 4, 2022 17:45
Generate a 12-word mnemonic and first receive addr
from embit import bip32, bip39, script
from embit.slip39 import secure_randint
from embit.wordlists.bip39 import WORDLIST
for i in range(0, 100):
mnemonic = []
for j in range(0, 11):
# note: `secure_randint` is inclusive of the end of the range
mnemonic.append(WORDLIST[secure_randint(0, 2047)])
mnemonic.append(WORDLIST[0])
@kdmukai
kdmukai / op_return.py
Last active June 13, 2023 00:24
Adding an OP_RETURN output to a psbt using `embit`
"""
dependency: pip install embit
"""
from embit import compact
from embit.psbt import PSBT, OutputScope
from embit.script import Script
class OPCODES:
OP_RETURN = 106
OP_PUSHDATA1 = 76