jmwallet.wallet.bip32
jmwallet.wallet.bip32
BIP32 HD key derivation for JoinMarket wallets. Implements BIP84 (Native SegWit) derivation paths.
Attributes
VPRV_TESTNET = bytes.fromhex('045F18BC')
module-attribute
VPUB_TESTNET = bytes.fromhex('045F1CF6')
module-attribute
XPRV_MAINNET = bytes.fromhex('0488ADE4')
module-attribute
XPRV_TESTNET = bytes.fromhex('04358394')
module-attribute
XPUB_MAINNET = bytes.fromhex('0488B21E')
module-attribute
XPUB_TESTNET = bytes.fromhex('043587CF')
module-attribute
ZPRV_MAINNET = bytes.fromhex('04B2430C')
module-attribute
ZPUB_MAINNET = bytes.fromhex('04B24746')
module-attribute
__all__ = ['HDKey', 'mnemonic_to_seed']
module-attribute
Classes
HDKey
Hierarchical Deterministic Key for Bitcoin. Implements BIP32 derivation.
Source code in jmwallet/src/jmwallet/wallet/bip32.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | |
Attributes
chain_code = chain_code
instance-attribute
child_number = child_number
instance-attribute
depth = depth
instance-attribute
fingerprint: bytes
property
Get the fingerprint of this key (first 4 bytes of hash160 of public key).
parent_fingerprint = parent_fingerprint
instance-attribute
private_key: PrivateKey
property
Return the coincurve PrivateKey instance.
public_key: PublicKey
property
Return the coincurve PublicKey instance.
Functions
__init__(private_key: PrivateKey, chain_code: bytes, depth: int = 0, parent_fingerprint: bytes = b'\x00\x00\x00\x00', child_number: int = 0)
Source code in jmwallet/src/jmwallet/wallet/bip32.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
derive(path: str) -> HDKey
Derive child key from path notation (e.g., "m/84'/0'/0'/0/0") ' indicates hardened derivation
Source code in jmwallet/src/jmwallet/wallet/bip32.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
from_seed(seed: bytes) -> HDKey
classmethod
Create master HD key from seed
Source code in jmwallet/src/jmwallet/wallet/bip32.py
71 72 73 74 75 76 77 78 79 80 | |
get_address(network: str = 'mainnet') -> str
Get P2WPKH (Native SegWit) address for this key
Source code in jmwallet/src/jmwallet/wallet/bip32.py
150 151 152 153 154 155 | |
get_private_key_bytes() -> bytes
Get private key as 32 bytes
Source code in jmwallet/src/jmwallet/wallet/bip32.py
142 143 144 | |
get_public_key_bytes(compressed: bool = True) -> bytes
Get public key bytes
Source code in jmwallet/src/jmwallet/wallet/bip32.py
146 147 148 | |
get_xprv(network: str = 'mainnet') -> str
Serialize the private key as an extended private key (xprv/tprv).
Args: network: "mainnet" for xprv, "testnet"/"regtest" for tprv
Returns: Base58Check-encoded extended private key
Source code in jmwallet/src/jmwallet/wallet/bip32.py
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | |
get_xpub(network: str = 'mainnet') -> str
Serialize the public key as an extended public key (xpub/tpub).
This produces a standard BIP32 xpub that can be used in Bitcoin Core descriptors. The descriptor wrapper (wpkh, wsh, etc.) determines the actual address type.
Args: network: "mainnet" for xpub, "testnet"/"regtest" for tpub
Returns: Base58Check-encoded extended public key (xpub or tpub)
Source code in jmwallet/src/jmwallet/wallet/bip32.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | |
get_zpub(network: str = 'mainnet') -> str
Serialize the public key as a BIP84 extended public key (zpub/vpub).
This produces a BIP84-compliant extended public key for native segwit wallets. zpub/vpub explicitly indicates the key is intended for P2WPKH addresses.
Args: network: "mainnet" for zpub, "testnet"/"regtest" for vpub
Returns: Base58Check-encoded extended public key (zpub or vpub)
Source code in jmwallet/src/jmwallet/wallet/bip32.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | |
sign(message: bytes) -> bytes
Sign a message with this key (uses SHA256 hashing).
Source code in jmwallet/src/jmwallet/wallet/bip32.py
157 158 159 | |
Functions
mnemonic_to_seed(mnemonic: str, passphrase: str = '') -> bytes
Convert BIP39 mnemonic to 64-byte seed using PBKDF2-HMAC-SHA512.
This follows the BIP39 specification for seed generation.
Args: mnemonic: Space-separated mnemonic words passphrase: Optional BIP39 passphrase (default empty)
Returns: 64-byte seed
Source code in jmcore/src/jmcore/crypto.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |