Skip to content

Commit

Permalink
Fix importing xprv
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-kaufman committed Jul 13, 2020
1 parent 729d19b commit 4e0b7ff
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/cryptoadvance/specter/devices/bitcoin_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ def setup_device(self, mnemonic, passphrase, wallet_manager, testnet):
cli = wallet_manager.cli.wallet(wallet_name)
# TODO: Maybe more than 1000? Maybe add mechanism to add more later.
## NOTE: This will work only on the network the device was added, so hot devices should be filtered out by network.
coin = int(testnet)
cli.importmulti([
{ 'desc': AddChecksum('sh(wpkh({}/49h/0h/0h/0/*))'.format(xprv)), 'range': 1000, 'timestamp': 'now'},
{ 'desc': AddChecksum('sh(wpkh({}/49h/0h/0h/1/*))'.format(xprv)), 'range': 1000, 'timestamp': 'now'},
{ 'desc': AddChecksum('wpkh({}/84h/0h/0h/0/*)'.format(xprv)), 'range': 1000, 'timestamp': 'now'},
{ 'desc': AddChecksum('wpkh({}/84h/0h/0h/1/*)'.format(xprv)), 'range': 1000, 'timestamp': 'now'},
{ 'desc': AddChecksum('sh(wpkh({}/48h/0h/0h/1h/0/*))'.format(xprv)), 'range': 1000, 'timestamp': 'now'},
{ 'desc': AddChecksum('sh(wpkh({}/48h/0h/0h/1h/1/*))'.format(xprv)), 'range': 1000, 'timestamp': 'now'},
{ 'desc': AddChecksum('wpkh({}/48h/0h/0h/2h/0/*)'.format(xprv)), 'range': 1000, 'timestamp': 'now'},
{ 'desc': AddChecksum('wpkh({}/48h/0h/0h/2h/1/*)'.format(xprv)), 'range': 1000, 'timestamp': 'now'},
{ 'desc': AddChecksum('sh(wpkh({}/49h/{}h/0h/0/*))'.format(xprv, coin)), 'range': 1000, 'timestamp': 'now'},
{ 'desc': AddChecksum('sh(wpkh({}/49h/{}h/0h/1/*))'.format(xprv, coin)), 'range': 1000, 'timestamp': 'now'},
{ 'desc': AddChecksum('wpkh({}/84h/{}h/0h/0/*)'.format(xprv, coin)), 'range': 1000, 'timestamp': 'now'},
{ 'desc': AddChecksum('wpkh({}/84h/{}h/0h/1/*)'.format(xprv, coin)), 'range': 1000, 'timestamp': 'now'},
{ 'desc': AddChecksum('sh(wpkh({}/48h/{}h/0h/1h/0/*))'.format(xprv, coin)), 'range': 1000, 'timestamp': 'now'},
{ 'desc': AddChecksum('sh(wpkh({}/48h/{}h/0h/1h/1/*))'.format(xprv, coin)), 'range': 1000, 'timestamp': 'now'},
{ 'desc': AddChecksum('wpkh({}/48h/{}h/0h/2h/0/*)'.format(xprv, coin)), 'range': 1000, 'timestamp': 'now'},
{ 'desc': AddChecksum('wpkh({}/48h/{}h/0h/2h/1/*)'.format(xprv, coin)), 'range': 1000, 'timestamp': 'now'},
])
if passphrase:
cli.encryptwallet(passphrase)
Expand Down

0 comments on commit 4e0b7ff

Please sign in to comment.