Skip to content

Instantly share code, notes, and snippets.

@HeXenCore
HeXenCore / seed2keys.py
Created May 23, 2021 09:08 — forked from romanz/seed2keys.py
Creates public and private keys from Electrum 2.0 seed
#!/usr/bin/env python
''' Run from "electrum/lib" directory.
'''
import bitcoin, mnemonic
mn = raw_input("Enter mnemonic (13 words)").strip()
s = mnemonic.Mnemonic.mnemonic_to_seed(mn, '')
print 'seed:', repr(s)
xprv, xpub = bitcoin.bip32_root(s)
@HeXenCore
HeXenCore / seed2keys.py
Created May 23, 2021 09:08 — forked from RCasatta/seed2keys.py
Creates public and private keys from Electrum 2.0 seed
#!/usr/bin/env python
''' Run from "electrum/lib" directory.
ThomaxV started a discussion on https://bitcointalk.org/index.php?topic=274182.msg2939599#msg2939599
about changing the HD derivation logic in electrum 2. The below post:
http://bitcoin.stackexchange.com/questions/37013/how-to-import-a-hd-wallet-from-an-extended-private-key
confirms that the format is actually m/c/i (and not m/44'/0'/a'/c/i)
so I have altered https://gist.github.com/romanz/4b32782bfc0ff4984713 accordingly:
tested to work with keys/addresses exported from electrum 2.7.0
note Electrum has a "gap limit" of 20, so loop @ level "c" to get the next 20 addresses
'''
@HeXenCore
HeXenCore / btc_scan.py
Created May 23, 2021 09:35 — forked from Nikolaj-K/btc_scan.py
Matching generated private keys against the funded ledger
"""
Script discussed in the video:
https://youtu.be/i2QaBjCvMN4
How to steal all bitcoin (on average 10^-60 of it per day)
This script checks whether a given Bitcoin private key (int) has
funds using a CSV snapshot of the blockchain ledger.
This ordered CSV of currently funded addresses can be downloaded from:
http://addresses.loyce.club/
@HeXenCore
HeXenCore / bitcoin_keys_gen.py
Created May 23, 2021 10:34 — forked from gerbill/bitcoin_keys_gen.py
Generate BitCoin Private Key, Public Key and Addresses for Main Net and Test Net
"""
Required modules:
ecdsa (pip install ecdsa)
base58 (pip install base58)
"""
import ecdsa
import base58
import hashlib
from hashlib import sha256
# https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses
# http://gobittest.appspot.com
# -*- coding: utf-8 -*-
import hashlib
import base58
prefix = "04"
version_main = "00"
@HeXenCore
HeXenCore / easy-litecoin-address-from-public-key.py
Created May 26, 2021 08:47 — forked from circulosmeos/easy-litecoin-address-from-public-key.py
Easily generate the litecoin address from the public key using Python (compatible with Python 2 and 3)
#!/usr/bin/env python
# patched from https://bitcoin.stackexchange.com/questions/56923/is-this-how-to-generate-a-bitcoin-address-with-python
# https://en.bitcoin.it/wiki/Protocol_documentation#Addresses
# Adapted to litecoin, following https://bitcoin.stackexchange.com/questions/65282/how-is-a-litecoin-address-generated
import hashlib
import base58
# ECDSA bitcoin Public Key
pubkey = '0450863ad64a87ae8a2fe83c1af1a8403cb53f53e486d8511dad8a04887e5b23522cd470243453a299fa9e77237716103abc11a1df38855ed6f2ee187e9c582ba6'
@HeXenCore
HeXenCore / ecdsa_to_bitocin_addy.py
Created May 26, 2021 09:09 — forked from nealmcb/ecdsa_to_bitocin_addy.py
Calculate Bitcoin address corresponding to given ECDSA private key. Handy for verifying document timestamps provided by OriginStamp.org.
#!/usr/bin/env python
"""Calculate Bitcoin address corresponding to given ECDSA private key.
Handy for verifying document timestamps provided by OriginStamp.org.
Usage: ecdsa_to_bitocin_addy.py ecdsa_private_key # that's a 64-character hex string
Prerequisite:
pip install ecdsa
@HeXenCore
HeXenCore / bitcoin.py
Created May 26, 2021 09:15 — forked from HelloZeroNet/bitcoin.py
Bitcoin signature signing and verficiation using coincurve
import hashlib
import struct
from coincurve import PrivateKey, PublicKey
from base58 import b58encode_check, b58decode_check
from hmac import compare_digest
RECID_MIN = 0
RECID_MAX = 3
RECID_UNCOMPR = 27
LEN_COMPACT_SIG = 65
#https://en.bitcoin.it/wiki/Wallet_import_format
import os, binascii, hashlib, base58, ecdsa
#Input params
#random_number - 32 byte random number string ex:b'-\xf2L~\xe1Gq\xeeN\x8e\x97La$\xc7\xbb\x05\xaf\x05\xf9^\x00\xd5\x19o`@Q\x02\xc18\xa1'
#If no random number input, one is automatically generated
#Output params - Private Wallet Key, Public Address
def create_wallet(random_number=""):
def ripemd160(x):
@HeXenCore
HeXenCore / address.py
Created May 26, 2021 11:24 — forked from chenxu2048/address.py
bitcoin and ethereum address
import hashlib
from ecdsa import SECP256k1, SigningKey
from sha3 import keccak_256
import sys
import binascii
BASE58TABLE = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
def from_bytes (data, big_endian = False):
if isinstance(data, str):