Skip to content

Instantly share code, notes, and snippets.

View arminsabouri's full-sized avatar
🎯
Focusing

Armin Sabouri arminsabouri

🎯
Focusing
View GitHub Profile
@arminsabouri
arminsabouri / README.md
Last active June 4, 2023 02:07
Ledger 2.1.0 Psbtv2 Conversion

LedgerHQ has laid the foundation for a PSBTv2 library, but it currently lacks some features and has issues with de/serialization. A complete Psbtv2 class can be found in my fork.

It is suggested to use PSBTv0 for all operations and only convert to v2 when communicating with the Ledger device. This can be achieved through utilizing BitcoinJS's excellent PSBTv0 library and utilizing an adapter function from v0 -> v2.

For exmaple if your're working with p2sh(p2wsh) script types, you might have something like:

export function convertPsbtv0ToV2(psbtv0: Psbt): PsbtV2 {
  const psbtv2 = new PsbtV2()

Start by using nix

Run nix-shell in the root directory

Start the virtual env using poetry shell

Run poetry shell in the root directory

We'll be building and running the core firmware

cd core make build_unix

Run the emulator

./emu.py If you are making changes to any python source code you shouldn't have to run the make command again.

@arminsabouri
arminsabouri / main.py
Last active November 17, 2022 21:15
Parse Xpub Components
def to_hd_node(base58DecodedXpub):
try:
return {
'version': base58DecodedXpub[0:8],
'depth': base58DecodedXpub[8:10],
'pfp': base58DecodedXpub[10:18],
'index': base58DecodedXpub[18:26],
'chaincode': base58DecodedXpub[26:90],
'key': base58DecodedXpub[90:156],
'checksum': base58DecodedXpub[156:164]
@arminsabouri
arminsabouri / mu.sh
Created July 12, 2022 00:43
I take no credit. SSH tmux multiplexer
#!/usr/bin/env bash
set -exo pipefail
decs_insts=$(aws --region us-east-1 ec2 describe-instances)
ssh_list=($(echo $decs_insts | jq -r --arg match "${1}" '.Reservations[]|select(.Instances[]|select((.Tags[]|select(.Key=="Name")|.Value)|match($match)))|select(.Instances[]|select(.State|select(.Name=="running")))|.Instances[].PrivateIpAddress' | tr '\r\n' ' '))
split_list=()
for ssh_entry in "${ssh_list[@]:1}"; do