waddrmgr: create new ScopedKeyManager to manage BIP43 purposes
In this commit, we create a new struct that houses the key derivation, address management, and account management for a particular scope. A scope consists of a (purpose, cointype) tuple. Additionally, each ScopedKeyManager is able to generate internal/external addresses for a specific *address type*. This make rescans easier as for each scope, we know what type of output to look for within the chain. The ScopedKeyManagers have two new primary methods that weren’t previously present within the regular Manager: * DeriveFromKeyPath * NewRawAccount These two methods allow callers a greater degree of control over the way that accounted are created and addressed derived.
This commit is contained in:
parent
f5de14f16b
commit
e3afc8be6a
2 changed files with 1367 additions and 6 deletions
File diff suppressed because it is too large
Load diff
|
@ -11,8 +11,8 @@ import (
|
|||
"github.com/roasbeef/btcwallet/walletdb"
|
||||
)
|
||||
|
||||
// BlockStamp defines a block (by height and a unique hash) and is
|
||||
// used to mark a point in the blockchain that an address manager element is
|
||||
// BlockStamp defines a block (by height and a unique hash) and is used to mark
|
||||
// a point in the blockchain that an address manager element is
|
||||
// synced to.
|
||||
type BlockStamp struct {
|
||||
Height int32
|
||||
|
@ -24,8 +24,8 @@ type BlockStamp struct {
|
|||
// seen blocks as height, as well as the start and current sync block stamps.
|
||||
type syncState struct {
|
||||
// startBlock is the first block that can be safely used to start a
|
||||
// rescan. It is either the block the manager was created with, or
|
||||
// the earliest block provided with imported addresses or scripts.
|
||||
// rescan. It is either the block the manager was created with, or the
|
||||
// earliest block provided with imported addresses or scripts.
|
||||
startBlock BlockStamp
|
||||
|
||||
// syncedTo is the current block the addresses in the manager are known
|
||||
|
@ -43,8 +43,8 @@ func newSyncState(startBlock, syncedTo *BlockStamp) *syncState {
|
|||
}
|
||||
|
||||
// SetSyncedTo marks the address manager to be in sync with the recently-seen
|
||||
// block described by the blockstamp. When the provided blockstamp is nil,
|
||||
// the oldest blockstamp of the block the manager was created at and of all
|
||||
// block described by the blockstamp. When the provided blockstamp is nil, the
|
||||
// oldest blockstamp of the block the manager was created at and of all
|
||||
// imported addresses will be used. This effectively allows the manager to be
|
||||
// marked as unsynced back to the oldest known point any of the addresses have
|
||||
// appeared in the block chain.
|
||||
|
|
Loading…
Add table
Reference in a new issue