Skip to content

Instantly share code, notes, and snippets.

View SomberNight's full-sized avatar

ghost43 SomberNight

View GitHub Profile
@SomberNight
SomberNight / get_xpub_from_unsigned_raw_tx.py
Created December 11, 2017 19:55
Electrum: Retrieve xpub from unsigned raw tx
#!/usr/bin/env python3
# tested with electrum 3.0.2
#import lib as electrum
import electrum
unsigned_raw_tx = '0100000001c3152b4707eaf16f068252d50425a3cedb0d207f922099c616f1ebcdd130e811000000005701ff4c53ff0488b21e0000000000000000003a6ac92f44bf918a9ed289b207b5b61a488ea9e04ea3dffd5acf18952fb0a1bd03edbbe79975e4758645e8ecc08a0c1dba2493806edf7b5569e3b1db4d5087a6e500000200fdffffff0240420f00000000001976a914b5d5cddb29e97ce5c0885de7cd7a21397ceba4c788ac64d73c00000000001976a91438ad3c4c411410b49fb9ad46d936d08da76708f388acad241300'
tx = electrum.transaction.Transaction(unsigned_raw_tx)

Keybase proof

I hereby claim:

  • I am SomberNight on github.
  • I am ghost43 (https://keybase.io/ghost43) on keybase.
  • I have a public key whose fingerprint is 4AD6 4339 DFA0 5E20 B3F6 AD51 E7B7 48CD AF5E 5ED9

To claim this, I am signing this object:

Instructions for retrieving your wallet files from Android.

Warnings:

  • deleting the Android app deletes the wallet files
  • rooting your phone might format userspace, hence delete the wallet files

Below procedure has been tested on

  • an unrooted phone running Android 8.0; Electrum version 3.0.2.0 from Google Play
  • an unrooted phone running Android 8.1; Electrum version 3.1.3.0 from Google Play
@SomberNight
SomberNight / bruteforce_pw.py
Created June 16, 2018 02:30
Electrum Android wallet file: bruteforce 6-digit PIN
# note: for good perfomance, have pycryptodome installed
# (about 20x faster than pyaes for this).
# for ref, it takes about 60 seconds to scan the whole domain for me with pycryptodome.
import electrum
from electrum.wallet import Wallet
from electrum.storage import WalletStorage
storage = WalletStorage('path_to_wallet_file')
wallet = Wallet(storage)
@SomberNight
SomberNight / xpub_to_ypub.py
Last active July 10, 2018 15:31
convert xpub to ypub
from electrum import bitcoin
xpub1 = 'xpub661MyMwAqRbcEcF8odLPZvkWA3xi9ptJqzfzzFFmvNcRtnGb2wzKgVCNN8i1uAwa6kwXLgG7atobaSoExfhpxDfuQp3FfSKPWcocLxKJyk9'
xtype, depth, fingerprint, child_number, c, K_or_k = bitcoin.deserialize_xkey(xpub1, False)
xpub2 = bitcoin.serialize_xpub('p2wpkh-p2sh', c, K_or_k, depth, fingerprint, child_number)
print(xpub2)
@SomberNight
SomberNight / taskgroup_wait_example.py
Last active September 8, 2018 15:05
TaskGroup wait example
import asyncio
from aiorpcx import TaskGroup, timeout_after
async def main():
print("main entered")
try:
async with TaskGroup() as group:
await group.spawn(forever())
# if we spawn a task to run "g", we will finish:
await group.spawn(g())
@SomberNight
SomberNight / electrumpro_keystore.py
Created May 8, 2018 08:55
decompiled keystore.py from ElectrumPro 4.0.2 scam
# uncompyle6 version 3.1.3
# Python bytecode 3.5 (3351)
# Decompiled from: Python 3.5.3 (default, Jan 19 2017, 14:11:04)
# [GCC 6.3.0 20170118]
# Embedded file name: site-packages\electrum-4.0.2-py3.5.egg\electrum\keystore.py
import base64, random, threading, requests, time
from unicodedata import normalize
from . import bitcoin
from .bitcoin import *
from . import constants
@SomberNight
SomberNight / ledger_dongle.py
Last active December 11, 2018 20:05
ledger dongle from electrum qt
# get access to ledger dongle object from electrum qt context
def get_dongle():
plugin_mgr = window.gui_object.plugins
plugin = plugin_mgr.get_plugin("ledger")
devices = plugin_mgr.device_manager.scan_devices()
dongle = None
for device in devices:
if device.product_key not in plugin.DEVICE_IDS:
@SomberNight
SomberNight / derive_address.py
Created January 25, 2019 14:38
electrum derive_address example
from electrum import bitcoin
from electrum import keystore
ks = keystore.from_xpub("zpub6nsHdRuY92FsMKdbn9BfjBCG6X8pyhCibNP6uDvpnw2cyrVhecvHRMa3Ne8kdJZxjxgwnpbHLkcR4bfnhHy6auHPJyDTQ3kianeuVLdkCYQ")
pubkey = ks.derive_pubkey(for_change=False, n=0)
addr = bitcoin.pubkey_to_address('p2wpkh', pubkey)
print(addr)
@SomberNight
SomberNight / build.sh
Created June 26, 2019 02:06 — forked from elpaso/build.sh
Build script for Qt5 in debug mode with SIP bindings and PyQt5 QWT and QScintilla
#!/bin/bash
############################################################
# This script builds Qt5, QScintilla and qwt with
# sip Python bindings.
# Tested and developed on xenial 64bit
# All other dev packages required to build QGIS need
# to be installed with apt
# Qt is built in debug mode.
set -e