Documentation ¶
Index ¶
- Constants
- Variables
- func DecryptData(data, passphrase []byte) ([]byte, error)
- func EncryptData(data, passphrase []byte) ([]byte, error)
- func ReEncryptData(data, oldPass, newPass []byte) ([]byte, error)
- type CreateWalletParams
- type Network
- type OpenWalletParams
- type PeerManagerChainService
- type PeerSource
- type RecoveryCfg
- type SPVPeer
- type SPVPeerManager
- type WalletBase
- func (w *WalletBase) AccountDiscoveryRequired() bool
- func (w *WalletBase) DataDir() string
- func (w *WalletBase) DecryptSeed(passphrase []byte) (string, error)
- func (sh WalletBase) InitializeSyncContext(ctx context.Context) (context.Context, error)
- func (w *WalletBase) IsRestored() bool
- func (sh WalletBase) IsSyncingOrSynced() bool
- func (w *WalletBase) IsWatchOnly() bool
- func (w *WalletBase) MarkAccountDiscoveryComplete()
- func (w *WalletBase) Network() Network
- func (w *WalletBase) ReEncryptSeed(oldPass, newPass []byte) error
- func (w *WalletBase) SeedVerificationRequired() bool
- func (sh WalletBase) StopSync()
- func (sh WalletBase) SyncEnded(err error)
- func (sh WalletBase) SyncIsStopping() bool
- func (w *WalletBase) VerifySeed(seedMnemonic string, passphrase []byte) (bool, error)
- func (sh WalletBase) WaitForSyncToStop()
- type WalletPeer
- type WalletTrait
Constants ¶
const Simnet = Regtest
Simnet is an alias of Regtest.
Variables ¶
var (
ErrInvalidPassphrase = errors.New("invalid_passphrase")
)
Functions ¶
func DecryptData ¶
DecryptData uses the provided passphrase to decrypt the provided data.
func EncryptData ¶
EncryptData encrypts the provided data with the provided passphrase.
func ReEncryptData ¶
ReEncryptData decrypts the provided data using the oldPass and re-encrypts the data using newPass.
Types ¶
type CreateWalletParams ¶
type CreateWalletParams struct { OpenWalletParams Pass []byte Birthday time.Time }
CreateWalletParams are the parameters for creating a wallet.
type Network ¶
type Network uint8
Network flags passed to asset backends to signify which network to use.
func NetFromString ¶
NetFromString returns the Network for the given network name.
type OpenWalletParams ¶
CreateWalletParams are the parameters for opening a wallet.
type PeerManagerChainService ¶
type PeerManagerChainService interface { ConnectNode(addr string, permanent bool) error RemoveNodeByAddr(addr string) error Peers() []SPVPeer }
PeerManagerChainService are the functions needed for an SPVPeerManager to communicate with a chain service.
type PeerSource ¶
type PeerSource uint16
const ( AddedPeer PeerSource = iota DefaultPeer DiscoveredPeer )
type RecoveryCfg ¶
type RecoveryCfg struct { Seed []byte Birthday time.Time NumExternalAddresses uint32 NumInternalAddresses uint32 }
RecoveryCfg is the information used to recover a wallet.
type SPVPeer ¶
SPVPeer is satisfied by *neutrino.ServerPeer, but is generalized to accommodate underlying implementations other than lightninglabs/neutrino.
type SPVPeerManager ¶
type SPVPeerManager struct {
// contains filtered or unexported fields
}
SPVPeerManager implements peer management functionality for all bitcoin clone SPV wallets.
func NewSPVPeerManager ¶
func NewSPVPeerManager(cs PeerManagerChainService, defaultPeers []string, savedPeersFilePath string, log slog.Logger, defaultPort string) *SPVPeerManager
NewSPVPeerManager creates a new SPVPeerManager.
func (*SPVPeerManager) AddPeer ¶
func (s *SPVPeerManager) AddPeer(addr string) error
AddPeer connects to a new peer and stores it in the db.
func (*SPVPeerManager) ConnectToInitialWalletPeers ¶
func (s *SPVPeerManager) ConnectToInitialWalletPeers()
ConnectToInitialWalletPeers connects to the default peers and the peers that were added by the user and persisted in the db.
func (*SPVPeerManager) Peers ¶
func (s *SPVPeerManager) Peers() ([]*WalletPeer, error)
Peers returns the list of peers that the wallet is connected to. It also returns the peers that the user added that the wallet may not currently be connected to.
func (*SPVPeerManager) RemovePeer ¶
func (s *SPVPeerManager) RemovePeer(addr string) error
RemovePeer disconnects from a peer added by the user and removes it from the db.
type WalletBase ¶
type WalletBase struct {
// contains filtered or unexported fields
}
func NewWalletBase ¶
func NewWalletBase(params OpenWalletParams, seed, walletPass []byte, birthday time.Time, traits WalletTrait) (*WalletBase, error)
NewWalletBase initializes a WalletBase using the information provided. The wallet's seed is encrypted and saved, along with other basic wallet info.
func OpenWalletBase ¶
func OpenWalletBase(params OpenWalletParams) (*WalletBase, error)
OpenWalletBase loads basic information for an existing wallet from the provided params.
func (*WalletBase) AccountDiscoveryRequired ¶
func (w *WalletBase) AccountDiscoveryRequired() bool
func (*WalletBase) DataDir ¶
func (w *WalletBase) DataDir() string
func (*WalletBase) DecryptSeed ¶
func (w *WalletBase) DecryptSeed(passphrase []byte) (string, error)
DecryptSeed decrypts the encrypted wallet seed using the provided passphrase and returns the mnemonic.
func (WalletBase) InitializeSyncContext ¶
InitializeSyncContext returns a context that should be used for bacgkround sync processes. All sync background processes should exit when the returned context is canceled. Call SyncEnded() when all sync processes have ended.
func (*WalletBase) IsRestored ¶
func (w *WalletBase) IsRestored() bool
func (WalletBase) IsSyncingOrSynced ¶
func (sh WalletBase) IsSyncingOrSynced() bool
IsSyncingOrSynced is true if the wallet synchronization was started.
func (*WalletBase) IsWatchOnly ¶
func (w *WalletBase) IsWatchOnly() bool
func (*WalletBase) MarkAccountDiscoveryComplete ¶
func (w *WalletBase) MarkAccountDiscoveryComplete()
func (*WalletBase) Network ¶
func (w *WalletBase) Network() Network
func (*WalletBase) ReEncryptSeed ¶
func (w *WalletBase) ReEncryptSeed(oldPass, newPass []byte) error
func (*WalletBase) SeedVerificationRequired ¶
func (w *WalletBase) SeedVerificationRequired() bool
SeedVerificationRequired is true if the seed for this wallet is yet to be verified by the owner. The wallet's seed is saved in an encrypted form until it is verified.
func (WalletBase) StopSync ¶
func (sh WalletBase) StopSync()
StopSync cancels the wallet's synchronization to the blockchain network. It may take a few moments for sync to completely stop. Use
func (WalletBase) SyncEnded ¶
func (sh WalletBase) SyncEnded(err error)
SyncEnded signals that all sync processes have been stopped.
func (WalletBase) SyncIsStopping ¶
func (sh WalletBase) SyncIsStopping() bool
func (*WalletBase) VerifySeed ¶
func (w *WalletBase) VerifySeed(seedMnemonic string, passphrase []byte) (bool, error)
VerifySeed decrypts the encrypted wallet seed using the provided passphrase and compares it with the provided seedMnemonic. If it's a match, the wallet seed will no longer be saved.
func (WalletBase) WaitForSyncToStop ¶
func (sh WalletBase) WaitForSyncToStop()
WaitForSyncToStop blocks until the wallet synchronization is fully stopped.
type WalletPeer ¶
type WalletPeer struct { Addr string `json:"addr"` Source PeerSource `json:"source"` Connected bool `json:"connected"` }
WalletPeer provides information about a wallet's peer.
type WalletTrait ¶
type WalletTrait uint64
WalletTrait is a bitset indicating various optional wallet properties, such as if the wallet was restored or if it's watch only.
const ( WalletTraitRestored WalletTrait = 1 << iota // The Wallet is a restored wallet. WalletTraitWatchOnly // The Wallet is a watch only wallet. )