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 NewOutPointFromString(outpoint string) (*wire.OutPoint, error)
- func SumOutputSerializeSizes(outputs []*wire.TxOut) (serializeSize int)
- func TestStxo_IsEqual(t *testing.T)
- func TestUtxo_IsEqual(t *testing.T)
- type BtcElectrumWallet
- func LoadBtcElectrumWallet(config *wallet.WalletConfig, pw string) (*BtcElectrumWallet, error)
- func MockWallet(pw string) *BtcElectrumWallet
- func NewBtcElectrumWallet(config *wallet.WalletConfig, pw string) (*BtcElectrumWallet, error)
- func RecreateElectrumWallet(config *wallet.WalletConfig, pw, mnemonic string) (*BtcElectrumWallet, error)
- func (w *BtcElectrumWallet) AddSubscription(subcription *wallet.Subscription) error
- func (w *BtcElectrumWallet) AddTransaction(tx *wire.MsgTx, height int64, timestamp time.Time) error
- func (w *BtcElectrumWallet) AddressToScript(address btcutil.Address) ([]byte, error)
- func (w *BtcElectrumWallet) Balance() (int64, int64, int64, error)
- func (w *BtcElectrumWallet) BumpFee(txid string) (*wire.MsgTx, error)
- func (w *BtcElectrumWallet) CreationDate() time.Time
- func (w *BtcElectrumWallet) CurrencyCode() string
- func (w *BtcElectrumWallet) DecodeAddress(addr string) (btcutil.Address, error)
- func (w *BtcElectrumWallet) EstimateFee(ins []wallet.InputInfo, outs []wallet.TransactionOutput, feePerByte int64) int64
- func (w *BtcElectrumWallet) FreezeUTXO(op *wire.OutPoint) error
- func (w *BtcElectrumWallet) GetAddress(kp *wallet.KeyPath) (btcutil.Address, error)
- func (w *BtcElectrumWallet) GetFeePerByte(feeLevel wallet.FeeLevel) int64
- func (w *BtcElectrumWallet) GetPrivKeyForAddress(pw string, address btcutil.Address) (string, error)
- func (w *BtcElectrumWallet) GetSubscription(scriptPubKey string) (*wallet.Subscription, error)
- func (w *BtcElectrumWallet) GetSubscriptionForElectrumScripthash(electrumScripthash string) (*wallet.Subscription, error)
- func (w *BtcElectrumWallet) GetTransaction(txid string) (*wallet.Txn, error)
- func (w *BtcElectrumWallet) GetUnusedAddress(purpose wallet.KeyPurpose) (btcutil.Address, error)
- func (w *BtcElectrumWallet) GetUnusedLegacyAddress() (btcutil.Address, error)
- func (w *BtcElectrumWallet) GetWalletAddressHistory(address btcutil.Address) ([]wallet.AddressHistory, error)
- func (w *BtcElectrumWallet) HasAddress(address btcutil.Address) bool
- func (w *BtcElectrumWallet) HasTransaction(txid string) (bool, *wallet.Txn)
- func (w *BtcElectrumWallet) IsDust(amount int64) bool
- func (w *BtcElectrumWallet) IsMine(queryAddress btcutil.Address) bool
- func (w *BtcElectrumWallet) ListAddresses() []btcutil.Address
- func (w *BtcElectrumWallet) ListConfirmedUnspent() ([]wallet.Utxo, error)
- func (w *BtcElectrumWallet) ListFrozenUnspent() ([]wallet.Utxo, error)
- func (w *BtcElectrumWallet) ListSpent() ([]wallet.Stxo, error)
- func (w *BtcElectrumWallet) ListSubscriptions() ([]*wallet.Subscription, error)
- func (w *BtcElectrumWallet) ListTransactions() ([]wallet.Txn, error)
- func (w *BtcElectrumWallet) ListUnspent() ([]wallet.Utxo, error)
- func (w *BtcElectrumWallet) MarkAddressUsed(address btcutil.Address) error
- func (w *BtcElectrumWallet) Params() *chaincfg.Params
- func (w *BtcElectrumWallet) RemoveSubscription(scriptPubKey string)
- func (w *BtcElectrumWallet) ScriptToAddress(script []byte) (btcutil.Address, error)
- func (w *BtcElectrumWallet) SignTx(pw string, info *wallet.SigningInfo) ([]byte, error)
- func (w *BtcElectrumWallet) Spend(pw string, amount int64, address btcutil.Address, feeLevel wallet.FeeLevel) (int, *wire.MsgTx, error)
- func (w *BtcElectrumWallet) Start()
- func (w *BtcElectrumWallet) SweepCoins(coins []wallet.InputInfo, feeLevel wallet.FeeLevel, maxTxInputs int) ([]*wire.MsgTx, error)
- func (w *BtcElectrumWallet) UnFreezeUTXO(op *wire.OutPoint) error
- func (w *BtcElectrumWallet) UpdateTip(newTip int64)
- type InputType
- type KeyManager
- 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) GetUnusedKey(purpose wallet.KeyPurpose) (*hd.ExtendedKey, error)
- func (km *KeyManager) MarkKeyAsUsed(scriptAddress []byte) error
- type MockDatastore
- func (m *MockDatastore) Cfg() wallet.Cfg
- func (m *MockDatastore) Enc() wallet.Enc
- func (m *MockDatastore) Keys() wallet.Keys
- func (m *MockDatastore) Stxos() wallet.Stxos
- func (m *MockDatastore) Subscriptions() wallet.Subscriptions
- func (m *MockDatastore) Txns() wallet.Txns
- func (m *MockDatastore) Utxos() wallet.Utxos
- type Storage
- type StorageManager
- type SubscriptionManager
- func (sm *SubscriptionManager) Delete(scriptPubKey string) error
- func (sm *SubscriptionManager) Get(scriptPubKey string) (*wallet.Subscription, error)
- func (sm *SubscriptionManager) GetAll() ([]*wallet.Subscription, error)
- func (sm *SubscriptionManager) GetElectrumScripthash(electrumScripthash string) (*wallet.Subscription, error)
- func (sm *SubscriptionManager) Put(subscription *wallet.Subscription) error
- type TxStore
Constants ¶
const ( // PubKeyLength is the length of a serialized compressed public key. PubKeyLength = 33 // 4 bytes version + 4 bytes locktime + 2 bytes of varints for the number of // transaction inputs and outputs MinimumBlockOverHead = 10 // DERSigLength is the maximum length of a DER encoded signature with a // sighash type byte. DERSigLength = 73 // RefundSigScriptSize is the worst case (largest) serialize size // of a transaction input script that refunds 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 DefaultSigScriptSize = 1 + DERSigLength + 1 + 33 // 108 // Overhead for a wire.TxIn. See wire.TxIn.SerializeSize. // hash 32 bytes + index 4 bytes + sequence 4 bytes. TxInOverhead = 32 + 4 + 4 // 40 // TxOutOverhead is the overhead associated with a transaction output. // 8 bytes value + at least 1 byte varint script size TxOutOverhead = 8 + 1 RedeemP2PKSigScriptSize = 1 + DERSigLength // P2SHPkScriptSize is the size of a transaction output script that // pays to a redeem script. It is calculated as: // // - OP_HASH160 // - OP_DATA_20 // - 20 bytes redeem script hash // - OP_EQUAL P2SHPkScriptSize = 1 + 1 + 20 + 1 // P2SHOutputSize is the size of the serialized P2SH output. P2SHOutputSize = TxOutOverhead + P2SHPkScriptSize // 9 + 23 = 32 // P2WSHPkScriptSize is the size of a segwit transaction output script that // pays to a redeem script. It is calculated as: // // - OP_0 // - OP_DATA_32 // - 32 bytes redeem script hash P2WSHPkScriptSize = 1 + 1 + 32 // P2WSHOutputSize is the size of the serialized P2WSH output. P2WSHOutputSize = TxOutOverhead + P2WSHPkScriptSize // 9 + 34 = 43 // RedeemP2WPKHInputSize is the worst case size of a transaction // input redeeming a P2WPKH output. This does not account for witness data, // which is considered at a lower weight for fee calculations. It is // calculated as // // - 32 bytes previous tx // - 4 bytes output index // - 4 bytes sequence // - 1 byte encoding empty redeem script // - 0 bytes signature script RedeemP2WPKHInputSize = TxInOverhead + 1 // RedeemP2WPKHInputWitnessWeight is the worst case weight of // a witness for spending P2WPKH and nested P2WPKH outputs. It // is calculated as: // // - 1 wu compact int encoding value 2 (number of items) // - 1 wu compact int encoding value 73 // - 72 wu DER signature + 1 wu sighash // - 1 wu compact int encoding value 33 // - 33 wu serialized compressed pubkey // NOTE: witness data is not script. RedeemP2WPKHInputWitnessWeight = 1 + 1 + DERSigLength + 1 + 33 // 109 // RedeemP2WPKHInputTotalSize is the worst case size of a transaction // input redeeming a P2WPKH output and the corresponding witness data. // It is calculated as: // // 41 vbytes base tx input // 109wu witness = 28 vbytes // total = 69 vbytes RedeemP2WPKHInputTotalSize = RedeemP2WPKHInputSize + (RedeemP2WPKHInputWitnessWeight+(witnessWeight-1))/witnessWeight // SigwitMarkerAndFlagWeight is the 2 bytes of overhead witness data // added to every segwit transaction. SegwitMarkerAndFlagWeight = 2 // P2WPKHPkScriptSize is the size of a transaction output script that // pays to a witness pubkey hash. It is calculated as: // // - OP_0 // - OP_DATA_20 // - 20 bytes pubkey hash P2WPKHPkScriptSize = 1 + 1 + 20 // P2WPKHOutputSize is the serialize size of a transaction output with a // P2WPKH output script. It is calculated as: // // - 8 bytes output value // - 1 byte compact int encoding value 22 // - 22 bytes P2PKH output script P2WPKHOutputSize = TxOutOverhead + P2WPKHPkScriptSize // 31 // MinimumTxOverhead is the size of an empty transaction. // 4 bytes version + 4 bytes locktime + 2 bytes of varints for the number of // transaction inputs and outputs MinimumTxOverhead = 4 + 4 + 1 + 1 // 10 // InitTxSizeBase is the size of a standard serialized atomic swap // initialization transaction with one change output and no inputs. This is // MsgTx overhead + 1 P2PKH change output + 1 P2SH contract output. However, // the change output might be P2WPKH, in which case it would be smaller. InitTxSizeBase = MinimumTxOverhead + P2PKHOutputSize + P2SHOutputSize // 10 + 34 + 32 = 76 // InitTxSize is InitTxBaseSize + 1 P2PKH input InitTxSize = InitTxSizeBase + RedeemP2PKHInputSize // 76 + 149 = 225 // InitTxSizeBaseSegwit is the size of a standard serialized atomic swap // initialization transaction with one change output and no inputs. The // change output is assumed to be segwit. 10 + 31 + 43 = 84 InitTxSizeBaseSegwit = MinimumTxOverhead + P2WPKHOutputSize + P2WSHOutputSize // InitTxSizeSegwit is InitTxSizeSegwit + 1 P2WPKH input. // 84 vbytes base tx // 41 vbytes base tx input // 109wu witness + 2wu segwit marker and flag = 28 vbytes // total = 153 vbytes InitTxSizeSegwit = InitTxSizeBaseSegwit + RedeemP2WPKHInputSize + (SegwitMarkerAndFlagWeight+RedeemP2WPKHInputWitnessWeight+(witnessWeight-1))/witnessWeight )
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 GAP_LIMIT = client.GAP_LIMIT
Lookahead window size from client constants
const MAX_TX_INPUTS = 50 //TODO: enforce this
const WalletVersion = "0.1.0"
Variables ¶
var ErrEmptyPassword = errors.New("empty password")
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 NewOutPointFromString ¶
NewOutPointFromString returns a new bitcoin transaction outpoint parsed from the provided string, which should be in the format "hash:index".
func SumOutputSerializeSizes ¶
SumOutputSerializeSizes sums up the serialized size of the supplied outputs.
func TestStxo_IsEqual ¶
func TestUtxo_IsEqual ¶
Types ¶
type BtcElectrumWallet ¶
type BtcElectrumWallet struct {
// contains filtered or unexported fields
}
func LoadBtcElectrumWallet ¶
func LoadBtcElectrumWallet(config *wallet.WalletConfig, pw string) (*BtcElectrumWallet, error)
func NewBtcElectrumWallet ¶
func NewBtcElectrumWallet(config *wallet.WalletConfig, pw string) (*BtcElectrumWallet, error)
NewBtcElectrumWallet mskes new wallet with a new seed. The Mnemonic should be saved offline by the user.
func RecreateElectrumWallet ¶
func RecreateElectrumWallet(config *wallet.WalletConfig, pw, mnemonic string) (*BtcElectrumWallet, error)
RecreateElectrumWallet makes new wallet with a mnenomic seed from an existing wallet. pw does not need to be the same as the old wallet
func (*BtcElectrumWallet) AddSubscription ¶
func (w *BtcElectrumWallet) AddSubscription(subcription *wallet.Subscription) error
func (*BtcElectrumWallet) AddTransaction ¶
Add a transaction to the database
func (*BtcElectrumWallet) AddressToScript ¶
func (w *BtcElectrumWallet) AddressToScript(address btcutil.Address) ([]byte, error)
func (*BtcElectrumWallet) Balance ¶
func (w *BtcElectrumWallet) Balance() (int64, int64, int64, error)
func (*BtcElectrumWallet) BumpFee ¶
func (w *BtcElectrumWallet) BumpFee(txid string) (*wire.MsgTx, error)
func (*BtcElectrumWallet) CreationDate ¶
func (w *BtcElectrumWallet) CreationDate() time.Time
func (*BtcElectrumWallet) CurrencyCode ¶
func (w *BtcElectrumWallet) CurrencyCode() string
func (*BtcElectrumWallet) DecodeAddress ¶
func (w *BtcElectrumWallet) DecodeAddress(addr string) (btcutil.Address, error)
func (*BtcElectrumWallet) EstimateFee ¶
func (w *BtcElectrumWallet) EstimateFee( ins []wallet.InputInfo, outs []wallet.TransactionOutput, feePerByte int64) int64
func (*BtcElectrumWallet) FreezeUTXO ¶
func (w *BtcElectrumWallet) FreezeUTXO(op *wire.OutPoint) error
func (*BtcElectrumWallet) GetAddress ¶
GetAddress gets an address given a KeyPath. It is used for Rescan and has no concept of gap-limit. It is expected that keys made here are just temporarily used to generate addresses for rescan.
func (*BtcElectrumWallet) GetFeePerByte ¶
func (w *BtcElectrumWallet) GetFeePerByte(feeLevel wallet.FeeLevel) int64
func (*BtcElectrumWallet) GetPrivKeyForAddress ¶
func (*BtcElectrumWallet) GetSubscription ¶
func (w *BtcElectrumWallet) GetSubscription(scriptPubKey string) (*wallet.Subscription, error)
func (*BtcElectrumWallet) GetSubscriptionForElectrumScripthash ¶
func (w *BtcElectrumWallet) GetSubscriptionForElectrumScripthash(electrumScripthash string) (*wallet.Subscription, error)
func (*BtcElectrumWallet) GetTransaction ¶
func (w *BtcElectrumWallet) GetTransaction(txid string) (*wallet.Txn, error)
func (*BtcElectrumWallet) GetUnusedAddress ¶
func (w *BtcElectrumWallet) GetUnusedAddress(purpose wallet.KeyPurpose) (btcutil.Address, error)
func (*BtcElectrumWallet) GetUnusedLegacyAddress ¶
func (w *BtcElectrumWallet) GetUnusedLegacyAddress() (btcutil.Address, error)
For receiving simple payments from legacy wallets only!
func (*BtcElectrumWallet) GetWalletAddressHistory ¶
func (w *BtcElectrumWallet) GetWalletAddressHistory(address btcutil.Address) ([]wallet.AddressHistory, error)
Return the calculated confirmed txids and heights for an address in this wallet. Currently we get this info from the Node.
func (*BtcElectrumWallet) HasAddress ¶
func (w *BtcElectrumWallet) HasAddress(address btcutil.Address) bool
func (*BtcElectrumWallet) HasTransaction ¶
func (w *BtcElectrumWallet) HasTransaction(txid string) (bool, *wallet.Txn)
func (*BtcElectrumWallet) IsDust ¶
func (w *BtcElectrumWallet) IsDust(amount int64) bool
func (*BtcElectrumWallet) IsMine ¶
func (w *BtcElectrumWallet) IsMine(queryAddress btcutil.Address) bool
func (*BtcElectrumWallet) ListAddresses ¶
func (w *BtcElectrumWallet) ListAddresses() []btcutil.Address
func (*BtcElectrumWallet) ListConfirmedUnspent ¶
func (w *BtcElectrumWallet) ListConfirmedUnspent() ([]wallet.Utxo, error)
func (*BtcElectrumWallet) ListFrozenUnspent ¶
func (w *BtcElectrumWallet) ListFrozenUnspent() ([]wallet.Utxo, error)
func (*BtcElectrumWallet) ListSpent ¶
func (w *BtcElectrumWallet) ListSpent() ([]wallet.Stxo, error)
List all spent
func (*BtcElectrumWallet) ListSubscriptions ¶
func (w *BtcElectrumWallet) ListSubscriptions() ([]*wallet.Subscription, error)
func (*BtcElectrumWallet) ListTransactions ¶
func (w *BtcElectrumWallet) ListTransactions() ([]wallet.Txn, error)
func (*BtcElectrumWallet) ListUnspent ¶
func (w *BtcElectrumWallet) ListUnspent() ([]wallet.Utxo, error)
List all unspent outputs in the wallet
func (*BtcElectrumWallet) MarkAddressUsed ¶
func (w *BtcElectrumWallet) MarkAddressUsed(address btcutil.Address) error
Marks the address as used (involved in at least one transaction)
func (*BtcElectrumWallet) Params ¶
func (w *BtcElectrumWallet) Params() *chaincfg.Params
func (*BtcElectrumWallet) RemoveSubscription ¶
func (w *BtcElectrumWallet) RemoveSubscription(scriptPubKey string)
func (*BtcElectrumWallet) ScriptToAddress ¶
func (w *BtcElectrumWallet) ScriptToAddress(script []byte) (btcutil.Address, error)
func (*BtcElectrumWallet) SignTx ¶
func (w *BtcElectrumWallet) SignTx(pw string, info *wallet.SigningInfo) ([]byte, error)
Sign an unsigned transaction with the wallet
func (*BtcElectrumWallet) Spend ¶
func (w *BtcElectrumWallet) Spend( pw string, amount int64, address btcutil.Address, feeLevel wallet.FeeLevel) (int, *wire.MsgTx, error)
Spend creates and signs a new transaction from wallet coins
func (*BtcElectrumWallet) Start ¶
func (w *BtcElectrumWallet) Start()
func (*BtcElectrumWallet) SweepCoins ¶
func (*BtcElectrumWallet) UnFreezeUTXO ¶
func (w *BtcElectrumWallet) UnFreezeUTXO(op *wire.OutPoint) error
func (*BtcElectrumWallet) UpdateTip ¶
func (w *BtcElectrumWallet) UpdateTip(newTip int64)
Update the wallet's view of the blockchain
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) 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) GetUnusedKey ¶
func (km *KeyManager) GetUnusedKey(purpose wallet.KeyPurpose) (*hd.ExtendedKey, error)
GetUnusedKey gets the first unused key for 'purpose'. CAUTION: There may not be any keys within the gap limit. In this case a used key can be utilized or user can wait until the gap is updated with new key(s). This happens when a transaction newly gets client.AGEDTX confirmations.
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) Cfg ¶
func (m *MockDatastore) Cfg() wallet.Cfg
func (*MockDatastore) Enc ¶
func (m *MockDatastore) Enc() wallet.Enc
func (*MockDatastore) Keys ¶
func (m *MockDatastore) Keys() wallet.Keys
func (*MockDatastore) Stxos ¶
func (m *MockDatastore) Stxos() wallet.Stxos
func (*MockDatastore) Subscriptions ¶
func (m *MockDatastore) Subscriptions() wallet.Subscriptions
func (*MockDatastore) Txns ¶
func (m *MockDatastore) Txns() wallet.Txns
func (*MockDatastore) Utxos ¶
func (m *MockDatastore) Utxos() wallet.Utxos
type Storage ¶
type StorageManager ¶
type StorageManager struct {
// contains filtered or unexported fields
}
func NewStorageManager ¶
func NewStorageManager(db wallet.Enc, params *chaincfg.Params) *StorageManager
func (*StorageManager) Get ¶
func (sm *StorageManager) Get(pw string) error
func (*StorageManager) IsValidPw ¶
func (sm *StorageManager) IsValidPw(pw string) bool
func (*StorageManager) Put ¶
func (sm *StorageManager) Put(pw string) error
type SubscriptionManager ¶
type SubscriptionManager struct {
// contains filtered or unexported fields
}
func NewSubscriptionManager ¶
func NewSubscriptionManager(db wallet.Subscriptions, params *chaincfg.Params) *SubscriptionManager
func (*SubscriptionManager) Delete ¶
func (sm *SubscriptionManager) Delete(scriptPubKey string) error
func (*SubscriptionManager) Get ¶
func (sm *SubscriptionManager) Get(scriptPubKey string) (*wallet.Subscription, error)
func (*SubscriptionManager) GetAll ¶
func (sm *SubscriptionManager) GetAll() ([]*wallet.Subscription, error)
func (*SubscriptionManager) GetElectrumScripthash ¶
func (sm *SubscriptionManager) GetElectrumScripthash(electrumScripthash string) (*wallet.Subscription, error)
func (*SubscriptionManager) Put ¶
func (sm *SubscriptionManager) Put(subscription *wallet.Subscription) error
type TxStore ¶
func NewTxStore ¶
func (*TxStore) AddTransaction ¶
func (ts *TxStore) AddTransaction(tx *wire.MsgTx, height int64, timestamp time.Time) (uint32, error)
AddTransaction puts a tx into the database.
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) PopulateAdrs ¶
func (ts *TxStore) PopulateAdrs()
PopulateAdrs makes a list of addresses from the key-index pairs we have in the database. The key-pairs we have stored are returned in index order. PopulateAdrs also makes an up to date list of txs in the database. It never mutates the db.