Skip to content

Commit

Permalink
hack: trating all imported privatekey as non-watchonly
Browse files Browse the repository at this point in the history
This is to unblock partner integration.

More comprehensive solution will be available soon.
  • Loading branch information
roylee17 committed Aug 8, 2022
1 parent 46f4df5 commit 893a820
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions waddrmgr/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const (
// exceed the hardened child range of extended keys and it provides a
// reserved account at the top of the range for supporting imported
// addresses.
MaxAccountNum = hdkeychain.HardenedKeyStart - 2 // 2^31 - 2
MaxAccountNum = hdkeychain.HardenedKeyStart - 3 // 2^31 - 3

// MaxAddressesPerAccount is the maximum allowed number of addresses
// per account number. This value is based on the limitation of the
Expand All @@ -37,11 +37,21 @@ const (
// addresses. This is useful since normal accounts are derived from
// the root hierarchical deterministic key and imported addresses do
// not fit into that model.
ImportedAddrAccount = MaxAccountNum + 1 // 2^31 - 1
ImportedAddrAccount = hdkeychain.HardenedKeyStart - 1 // 2^31 - 1

// ImportedAddrAccountName is the name of the imported account.
ImportedAddrAccountName = "imported"

// ImportedWatchonlyAddrAccount is the account number to use for all
// imported watchonly addresses, such as public keys and addresses.
// This is useful since normal accounts are derived from the root
// hierarchical deterministic key and imported addresses do not fit
// into that model.
ImportedWatchonlyAddrAccount = hdkeychain.HardenedKeyStart - 2 // 2^31 - 2

// ImportedWatchonlyAddrAccountName is the name of the imported watchonly account.
ImportedWatchonlyAddrAccountName = "imported-watchonly"

// DefaultAccountNum is the number of the default account.
DefaultAccountNum = 0

Expand Down Expand Up @@ -415,10 +425,10 @@ func (m *Manager) IsWatchOnlyAccount(ns walletdb.ReadBucket, keyScope KeyScope,
return true, nil
}

// Assume the default imported account has no private keys.
//
// TODO: Actually check whether it does.
if account == ImportedAddrAccount {
return false, nil
}
if account == ImportedWatchonlyAddrAccount {
return true, nil
}

Expand Down

0 comments on commit 893a820

Please sign in to comment.