Documentation ¶
Index ¶
- Constants
- Variables
- func Bip44Derivation(masterPrivKey *hd.ExtendedKey) (internal, external *hd.ExtendedKey, err error)
- func EstimateSerializeSize(inputCount int, txOuts []*wire.TxOut, addChangeOutput bool, ...) int
- func LockTimeFromRedeemScript(redeemScript []byte) (uint32, error)
- func MakeMerkleParent(left *chainhash.Hash, right *chainhash.Hash) (*chainhash.Hash, error)
- func NewCoin(txid []byte, index uint32, value btc.Amount, numConfs int64, ...) coinset.Coin
- func NewUnsignedTransaction(outputs []*wire.TxOut, feePerKb btc.Amount, fetchInputs txauthor.InputSource, ...) (*txauthor.AuthoredTx, error)
- func SumOutputSerializeSizes(outputs []*wire.TxOut) (serializeSize int)
- func TestStxo_IsEqual(t *testing.T)
- func TestUtxo_IsEqual(t *testing.T)
- func TorLookupIP(host string) ([]net.IP, error)
- type Blockchain
- func (b *Blockchain) BestBlock() (StoredHeader, error)
- func (b *Blockchain) CalcMedianTimePast(header wire.BlockHeader) (time.Time, error)
- func (b *Blockchain) CheckHeader(header wire.BlockHeader, prevHeader StoredHeader) bool
- func (b *Blockchain) Close()
- func (b *Blockchain) CommitHeader(header wire.BlockHeader) (bool, *StoredHeader, uint32, error)
- func (b *Blockchain) GetBlockLocator() blockchain.BlockLocator
- func (b *Blockchain) GetCommonAncestor(bestHeader, prevBestHeader StoredHeader) (*StoredHeader, error)
- func (b *Blockchain) GetEpoch() (*wire.BlockHeader, error)
- func (b *Blockchain) GetHeader(hash *chainhash.Hash) (StoredHeader, error)
- func (b *Blockchain) GetNPrevBlockHashes(n int) []*chainhash.Hash
- func (b *Blockchain) Rollback(t time.Time) error
- type Checkpoint
- type Coin
- type Config
- type FeeProvider
- type Fees
- type HeaderCache
- type HeaderDB
- func (h *HeaderDB) Close()
- func (h *HeaderDB) DeleteAfter(height uint32) error
- func (h *HeaderDB) GetBestHeader() (sh StoredHeader, err error)
- func (h *HeaderDB) GetHeader(hash chainhash.Hash) (sh StoredHeader, err error)
- func (h *HeaderDB) GetPreviousHeader(header wire.BlockHeader) (sh StoredHeader, err error)
- func (h *HeaderDB) Height() (uint32, error)
- func (h *HeaderDB) Print(w io.Writer)
- func (h *HeaderDB) Prune() error
- func (h *HeaderDB) Put(sh StoredHeader, newBestHeader bool) error
- type Headers
- type InputType
- type KeyManager
- func (km *KeyManager) GetCurrentKey(purpose wallet.KeyPurpose) (*hd.ExtendedKey, error)
- func (km *KeyManager) GetFreshKey(purpose wallet.KeyPurpose) (*hd.ExtendedKey, error)
- func (km *KeyManager) GetKeyForScript(scriptAddress []byte) (*hd.ExtendedKey, error)
- func (km *KeyManager) GetKeys() []*hd.ExtendedKey
- func (km *KeyManager) MarkKeyAsUsed(scriptAddress []byte) error
- type MockDatastore
- type PeerManager
- type PeerManagerConfig
- type SPVWallet
- func (w *SPVWallet) AddTransactionListener(callback func(wallet.TransactionCallback))
- func (w *SPVWallet) AddWatchedAddresses(addrs ...btc.Address) error
- func (w *SPVWallet) AddressToScript(addr btc.Address) ([]byte, error)
- func (w *SPVWallet) AssociateTransactionWithOrder(cb wallet.TransactionCallback)
- func (w *SPVWallet) Balance() (confirmed, unconfirmed int64)
- func (s *SPVWallet) Broadcast(tx *wire.MsgTx) error
- func (w *SPVWallet) BumpFee(txid chainhash.Hash) (*chainhash.Hash, error)
- func (w *SPVWallet) ChainTip() (uint32, chainhash.Hash)
- func (w *SPVWallet) ChildKey(keyBytes []byte, chaincode []byte, isPrivateKey bool) (*hd.ExtendedKey, error)
- func (w *SPVWallet) Close()
- func (w *SPVWallet) ConnectedPeers() []*peer.Peer
- func (w *SPVWallet) CreateMultisigSignature(ins []wallet.TransactionInput, outs []wallet.TransactionOutput, ...) ([]wallet.Signature, error)
- func (w *SPVWallet) CurrencyCode() string
- func (w *SPVWallet) CurrentAddress(purpose wallet.KeyPurpose) btc.Address
- func (w *SPVWallet) DecodeAddress(addr string) (btc.Address, error)
- func (w *SPVWallet) DumpHeaders(writer io.Writer)
- func (w *SPVWallet) EstimateFee(ins []wallet.TransactionInput, outs []wallet.TransactionOutput, ...) uint64
- func (w *SPVWallet) EstimateSpendFee(amount int64, feeLevel wallet.FeeLevel) (uint64, error)
- func (w *SPVWallet) ExchangeRates() wallet.ExchangeRates
- func (w *SPVWallet) GenerateMultisigScript(keys []hd.ExtendedKey, threshold int, timeout time.Duration, ...) (addr btc.Address, redeemScript []byte, err error)
- func (w *SPVWallet) GetConfirmations(txid chainhash.Hash) (uint32, uint32, error)
- func (w *SPVWallet) GetFeePerByte(feeLevel wallet.FeeLevel) uint64
- func (w *SPVWallet) GetKey(addr btc.Address) (*btcec.PrivateKey, error)
- func (w *SPVWallet) GetTransaction(txid chainhash.Hash) (wallet.Txn, error)
- func (w *SPVWallet) HasKey(addr btc.Address) bool
- func (w *SPVWallet) IsDust(amount int64) bool
- func (w *SPVWallet) ListAddresses() []btc.Address
- func (w *SPVWallet) ListKeys() []btcec.PrivateKey
- func (w *SPVWallet) MasterPrivateKey() *hd.ExtendedKey
- func (w *SPVWallet) MasterPublicKey() *hd.ExtendedKey
- func (w *SPVWallet) Mnemonic() string
- func (w *SPVWallet) Multisign(ins []wallet.TransactionInput, outs []wallet.TransactionOutput, ...) ([]byte, error)
- func (w *SPVWallet) NewAddress(purpose wallet.KeyPurpose) btc.Address
- func (w *SPVWallet) Params() *chaincfg.Params
- func (w *SPVWallet) ReSyncBlockchain(fromDate time.Time)
- func (w *SPVWallet) ScriptToAddress(script []byte) (btc.Address, error)
- func (w *SPVWallet) Spend(amount int64, addr btc.Address, feeLevel wallet.FeeLevel, referenceID string, ...) (*chainhash.Hash, error)
- func (w *SPVWallet) Start()
- func (w *SPVWallet) SweepAddress(ins []wallet.TransactionInput, address *btc.Address, key *hd.ExtendedKey, ...) (*chainhash.Hash, error)
- func (w *SPVWallet) Transactions() ([]wallet.Txn, error)
- type StoredHeader
- type TxStore
- func (ts *TxStore) CheckDoubleSpends(argTx *wire.MsgTx) ([]*chainhash.Hash, error)
- func (ts *TxStore) GetPendingInv() (*wire.MsgInv, error)
- func (ts *TxStore) GimmeFilter() (*bloom.Filter, error)
- func (ts *TxStore) Ingest(tx *wire.MsgTx, height int32, timestamp time.Time) (uint32, error)
- func (ts *TxStore) PopulateAdrs() error
- type WireService
- type WireServiceConfig
Constants ¶
const ( MAX_HEADERS = 2000 CACHE_SIZE = 100 )
const ( // RedeemP2PKHSigScriptSize is the worst case (largest) serialize size // of a transaction input script that redeems a compressed P2PKH output. // It is calculated as: // // - OP_DATA_73 // - 72 bytes DER signature + 1 byte sighash // - OP_DATA_33 // - 33 bytes serialized compressed pubkey RedeemP2PKHSigScriptSize = 1 + 73 + 1 + 33 // RedeemP2SHMultisigSigScriptSize is the worst case (largest) serialize size // of a transaction input script that redeems a 2 of 3 P2SH multisig output with compressed keys. // It is calculated as: // // - OP_0 // - OP_DATA_72 // - 72 bytes DER signature // - OP_DATA_72 // - 72 bytes DER signature // - OP_PUSHDATA // - OP_2 // - OP_DATA_33 // - 33 bytes serialized compressed pubkey // - OP_DATA_33 // - 33 bytes serialized compressed pubkey // - OP_DATA_33 // - 33 bytes serialized compressed pubkey // - OP3 // - OP_CHECKMULTISIG RedeemP2SH2of3MultisigSigScriptSize = 1 + 1 + 72 + 1 + 72 + 1 + 1 + 1 + 33 + 1 + 33 + 1 + 33 + 1 + 1 // RedeemP2SH1of2MultisigSigScriptSize is the worst case (largest) serialize size // of a transaction input script that redeems a 1 of 2 P2SH multisig output with compressed keys. // It is calculated as: // // - OP_0 // - OP_DATA_72 // - 72 bytes DER signature // - OP_PUSHDATA // - OP_1 // - OP_DATA_33 // - 33 bytes serialized compressed pubkey // - OP_DATA_33 // - 33 bytes serialized compressed pubkey // - OP2 // - OP_CHECKMULTISIG RedeemP2SH1of2MultisigSigScriptSize = 1 + 1 + 72 + 1 + 1 + 1 + 33 + 1 + 33 + 1 + 1 // RedeemP2SHMultisigTimelock1SigScriptSize is the worst case (largest) serialize size // of a transaction input script that redeems a compressed P2SH timelocked multisig using the timeout. // It is calculated as: // // - OP_DATA_72 // - 72 bytes DER signature // - OP_0 // - OP_PUSHDATA // - OP_IF // - OP_2 // - OP_DATA_33 // - 33 bytes serialized compressed pubkey // - OP_DATA_33 // - 33 bytes serialized compressed pubkey // - OP_DATA_33 // - 33 bytes serialized compressed pubkey // - OP3 // - OP_CHECKMULTISIG // - OP_ELSE // - OP_PUSHDATA // - 2 byte block height // - OP_CHECKSEQUENCEVERIFY // - OP_DROP // - OP_DATA_33 // - 33 bytes serialized compressed pubkey // - OP_CHECKSIG // - OP_ENDIF RedeemP2SHMultisigTimelock1SigScriptSize = 1 + 72 + 1 + 1 + 1 + 1 + 1 + 33 + 1 + 33 + 1 + 33 + 1 + 1 + 1 + 1 + 2 + 1 + 1 + 1 + 33 + 1 + 1 // RedeemP2SHMultisigTimelock2SigScriptSize is the worst case (largest) serialize size // of a transaction input script that redeems a compressed P2SH timelocked multisig without using the timeout. // It is calculated as: // // - OP_0 // - OP_DATA_72 // - 72 bytes DER signature // - OP_DATA_72 // - 72 bytes DER signature // - OP_1 // - OP_PUSHDATA // - OP_IF // - OP_2 // - OP_DATA_33 // - 33 bytes serialized compressed pubkey // - OP_DATA_33 // - 33 bytes serialized compressed pubkey // - OP_DATA_33 // - 33 bytes serialized compressed pubkey // - OP3 // - OP_CHECKMULTISIG // - OP_ELSE // - OP_PUSHDATA // - 2 byte block height // - OP_CHECKSEQUENCEVERIFY // - OP_DROP // - OP_DATA_33 // - 33 bytes serialized compressed pubkey // - OP_CHECKSIG // - OP_ENDIF RedeemP2SHMultisigTimelock2SigScriptSize = 1 + 1 + 72 + +1 + 72 + 1 + 1 + 1 + 1 + 1 + 33 + 1 + 33 + 1 + 33 + 1 + 1 + 1 + 1 + 2 + 1 + 1 + 1 + 33 + 1 + 1 // P2PKHPkScriptSize is the size of a transaction output script that // pays to a compressed pubkey hash. It is calculated as: // // - OP_DUP // - OP_HASH160 // - OP_DATA_20 // - 20 bytes pubkey hash // - OP_EQUALVERIFY // - OP_CHECKSIG P2PKHPkScriptSize = 1 + 1 + 1 + 20 + 1 + 1 // RedeemP2PKHInputSize is the worst case (largest) serialize size of a // transaction input redeeming a compressed P2PKH output. It is // calculated as: // // - 32 bytes previous tx // - 4 bytes output index // - 1 byte script len // - signature script // - 4 bytes sequence RedeemP2PKHInputSize = 32 + 4 + 1 + RedeemP2PKHSigScriptSize + 4 // RedeemP2SH2of3MultisigInputSize is the worst case (largest) serialize size of a // transaction input redeeming a compressed P2SH 2 of 3 multisig output. It is // calculated as: // // - 32 bytes previous tx // - 4 bytes output index // - 1 byte script len // - 4 bytes sequence /// - witness discounted signature script RedeemP2SH2of3MultisigInputSize = 32 + 4 + 1 + 4 + (RedeemP2SH2of3MultisigSigScriptSize / 4) // RedeemP2SH1of2MultisigInputSize is the worst case (largest) serialize size of a // transaction input redeeming a compressed P2SH 2 of 3 multisig output. It is // calculated as: // // - 32 bytes previous tx // - 4 bytes output index // - 1 byte script len // - 4 bytes sequence /// - witness discounted signature script RedeemP2SH1of2MultisigInputSize = 32 + 4 + 1 + 4 + (RedeemP2SH1of2MultisigSigScriptSize / 4) // RedeemP2SHMultisigTimelock1InputSize is the worst case (largest) serialize size of a // transaction input redeeming a compressed p2sh timelocked multig output with using the timeout. It is // calculated as: // // - 32 bytes previous tx // - 4 bytes output index // - 1 byte script len // - 4 bytes sequence /// - witness discounted signature script RedeemP2SHMultisigTimelock1InputSize = 32 + 4 + 1 + 4 + (RedeemP2SHMultisigTimelock1SigScriptSize / 4) // RedeemP2SHMultisigTimelock2InputSize is the worst case (largest) serialize size of a // transaction input redeeming a compressed P2SH timelocked multisig output without using the timeout. It is // calculated as: // // - 32 bytes previous tx // - 4 bytes output index // - 1 byte script len // - 4 bytes sequence /// - witness discounted signature script RedeemP2SHMultisigTimelock2InputSize = 32 + 4 + 1 + 4 + (RedeemP2SHMultisigTimelock2SigScriptSize / 4) // P2PKHOutputSize is the serialize size of a transaction output with a // P2PKH output script. It is calculated as: // // - 8 bytes output value // - 1 byte compact int encoding value 25 // - 25 bytes P2PKH output script P2PKHOutputSize = 8 + 1 + P2PKHPkScriptSize )
Worst case script and input/output size estimates.
const LOOKAHEADWINDOW = 100
const MaxGetAddressAttempts = 10
const WALLET_VERSION = "0.1.0"
Variables ¶
var ( BKTHeaders = []byte("Headers") BKTChainTip = []byte("ChainTip") KEYChainTip = []byte("ChainTip") )
var ( // ErrTorInvalidAddressResponse indicates an invalid address was // returned by the Tor DNS resolver. ErrTorInvalidAddressResponse = errors.New("invalid address response") // ErrTorInvalidProxyResponse indicates the Tor proxy returned a // response in an unexpected format. ErrTorInvalidProxyResponse = errors.New("invalid proxy response") // ErrTorUnrecognizedAuthMethod indicates the authentication method // provided is not recognized. ErrTorUnrecognizedAuthMethod = errors.New("invalid proxy authentication method") )
var BumpFeeAlreadyConfirmedError = errors.New("Transaction is confirmed, cannot bump fee")
var BumpFeeNotFoundError = errors.New("Transaction either doesn't exist or has already been spent")
var BumpFeeTransactionDeadError = errors.New("Cannot bump fee of dead transaction")
var OrphanHeaderError = errors.New("header does not extend any known headers")
var SFNodeBitcoinCash wire.ServiceFlag = 1 << 5
Functions ¶
func Bip44Derivation ¶
func Bip44Derivation(masterPrivKey *hd.ExtendedKey) (internal, external *hd.ExtendedKey, err error)
m / purpose' / coin_type' / account' / change / address_index
func EstimateSerializeSize ¶
func EstimateSerializeSize(inputCount int, txOuts []*wire.TxOut, addChangeOutput bool, inputType InputType) int
EstimateSerializeSize returns a worst case serialize size estimate for a signed transaction that spends inputCount number of compressed P2PKH outputs and contains each transaction output from txOuts. The estimated size is incremented for an additional P2PKH change output if addChangeOutput is true.
func MakeMerkleParent ¶
func NewUnsignedTransaction ¶
func NewUnsignedTransaction(outputs []*wire.TxOut, feePerKb btc.Amount, fetchInputs txauthor.InputSource, fetchChange txauthor.ChangeSource) (*txauthor.AuthoredTx, error)
func SumOutputSerializeSizes ¶
SumOutputSerializeSizes sums up the serialized size of the supplied outputs.
func TestStxo_IsEqual ¶
func TestUtxo_IsEqual ¶
Types ¶
type Blockchain ¶
type Blockchain struct {
// contains filtered or unexported fields
}
Wrapper around Headers implementation that handles all blockchain operations
func NewBlockchain ¶
func (*Blockchain) BestBlock ¶
func (b *Blockchain) BestBlock() (StoredHeader, error)
func (*Blockchain) CalcMedianTimePast ¶
func (b *Blockchain) CalcMedianTimePast(header wire.BlockHeader) (time.Time, error)
func (*Blockchain) CheckHeader ¶
func (b *Blockchain) CheckHeader(header wire.BlockHeader, prevHeader StoredHeader) bool
func (*Blockchain) Close ¶
func (b *Blockchain) Close()
func (*Blockchain) CommitHeader ¶
func (b *Blockchain) CommitHeader(header wire.BlockHeader) (bool, *StoredHeader, uint32, error)
func (*Blockchain) GetBlockLocator ¶
func (b *Blockchain) GetBlockLocator() blockchain.BlockLocator
func (*Blockchain) GetCommonAncestor ¶
func (b *Blockchain) GetCommonAncestor(bestHeader, prevBestHeader StoredHeader) (*StoredHeader, error)
GetCommonAncestor returns last header before reorg point
func (*Blockchain) GetEpoch ¶
func (b *Blockchain) GetEpoch() (*wire.BlockHeader, error)
func (*Blockchain) GetHeader ¶
func (b *Blockchain) GetHeader(hash *chainhash.Hash) (StoredHeader, error)
func (*Blockchain) GetNPrevBlockHashes ¶
func (b *Blockchain) GetNPrevBlockHashes(n int) []*chainhash.Hash
type Checkpoint ¶
type Checkpoint struct { Height uint32 Header wire.BlockHeader }
func GetCheckpoint ¶
func GetCheckpoint(walletCreationDate time.Time, params *chaincfg.Params) Checkpoint
type Coin ¶
type Config ¶
type Config struct { // Network parameters. Set mainnet, testnet, or regtest using this. Params *chaincfg.Params // Bip39 mnemonic string. If empty a new mnemonic will be created. Mnemonic string // The date the wallet was created. // If before the earliest checkpoint the chain will be synced using the earliest checkpoint. CreationDate time.Time // The user-agent that shall be visible to peers UserAgent string // Location of the data directory RepoPath string // An implementation of the Datastore interface DB wallet.Datastore // If you wish to connect to a single trusted peer set this. Otherwise leave nil. TrustedPeer net.Addr // A Tor proxy can be set here causing the wallet will use Tor Proxy proxy.Dialer // The default fee-per-byte for each level LowFee uint64 MediumFee uint64 HighFee uint64 // The highest allowable fee-per-byte MaxFee uint64 // External API to query to look up fees. If this field is nil then the default fees will be used. // If the API is unreachable then the default fees will likewise be used. If the API returns a fee // greater than MaxFee then the MaxFee will be used in place. The API response must be formatted as // { "fastestFee": 40, "halfHourFee": 20, "hourFee": 10 } FeeAPI url.URL // A logger. You can write the logs to file or stdout or however else you want. Logger logging.Backend // Disable the exchange rate provider DisableExchangeRates bool }
func NewDefaultConfig ¶
func NewDefaultConfig() *Config
type FeeProvider ¶
type FeeProvider struct {
// contains filtered or unexported fields
}
func NewFeeProvider ¶
func NewFeeProvider(maxFee, priorityFee, normalFee, economicFee uint64, feeAPI string, proxy proxy.Dialer) *FeeProvider
func (*FeeProvider) GetFeePerByte ¶
func (fp *FeeProvider) GetFeePerByte(feeLevel wallet.FeeLevel) uint64
type HeaderCache ¶
func (*HeaderCache) Get ¶
func (h *HeaderCache) Get(hash chainhash.Hash) (StoredHeader, error)
func (*HeaderCache) Set ¶
func (h *HeaderCache) Set(sh StoredHeader)
type HeaderDB ¶
type HeaderDB struct {
// contains filtered or unexported fields
}
HeaderDB implements Headers using bolt DB
func NewHeaderDB ¶
func (*HeaderDB) DeleteAfter ¶
func (*HeaderDB) GetBestHeader ¶
func (h *HeaderDB) GetBestHeader() (sh StoredHeader, err error)
func (*HeaderDB) GetHeader ¶
func (h *HeaderDB) GetHeader(hash chainhash.Hash) (sh StoredHeader, err error)
func (*HeaderDB) GetPreviousHeader ¶
func (h *HeaderDB) GetPreviousHeader(header wire.BlockHeader) (sh StoredHeader, err error)
type Headers ¶
type Headers interface { // Put a block header to the database // Total work and height are required to be calculated prior to insertion // If this is the new best header, the chain tip should also be updated Put(header StoredHeader, newBestHeader bool) error // Delete all headers after the MAX_HEADERS most recent Prune() error // Delete all headers after the given height DeleteAfter(height uint32) error // Returns all information about the previous header GetPreviousHeader(header wire.BlockHeader) (StoredHeader, error) // Grab a header given hash GetHeader(hash chainhash.Hash) (StoredHeader, error) // Retrieve the best header from the database GetBestHeader() (StoredHeader, error) // Get the height of chain Height() (uint32, error) // Cleanly close the db Close() // Print all headers Print(io.Writer) }
Database interface for storing block headers
type KeyManager ¶
type KeyManager struct {
// contains filtered or unexported fields
}
func NewKeyManager ¶
func NewKeyManager(db wallet.Keys, params *chaincfg.Params, masterPrivKey *hd.ExtendedKey) (*KeyManager, error)
func (*KeyManager) GetCurrentKey ¶
func (km *KeyManager) GetCurrentKey(purpose wallet.KeyPurpose) (*hd.ExtendedKey, error)
func (*KeyManager) GetFreshKey ¶
func (km *KeyManager) GetFreshKey(purpose wallet.KeyPurpose) (*hd.ExtendedKey, error)
func (*KeyManager) GetKeyForScript ¶
func (km *KeyManager) GetKeyForScript(scriptAddress []byte) (*hd.ExtendedKey, error)
func (*KeyManager) GetKeys ¶
func (km *KeyManager) GetKeys() []*hd.ExtendedKey
func (*KeyManager) MarkKeyAsUsed ¶
func (km *KeyManager) MarkKeyAsUsed(scriptAddress []byte) error
Mark the given key as used and extend the lookahead window
type MockDatastore ¶
type MockDatastore struct {
// contains filtered or unexported fields
}
func (*MockDatastore) Keys ¶
func (m *MockDatastore) Keys() wallet.Keys
func (*MockDatastore) Stxos ¶
func (m *MockDatastore) Stxos() wallet.Stxos
func (*MockDatastore) Txns ¶
func (m *MockDatastore) Txns() wallet.Txns
func (*MockDatastore) Utxos ¶
func (m *MockDatastore) Utxos() wallet.Utxos
func (*MockDatastore) WatchedScripts ¶
func (m *MockDatastore) WatchedScripts() wallet.WatchedScripts
type PeerManager ¶
type PeerManager struct {
// contains filtered or unexported fields
}
func NewPeerManager ¶
func NewPeerManager(config *PeerManagerConfig) (*PeerManager, error)
func (*PeerManager) ConnectedPeers ¶
func (pm *PeerManager) ConnectedPeers() []*peer.Peer
func (*PeerManager) Start ¶
func (pm *PeerManager) Start()
func (*PeerManager) Stop ¶
func (pm *PeerManager) Stop()
type PeerManagerConfig ¶
type PeerManagerConfig struct { // The network parameters to use Params *chaincfg.Params // The target number of outbound peers. Defaults to 10. TargetOutbound uint32 // Duration of time to retry a connection. Defaults to 5 seconds. RetryDuration time.Duration // UserAgentName specifies the user agent name to advertise. It is // highly recommended to specify this value. UserAgentName string // UserAgentVersion specifies the user agent version to advertise. It // is highly recommended to specify this value and that it follows the // form "major.minor.revision" e.g. "2.6.41". UserAgentVersion string // The directory to store cached peers AddressCacheDir string // If this field is not nil the PeerManager will only connect to this address TrustedPeer net.Addr // Listeners to handle messages from peers. If nil, no messages will be handled. Listeners *peer.MessageListeners // An optional proxy dialer. Will use net.Dial if nil. Proxy proxy.Dialer // Function to return current block hash and height GetNewestBlock func() (hash *chainhash.Hash, height int32, err error) // The main channel over which to send outgoing events MsgChan chan interface{} }
type SPVWallet ¶
type SPVWallet struct {
// contains filtered or unexported fields
}
func NewSPVWallet ¶
func (*SPVWallet) AddTransactionListener ¶
func (w *SPVWallet) AddTransactionListener(callback func(wallet.TransactionCallback))
func (*SPVWallet) AddWatchedAddresses ¶
func (*SPVWallet) AddressToScript ¶
func (*SPVWallet) AssociateTransactionWithOrder ¶
func (w *SPVWallet) AssociateTransactionWithOrder(cb wallet.TransactionCallback)
AssociateTransactionWithOrder used for ORDER_PAYMENT message
func (*SPVWallet) ConnectedPeers ¶
func (*SPVWallet) CreateMultisigSignature ¶
func (*SPVWallet) CurrencyCode ¶
func (*SPVWallet) CurrentAddress ¶
func (*SPVWallet) DecodeAddress ¶
func (*SPVWallet) DumpHeaders ¶
func (*SPVWallet) EstimateFee ¶
func (*SPVWallet) EstimateSpendFee ¶
Build a spend transaction for the amount and return the transaction fee
func (*SPVWallet) ExchangeRates ¶
func (w *SPVWallet) ExchangeRates() wallet.ExchangeRates
func (*SPVWallet) GenerateMultisigScript ¶
func (*SPVWallet) GetConfirmations ¶
func (*SPVWallet) GetFeePerByte ¶
func (*SPVWallet) GetTransaction ¶
func (*SPVWallet) ListAddresses ¶
func (*SPVWallet) ListKeys ¶
func (w *SPVWallet) ListKeys() []btcec.PrivateKey
func (*SPVWallet) MasterPrivateKey ¶
func (w *SPVWallet) MasterPrivateKey() *hd.ExtendedKey
func (*SPVWallet) MasterPublicKey ¶
func (w *SPVWallet) MasterPublicKey() *hd.ExtendedKey
func (*SPVWallet) NewAddress ¶
func (*SPVWallet) ReSyncBlockchain ¶
func (*SPVWallet) ScriptToAddress ¶
func (*SPVWallet) SweepAddress ¶
func (*SPVWallet) Transactions ¶
type StoredHeader ¶
type StoredHeader struct {
// contains filtered or unexported fields
}
type TxStore ¶
type TxStore struct { wallet.Datastore // contains filtered or unexported fields }
func NewTxStore ¶
func NewTxStore(p *chaincfg.Params, db wallet.Datastore, keyManager *KeyManager) (*TxStore, error)
func (*TxStore) CheckDoubleSpends ¶
CheckDoubleSpends takes a transaction and compares it with all transactions in the db. It returns a slice of all txids in the db which are double spent by the received tx.
func (*TxStore) GetPendingInv ¶
GetPendingInv returns an inv message containing all txs known to the db which are at height 0 (not known to be confirmed). This can be useful on startup or to rebroadcast unconfirmed txs.
func (*TxStore) GimmeFilter ¶
... or I'm gonna fade away
func (*TxStore) Ingest ¶
Ingest puts a tx into the DB atomically. This can result in a gain, a loss, or no result. Gain or loss in satoshis is returned.
func (*TxStore) PopulateAdrs ¶
PopulateAdrs just puts a bunch of adrs in ram; it doesn't touch the DB
type WireService ¶
type WireService struct {
// contains filtered or unexported fields
}
func NewWireService ¶
func NewWireService(config *WireServiceConfig) *WireService
func (*WireService) Current ¶
func (ws *WireService) Current() bool
func (*WireService) MsgChan ¶
func (ws *WireService) MsgChan() chan interface{}
func (*WireService) Rebroadcast ¶
func (ws *WireService) Rebroadcast()
func (*WireService) Resync ¶
func (ws *WireService) Resync()
func (*WireService) Start ¶
func (ws *WireService) Start()
The start function must be run in its own goroutine. The entire WireService is single threaded which means all messages are processed sequentially removing the need for complex locking.
func (*WireService) Stop ¶
func (ws *WireService) Stop()
type WireServiceConfig ¶
type WireServiceConfig struct {
// contains filtered or unexported fields
}