What is the relationship of ckeypool and ckeystore?

0

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

yrm23

Posted 2018-09-24T13:14:16.543

Reputation: 41

Answers

1

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.

Andrew Chow

Posted 2018-09-24T13:14:16.543

Reputation: 40 910

Thanks. If the keypool store only store public keys, where is the related private keys located and how the pair related?yrm23 2018-09-24T13:43:07.040

If refill keypool, where the new private keys go?yrm23 2018-09-24T13:53:40.990

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 2018-09-24T14:05:11.700

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 2018-09-24T14:13:13.477

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 2018-09-24T15:17:11.753