In the source, there are ckeypool and skeystore. I wonder what is the relationship of them and why need both.


CKeyStore is a class for storing keys. It provides the functions for storing and retrieving keys.

CKeyPool is a class for a key that is in the keypool. It is specifically a database object for storing a public key and its location inside of the keypool.

CKeyStore and CKeyPool are two different things and are largely unrelated.

The keypool is the set of keys that are unused. It is separate from CKeyStore and has an entirely different purpose. CKeyPool objects are specific to a CWallet which is a subclass of CKeyStore.

  • Thanks. If the keypool store only store public keys, where is the related private keys located and how the pair related?
    – yrm23
    Sep 24 '18 at 13:43
  • If refill keypool, where the new private keys go?
    – yrm23
    Sep 24 '18 at 13:53
  • The private keys, along with their public keys, are stored in the keystore. When new keys are generated, they private keys and their public keys are added to the keystore. At the same time, public keys are added to the keypool. There are other information that is stored to.
    – Andrew Chow
    Sep 24 '18 at 14:05
  • One more thing, I am not sure, when new keys are generated, the public keys are added to both keystore and keypool, or just added to the keystore's keypool only?
    – yrm23
    Sep 24 '18 at 14:13
  • A keystore does not have a keypool. The public keys are added to many different places, including the keystore and the keypool. Public keys are used as identifiers for many things, so they end up being duplicated in many different places.
    – Andrew Chow
    Sep 24 '18 at 15:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.