diff options
| author | mtg0001 <106211915+mtg0001@users.noreply.github.com> | 2026-08-03 15:11:55 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-08-03 15:11:55 -0300 |
| commit | aba252206bf39ac81e6627354062c28fae05b0aa (patch) | |
| tree | 751691f0baaf925c54a2c03f9f02ca87fb29956f /src/bip32.h | |
| parent | 1aee805b232a33484e3db1dc8ea4bfb3f585212e (diff) | |
Activate BIP44 wallet derivation (#124)
* Add BIP32 path derivation foundation
* Add HD wallet schema metadata
* Add provisional BIP44 coin type metadata
* Activate BIP44 wallet derivation
* wallet: scan BIP44 restore depth per branch
* wallet: widen default BIP44 restore lookahead
---------
Co-authored-by: Gilcimar Duarte <ti@gpm.infra>
Diffstat (limited to 'src/bip32.h')
| -rw-r--r-- | src/bip32.h | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/bip32.h b/src/bip32.h index a029444..e9862d5 100644 --- a/src/bip32.h +++ b/src/bip32.h | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | // | 5 | // |
| 6 | // This module is deliberately independent from wallet.dat and GUI code. It is | 6 | // This module is deliberately independent from wallet.dat and GUI code. It is |
| 7 | // the auditable foundation: mnemonic generation/validation, seed derivation, | 7 | // the auditable foundation: mnemonic generation/validation, seed derivation, |
| 8 | // and hardened private child derivation over secp256k1. | 8 | // and private child derivation over secp256k1. |
| 9 | 9 | ||
| 10 | #ifndef BITFLASH_BIP32_H | 10 | #ifndef BITFLASH_BIP32_H |
| 11 | #define BITFLASH_BIP32_H | 11 | #define BITFLASH_BIP32_H |
| @@ -16,6 +16,8 @@ | |||
| 16 | namespace bitflash | 16 | namespace bitflash |
| 17 | { | 17 | { |
| 18 | 18 | ||
| 19 | static const unsigned int BIP32_HARDENED = 0x80000000U; | ||
| 20 | |||
| 19 | struct BIP32PrivateNode | 21 | struct BIP32PrivateNode |
| 20 | { | 22 | { |
| 21 | std::vector<unsigned char> privateKey; // 32-byte scalar | 23 | std::vector<unsigned char> privateKey; // 32-byte scalar |
| @@ -43,6 +45,16 @@ bool BIP32MasterFromSeed(const std::vector<unsigned char>& seed, | |||
| 43 | BIP32PrivateNode& nodeOut, | 45 | BIP32PrivateNode& nodeOut, |
| 44 | std::string& errorOut); | 46 | std::string& errorOut); |
| 45 | 47 | ||
| 48 | bool BIP32DeriveChild(const BIP32PrivateNode& parent, | ||
| 49 | unsigned int childNumber, | ||
| 50 | BIP32PrivateNode& childOut, | ||
| 51 | std::string& errorOut); | ||
| 52 | |||
| 53 | bool BIP32DerivePath(const BIP32PrivateNode& root, | ||
| 54 | const std::vector<unsigned int>& path, | ||
| 55 | BIP32PrivateNode& nodeOut, | ||
| 56 | std::string& errorOut); | ||
| 57 | |||
| 46 | bool BIP32DeriveHardenedChild(const BIP32PrivateNode& parent, | 58 | bool BIP32DeriveHardenedChild(const BIP32PrivateNode& parent, |
| 47 | unsigned int childIndex, | 59 | unsigned int childIndex, |
| 48 | BIP32PrivateNode& childOut, | 60 | BIP32PrivateNode& childOut, |