Documentation
¶
Index ¶
- Constants
- Variables
- func ConvertOwnedUTXOIntoVin(utxo *OwnedUTXO) bip352.Vin
- func LoadConfigs(pathToConfig string)
- func SetPaths(baseDirectory string)
- type Address
- type Addresses
- type Keys
- type Label
- type LabelsMapping
- type OwnedUTXO
- type Recipient
- type UTXOMapping
- type UTXOState
- type UtxoCollection
- type Wallet
- func (w *Wallet) AddUTXOs(utxos []*OwnedUTXO) error
- func (w *Wallet) CheckAndInitialiseFields() error
- func (w *Wallet) DeSerialise(data []byte) error
- func (w *Wallet) FindLabelByPubKey(pubKey [33]byte) *Label
- func (w *Wallet) FreeBalance() uint64
- func (w *Wallet) GenerateAddress() (string, error)
- func (w *Wallet) GenerateChangeLabel() (string, error)
- func (w *Wallet) GenerateNewLabel(comment string) (*Label, error)
- func (w *Wallet) GetFreeUTXOs(includeSpentUnconfirmed bool) UtxoCollection
- func (w *Wallet) GetUTXOsByStates(states ...UTXOState) UtxoCollection
- func (w *Wallet) LoadKeys(secretKeyScan, secretKeySpend [32]byte)
- func (w *Wallet) SecretKeyScan() [32]byte
- func (w *Wallet) SecretKeySpend() [32]byte
- func (w *Wallet) Serialise() ([]byte, error)
- func (w *Wallet) SortedAddresses() ([]Address, error)
Constants ¶
View Source
const DefaultDirectoryPath = "~/.blindbitd"
View Source
const PathEndingConfig = "/blindbit.toml"
View Source
const PathEndingKeys = dataPath + "/keys"
View Source
const PathEndingSocketDirPath = "/run"
View Source
const PathEndingSocketPath = PathEndingSocketDirPath + "/blindbit.socket"
View Source
const PathEndingWallet = dataPath + "/wallet"
View Source
const StandardAddressComment = "standard"
StandardAddressComment Identifier for the base non-labelled address
Variables ¶
View Source
var ( ErrLabelAlreadyExists = errors.New("label already exists") ErrMinChangeAmountNotReached = errors.New("min change amount not reached") ErrWrongLengthRecipients = errors.New("wrong length new recipients") ErrRecipientIncomplete = errors.New("recipient incomplete") ErrNotSPAddress = errors.New("not a sp address") ErrNoUTXOsInWallet = errors.New("no utxos in wallet") ErrInsufficientFunds = errors.New("insufficient funds") ErrNoMatchForUTXO = errors.New("could not match UTXO to foundOutput, should not happen") ErrTxInputAndVinLengthMismatch = errors.New("tx inputs and vins have different length, should not happen") ErrNoMatchingVinFoundForTxInput = errors.New("there was no matching vin for the given tx input, should not happen") ErrDaemonNotSet = errors.New("daemon is not initialised") ErrDaemonIsLocked = errors.New("daemon is locked") ErrInvalidFeeRate = errors.New("invalid fee rate") ErrRecipientAmountIsZero = errors.New("recipient amount is zero") )
todo group by logical context errors with `should not happen` indicate a bug in the program and not necessarily user input errors
View Source
var ( DirectoryPath = "~/.blindbitd" PathLogs string PathIpcSocketDir string PathIpcSocket string PathConfig string PathDbWallet string PathToKeys string )
View Source
var ( // BlindBitServerAddress Indexing server for silent payments that follows the blindbit standard BlindBitServerAddress string // ElectrumServerAddress Electrum server ElectrumServerAddress string // MinChangeAmount The wallet will never create change that is smaller than this value. Value has to be in sats. MinChangeAmount int64 // DustLimit only receives amounts and checks tweaks where the biggest utxo exceeds the dust limit. // Note: that if you receive funds below this threshold you might not find them. // Rescan with DustLimit = 0 to find those. DustLimit uint64 // ChainParams defines on which chain the wallet runs ChainParams *chaincfg.Params // ElectrumTorProxyHost if the host addr is given, tor will be used normally "127.0.0.1:9050". This is also the default setting ElectrumTorProxyHost = "" // UseElectrum no electrum calls will be made if false. Setting an electrum address wil set to true in settings. UseElectrum bool // AutomaticScanInterval has different values depending on whether Electrum is used or not AutomaticScanInterval time.Duration = 5 * time.Minute // 5 minutes if electrum is active )
View Source
var Empty32Arr = bip352.ConvertToFixedLength32(bytes.Repeat([]byte{0x00}, 32))
View Source
var Empty33Arr = bip352.ConvertToFixedLength33(bytes.Repeat([]byte{0x00}, 33))
Functions ¶
func ConvertOwnedUTXOIntoVin ¶
func LoadConfigs ¶
func LoadConfigs(pathToConfig string)
Types ¶
type Keys ¶
func CreateNewKeys ¶
func DeriveKeysFromMaster ¶
func DeriveKeysFromMaster(master *hdkeychain.ExtendedKey) (*Keys, error)
func KeysFromMnemonic ¶
func (*Keys) DeSerialise ¶
type LabelsMapping ¶
LabelsMapping the key is the label's pubKey, the value is the Label data
func (*LabelsMapping) GetLabelByPubKey ¶
func (lm *LabelsMapping) GetLabelByPubKey(labelPubKey [33]byte) *Label
func (*LabelsMapping) MarshalJSON ¶
func (lm *LabelsMapping) MarshalJSON() ([]byte, error)
func (*LabelsMapping) UnmarshalJSON ¶
func (lm *LabelsMapping) UnmarshalJSON(data []byte) error
type OwnedUTXO ¶
type OwnedUTXO struct {
Txid [32]byte `json:"txid,omitempty"`
Vout uint32 `json:"vout,omitempty"`
Amount uint64 `json:"amount"`
PrivKeyTweak [32]byte `json:"priv_key_tweak,omitempty"`
PubKey [32]byte `json:"pub_key,omitempty"`
Timestamp uint64 `json:"timestamp,omitempty"`
State UTXOState `json:"utxo_state,omitempty"`
Label *bip352.Label `json:"label"` // the pubKey associated with the label
}
func (*OwnedUTXO) LabelComment ¶
func (u *OwnedUTXO) LabelComment(mapping LabelsMapping) *string
func (*OwnedUTXO) LabelPubKey ¶
func (*OwnedUTXO) SerialiseToOutpoint ¶
type UTXOMapping ¶
type UTXOMapping map[[36]byte]struct{}
UTXOMapping the key is the utxos (txid||vout) todo marshalling or unmarshalling seems to have some issues. Investigate root cause
func (*UTXOMapping) MarshalJSON ¶
func (um *UTXOMapping) MarshalJSON() ([]byte, error)
func (*UTXOMapping) UnmarshalJSON ¶
func (um *UTXOMapping) UnmarshalJSON(data []byte) error
type UtxoCollection ¶
type UtxoCollection []*OwnedUTXO
func (*UtxoCollection) DeSerialise ¶
func (c *UtxoCollection) DeSerialise(data []byte) error
func (*UtxoCollection) Serialise ¶
func (c *UtxoCollection) Serialise() ([]byte, error)
type Wallet ¶
type Wallet struct {
PubKeyScan [33]byte `json:"pub_key_scan"`
PubKeySpend [33]byte `json:"pub_key_spend"`
BirthHeight uint64 `json:"birth_height,omitempty"`
LastScanHeight uint64 `json:"last_scan,omitempty"`
UTXOs UtxoCollection `json:"utxos,omitempty"`
Labels []*bip352.Label `json:"labels"` // Labels contains all labels except for the change label
ChangeLabel *bip352.Label `json:"change_label"` // ChangeLabel is separate in order to make it clear that it's special and is not just shown like other labels
NextLabelM uint32 `json:"next_label_m"` // NextLabelM indicates which m will be used to derive the next label
// todo Important: if taken out we need to keep the tweak fro that UTXO otherwise it will be found but basically unspendable
PubKeysToWatch [][32]byte `json:"pub_keys_to_watch"` // todo this can be taken out, we can check for new payments to old pub-keys via electrum.
Addresses Addresses `json:"addresses"`
// todo should LabelsMapping be integrated with Wallet.Labels
LabelsMapping LabelsMapping `json:"labels_mapping"` // never show LabelsMapping addresses to the user - it includes the change label which should NEVER be shown to normal users
UTXOMapping UTXOMapping `json:"utxo_mapping"` // used to keep track of utxos and not add the same twice
// contains filtered or unexported fields
}
func (*Wallet) CheckAndInitialiseFields ¶
func (*Wallet) DeSerialise ¶
func (*Wallet) FindLabelByPubKey ¶
FindLabelByPubKey returns the pointer to a Label stored in the wallet, will be nil if none was found. This is basically a wrapper function around LabelsMapping but adds the change label. Chose this approach to avoid accidentally exposing the change address.
func (*Wallet) FreeBalance ¶
func (*Wallet) GenerateAddress ¶
func (*Wallet) GenerateChangeLabel ¶
func (*Wallet) GetFreeUTXOs ¶
func (w *Wallet) GetFreeUTXOs(includeSpentUnconfirmed bool) UtxoCollection
func (*Wallet) GetUTXOsByStates ¶
func (w *Wallet) GetUTXOsByStates(states ...UTXOState) UtxoCollection
func (*Wallet) SecretKeyScan ¶
func (*Wallet) SecretKeySpend ¶
func (*Wallet) SortedAddresses ¶
Click to show internal directories.
Click to hide internal directories.