Struct KeyPool

Source
pub struct KeyPool { /* private fields */ }
Expand description

| A key from a CWallet’s keypool | | The wallet holds one (for pre HD-split wallets) | or several keypools. These are sets of keys | that have not yet been used to provide | addresses or receive change. | | The Bitcoin Core wallet was originally | a collection of unrelated private keys with | their associated addresses. If a non-HD wallet | generated a key/address, gave that address out | and then restored a backup from before that | key’s generation, then any funds sent to that | address would be lost definitively. | | The keypool was implemented to avoid this | scenario (commit: 10384941). The wallet would | generate a set of keys (100 by default). When | a new public key was required, either to give | out as an address or to use in a change output, | it would be drawn from the keypool. The keypool | would then be topped up to maintain 100 | keys. This ensured that as long as the wallet | hadn’t used more than 100 keys since the | previous backup, all funds would be safe, since | a restored wallet would be able to scan for all | owned addresses. | | A keypool also allowed encrypted wallets to | give out addresses without having to be | decrypted to generate a new private key. | | With the introduction of HD wallets (commit: | f1902510), the keypool essentially became an | address look-ahead pool. Restoring old backups | can no longer definitively lose funds as long | as the addresses used were from the wallet’s HD | seed (since all private keys can be rederived | from the seed). However, if many addresses | were used since the backup, then the wallet may | not know how far ahead in the HD chain to look | for its addresses. The keypool is used to | implement a ‘gap limit’. The keypool maintains | a set of keys (by default 1000) ahead of the | last used key and scans for the addresses of | those keys. This avoids the risk of not seeing | transactions involving the wallet’s addresses, | or of re-using the same address. In the | unlikely case where none of the addresses in | the gap limit are used on-chain, the | look-ahead will not be incremented to keep | a constant size and addresses beyond this range | will not be detected by an old backup. For this | reason, it is not recommended to decrease | keypool size lower than default value. | | The HD-split wallet feature added a second | keypool (commit: 02592f4c). There is an | external keypool (for addresses to hand out) | and an internal keypool (for change addresses). | | Keypool keys are stored in the | wallet/keystore’s keymap. The keypool data is | stored as sets of indexes in the wallet | (setInternalKeyPool, setExternalKeyPool and | set_pre_split_keypool), and a map from the key | to the index (m_pool_key_to_index). The | CKeyPool object is used to | serialize/deserialize the pool data to/from the | database.

Implementations§

Source§

impl KeyPool

Source

pub fn new(vch_pub_key_in: &PubKey, internal_in: bool) -> Self

Source

pub fn serialize<Stream>(&self, s: &mut Stream)

Source

pub fn unserialize<Stream>(&mut self, s: &mut Stream)

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T, U> CastInto<U> for T
where U: CastFrom<T>,

Source§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> StaticUpcast<T> for T

Source§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V