repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
btcsuite/btcwallet | wallet/wallet.go | PublishTransaction | func (w *Wallet) PublishTransaction(tx *wire.MsgTx) error {
_, err := w.reliablyPublishTransaction(tx)
return err
} | go | func (w *Wallet) PublishTransaction(tx *wire.MsgTx) error {
_, err := w.reliablyPublishTransaction(tx)
return err
} | [
"func",
"(",
"w",
"*",
"Wallet",
")",
"PublishTransaction",
"(",
"tx",
"*",
"wire",
".",
"MsgTx",
")",
"error",
"{",
"_",
",",
"err",
":=",
"w",
".",
"reliablyPublishTransaction",
"(",
"tx",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // PublishTransaction sends the transaction to the consensus RPC server so it
// can be propagated to other nodes and eventually mined.
//
// This function is unstable and will be removed once syncing code is moved out
// of the wallet. | [
"PublishTransaction",
"sends",
"the",
"transaction",
"to",
"the",
"consensus",
"RPC",
"server",
"so",
"it",
"can",
"be",
"propagated",
"to",
"other",
"nodes",
"and",
"eventually",
"mined",
".",
"This",
"function",
"is",
"unstable",
"and",
"will",
"be",
"remove... | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/wallet/wallet.go#L3346-L3349 | train |
btcsuite/btcwallet | wallet/wallet.go | publishTransaction | func (w *Wallet) publishTransaction(tx *wire.MsgTx) (*chainhash.Hash, error) {
chainClient, err := w.requireChainClient()
if err != nil {
return nil, err
}
txid, err := chainClient.SendRawTransaction(tx, false)
switch {
case err == nil:
return txid, nil
// Since we have different backends that can be used ... | go | func (w *Wallet) publishTransaction(tx *wire.MsgTx) (*chainhash.Hash, error) {
chainClient, err := w.requireChainClient()
if err != nil {
return nil, err
}
txid, err := chainClient.SendRawTransaction(tx, false)
switch {
case err == nil:
return txid, nil
// Since we have different backends that can be used ... | [
"func",
"(",
"w",
"*",
"Wallet",
")",
"publishTransaction",
"(",
"tx",
"*",
"wire",
".",
"MsgTx",
")",
"(",
"*",
"chainhash",
".",
"Hash",
",",
"error",
")",
"{",
"chainClient",
",",
"err",
":=",
"w",
".",
"requireChainClient",
"(",
")",
"\n",
"if",
... | // publishTransaction attempts to send an unconfirmed transaction to the
// wallet's current backend. In the event that sending the transaction fails for
// whatever reason, it will be removed from the wallet's unconfirmed transaction
// store. | [
"publishTransaction",
"attempts",
"to",
"send",
"an",
"unconfirmed",
"transaction",
"to",
"the",
"wallet",
"s",
"current",
"backend",
".",
"In",
"the",
"event",
"that",
"sending",
"the",
"transaction",
"fails",
"for",
"whatever",
"reason",
"it",
"will",
"be",
... | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/wallet/wallet.go#L3410-L3492 | train |
btcsuite/btcwallet | wallet/wallet.go | Create | func Create(db walletdb.DB, pubPass, privPass, seed []byte, params *chaincfg.Params,
birthday time.Time) error {
// If a seed was provided, ensure that it is of valid length. Otherwise,
// we generate a random seed for the wallet with the recommended seed
// length.
if seed == nil {
hdSeed, err := hdkeychain.Ge... | go | func Create(db walletdb.DB, pubPass, privPass, seed []byte, params *chaincfg.Params,
birthday time.Time) error {
// If a seed was provided, ensure that it is of valid length. Otherwise,
// we generate a random seed for the wallet with the recommended seed
// length.
if seed == nil {
hdSeed, err := hdkeychain.Ge... | [
"func",
"Create",
"(",
"db",
"walletdb",
".",
"DB",
",",
"pubPass",
",",
"privPass",
",",
"seed",
"[",
"]",
"byte",
",",
"params",
"*",
"chaincfg",
".",
"Params",
",",
"birthday",
"time",
".",
"Time",
")",
"error",
"{",
"// If a seed was provided, ensure t... | // Create creates an new wallet, writing it to an empty database. If the passed
// seed is non-nil, it is used. Otherwise, a secure random seed of the
// recommended length is generated. | [
"Create",
"creates",
"an",
"new",
"wallet",
"writing",
"it",
"to",
"an",
"empty",
"database",
".",
"If",
"the",
"passed",
"seed",
"is",
"non",
"-",
"nil",
"it",
"is",
"used",
".",
"Otherwise",
"a",
"secure",
"random",
"seed",
"of",
"the",
"recommended",
... | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/wallet/wallet.go#L3510-L3548 | train |
btcsuite/btcwallet | wallet/wallet.go | Open | func Open(db walletdb.DB, pubPass []byte, cbs *waddrmgr.OpenCallbacks,
params *chaincfg.Params, recoveryWindow uint32) (*Wallet, error) {
var (
addrMgr *waddrmgr.Manager
txMgr *wtxmgr.Store
)
// Before attempting to open the wallet, we'll check if there are any
// database upgrades for us to proceed. We'll... | go | func Open(db walletdb.DB, pubPass []byte, cbs *waddrmgr.OpenCallbacks,
params *chaincfg.Params, recoveryWindow uint32) (*Wallet, error) {
var (
addrMgr *waddrmgr.Manager
txMgr *wtxmgr.Store
)
// Before attempting to open the wallet, we'll check if there are any
// database upgrades for us to proceed. We'll... | [
"func",
"Open",
"(",
"db",
"walletdb",
".",
"DB",
",",
"pubPass",
"[",
"]",
"byte",
",",
"cbs",
"*",
"waddrmgr",
".",
"OpenCallbacks",
",",
"params",
"*",
"chaincfg",
".",
"Params",
",",
"recoveryWindow",
"uint32",
")",
"(",
"*",
"Wallet",
",",
"error"... | // Open loads an already-created wallet from the passed database and namespaces. | [
"Open",
"loads",
"an",
"already",
"-",
"created",
"wallet",
"from",
"the",
"passed",
"database",
"and",
"namespaces",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/wallet/wallet.go#L3551-L3626 | train |
btcsuite/btcwallet | internal/helpers/helpers.go | SumOutputValues | func SumOutputValues(outputs []*wire.TxOut) (totalOutput btcutil.Amount) {
for _, txOut := range outputs {
totalOutput += btcutil.Amount(txOut.Value)
}
return totalOutput
} | go | func SumOutputValues(outputs []*wire.TxOut) (totalOutput btcutil.Amount) {
for _, txOut := range outputs {
totalOutput += btcutil.Amount(txOut.Value)
}
return totalOutput
} | [
"func",
"SumOutputValues",
"(",
"outputs",
"[",
"]",
"*",
"wire",
".",
"TxOut",
")",
"(",
"totalOutput",
"btcutil",
".",
"Amount",
")",
"{",
"for",
"_",
",",
"txOut",
":=",
"range",
"outputs",
"{",
"totalOutput",
"+=",
"btcutil",
".",
"Amount",
"(",
"t... | // SumOutputValues sums up the list of TxOuts and returns an Amount. | [
"SumOutputValues",
"sums",
"up",
"the",
"list",
"of",
"TxOuts",
"and",
"returns",
"an",
"Amount",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/internal/helpers/helpers.go#L15-L20 | train |
btcsuite/btcwallet | internal/helpers/helpers.go | SumOutputSerializeSizes | func SumOutputSerializeSizes(outputs []*wire.TxOut) (serializeSize int) {
for _, txOut := range outputs {
serializeSize += txOut.SerializeSize()
}
return serializeSize
} | go | func SumOutputSerializeSizes(outputs []*wire.TxOut) (serializeSize int) {
for _, txOut := range outputs {
serializeSize += txOut.SerializeSize()
}
return serializeSize
} | [
"func",
"SumOutputSerializeSizes",
"(",
"outputs",
"[",
"]",
"*",
"wire",
".",
"TxOut",
")",
"(",
"serializeSize",
"int",
")",
"{",
"for",
"_",
",",
"txOut",
":=",
"range",
"outputs",
"{",
"serializeSize",
"+=",
"txOut",
".",
"SerializeSize",
"(",
")",
"... | // SumOutputSerializeSizes sums up the serialized size of the supplied outputs. | [
"SumOutputSerializeSizes",
"sums",
"up",
"the",
"serialized",
"size",
"of",
"the",
"supplied",
"outputs",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/internal/helpers/helpers.go#L23-L28 | train |
btcsuite/btcwallet | wallet/unstable.go | TxDetails | func (u unstableAPI) TxDetails(txHash *chainhash.Hash) (*wtxmgr.TxDetails, error) {
var details *wtxmgr.TxDetails
err := walletdb.View(u.w.db, func(dbtx walletdb.ReadTx) error {
txmgrNs := dbtx.ReadBucket(wtxmgrNamespaceKey)
var err error
details, err = u.w.TxStore.TxDetails(txmgrNs, txHash)
return err
})
r... | go | func (u unstableAPI) TxDetails(txHash *chainhash.Hash) (*wtxmgr.TxDetails, error) {
var details *wtxmgr.TxDetails
err := walletdb.View(u.w.db, func(dbtx walletdb.ReadTx) error {
txmgrNs := dbtx.ReadBucket(wtxmgrNamespaceKey)
var err error
details, err = u.w.TxStore.TxDetails(txmgrNs, txHash)
return err
})
r... | [
"func",
"(",
"u",
"unstableAPI",
")",
"TxDetails",
"(",
"txHash",
"*",
"chainhash",
".",
"Hash",
")",
"(",
"*",
"wtxmgr",
".",
"TxDetails",
",",
"error",
")",
"{",
"var",
"details",
"*",
"wtxmgr",
".",
"TxDetails",
"\n",
"err",
":=",
"walletdb",
".",
... | // TxDetails calls wtxmgr.Store.TxDetails under a single database view transaction. | [
"TxDetails",
"calls",
"wtxmgr",
".",
"Store",
".",
"TxDetails",
"under",
"a",
"single",
"database",
"view",
"transaction",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/wallet/unstable.go#L26-L35 | train |
btcsuite/btcwallet | wallet/unstable.go | RangeTransactions | func (u unstableAPI) RangeTransactions(begin, end int32, f func([]wtxmgr.TxDetails) (bool, error)) error {
return walletdb.View(u.w.db, func(dbtx walletdb.ReadTx) error {
txmgrNs := dbtx.ReadBucket(wtxmgrNamespaceKey)
return u.w.TxStore.RangeTransactions(txmgrNs, begin, end, f)
})
} | go | func (u unstableAPI) RangeTransactions(begin, end int32, f func([]wtxmgr.TxDetails) (bool, error)) error {
return walletdb.View(u.w.db, func(dbtx walletdb.ReadTx) error {
txmgrNs := dbtx.ReadBucket(wtxmgrNamespaceKey)
return u.w.TxStore.RangeTransactions(txmgrNs, begin, end, f)
})
} | [
"func",
"(",
"u",
"unstableAPI",
")",
"RangeTransactions",
"(",
"begin",
",",
"end",
"int32",
",",
"f",
"func",
"(",
"[",
"]",
"wtxmgr",
".",
"TxDetails",
")",
"(",
"bool",
",",
"error",
")",
")",
"error",
"{",
"return",
"walletdb",
".",
"View",
"(",... | // RangeTransactions calls wtxmgr.Store.RangeTransactions under a single
// database view tranasction. | [
"RangeTransactions",
"calls",
"wtxmgr",
".",
"Store",
".",
"RangeTransactions",
"under",
"a",
"single",
"database",
"view",
"tranasction",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/wallet/unstable.go#L39-L44 | train |
btcsuite/btcwallet | cmd/sweepaccount/main.go | init | func init() {
// Unset localhost defaults if certificate file can not be found.
certFileExists, err := cfgutil.FileExists(opts.RPCCertificateFile)
if err != nil {
fatalf("%v", err)
}
if !certFileExists {
opts.RPCConnect = ""
opts.RPCCertificateFile = ""
}
_, err = flags.Parse(&opts)
if err != nil {
os.... | go | func init() {
// Unset localhost defaults if certificate file can not be found.
certFileExists, err := cfgutil.FileExists(opts.RPCCertificateFile)
if err != nil {
fatalf("%v", err)
}
if !certFileExists {
opts.RPCConnect = ""
opts.RPCCertificateFile = ""
}
_, err = flags.Parse(&opts)
if err != nil {
os.... | [
"func",
"init",
"(",
")",
"{",
"// Unset localhost defaults if certificate file can not be found.",
"certFileExists",
",",
"err",
":=",
"cfgutil",
".",
"FileExists",
"(",
"opts",
".",
"RPCCertificateFile",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"fatalf",
"(",
"... | // Parse and validate flags. | [
"Parse",
"and",
"validate",
"flags",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/cmd/sweepaccount/main.go#L67-L126 | train |
btcsuite/btcwallet | cmd/sweepaccount/main.go | makeInputSource | func makeInputSource(outputs []btcjson.ListUnspentResult) txauthor.InputSource {
var (
totalInputValue btcutil.Amount
inputs = make([]*wire.TxIn, 0, len(outputs))
inputValues = make([]btcutil.Amount, 0, len(outputs))
sourceErr error
)
for _, output := range outputs {
outputAmount, err :=... | go | func makeInputSource(outputs []btcjson.ListUnspentResult) txauthor.InputSource {
var (
totalInputValue btcutil.Amount
inputs = make([]*wire.TxIn, 0, len(outputs))
inputValues = make([]btcutil.Amount, 0, len(outputs))
sourceErr error
)
for _, output := range outputs {
outputAmount, err :=... | [
"func",
"makeInputSource",
"(",
"outputs",
"[",
"]",
"btcjson",
".",
"ListUnspentResult",
")",
"txauthor",
".",
"InputSource",
"{",
"var",
"(",
"totalInputValue",
"btcutil",
".",
"Amount",
"\n",
"inputs",
"=",
"make",
"(",
"[",
"]",
"*",
"wire",
".",
"TxIn... | // makeInputSource creates an InputSource that creates inputs for every unspent
// output with non-zero output values. The target amount is ignored since every
// output is consumed. The InputSource does not return any previous output
// scripts as they are not needed for creating the unsinged transaction and are
// ... | [
"makeInputSource",
"creates",
"an",
"InputSource",
"that",
"creates",
"inputs",
"for",
"every",
"unspent",
"output",
"with",
"non",
"-",
"zero",
"output",
"values",
".",
"The",
"target",
"amount",
"is",
"ignored",
"since",
"every",
"output",
"is",
"consumed",
... | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/cmd/sweepaccount/main.go#L141-L186 | train |
btcsuite/btcwallet | cmd/sweepaccount/main.go | makeDestinationScriptSource | func makeDestinationScriptSource(rpcClient *rpcclient.Client, accountName string) txauthor.ChangeSource {
return func() ([]byte, error) {
destinationAddress, err := rpcClient.GetNewAddress(accountName)
if err != nil {
return nil, err
}
return txscript.PayToAddrScript(destinationAddress)
}
} | go | func makeDestinationScriptSource(rpcClient *rpcclient.Client, accountName string) txauthor.ChangeSource {
return func() ([]byte, error) {
destinationAddress, err := rpcClient.GetNewAddress(accountName)
if err != nil {
return nil, err
}
return txscript.PayToAddrScript(destinationAddress)
}
} | [
"func",
"makeDestinationScriptSource",
"(",
"rpcClient",
"*",
"rpcclient",
".",
"Client",
",",
"accountName",
"string",
")",
"txauthor",
".",
"ChangeSource",
"{",
"return",
"func",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"destinationAddress",
... | // makeDestinationScriptSource creates a ChangeSource which is used to receive
// all correlated previous input value. A non-change address is created by this
// function. | [
"makeDestinationScriptSource",
"creates",
"a",
"ChangeSource",
"which",
"is",
"used",
"to",
"receive",
"all",
"correlated",
"previous",
"input",
"value",
".",
"A",
"non",
"-",
"change",
"address",
"is",
"created",
"by",
"this",
"function",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/cmd/sweepaccount/main.go#L191-L199 | train |
btcsuite/btcwallet | wallet/txauthor/author.go | RandomizeOutputPosition | func RandomizeOutputPosition(outputs []*wire.TxOut, index int) int {
r := cprng.Int31n(int32(len(outputs)))
outputs[r], outputs[index] = outputs[index], outputs[r]
return int(r)
} | go | func RandomizeOutputPosition(outputs []*wire.TxOut, index int) int {
r := cprng.Int31n(int32(len(outputs)))
outputs[r], outputs[index] = outputs[index], outputs[r]
return int(r)
} | [
"func",
"RandomizeOutputPosition",
"(",
"outputs",
"[",
"]",
"*",
"wire",
".",
"TxOut",
",",
"index",
"int",
")",
"int",
"{",
"r",
":=",
"cprng",
".",
"Int31n",
"(",
"int32",
"(",
"len",
"(",
"outputs",
")",
")",
")",
"\n",
"outputs",
"[",
"r",
"]"... | // RandomizeOutputPosition randomizes the position of a transaction's output by
// swapping it with a random output. The new index is returned. This should be
// done before signing. | [
"RandomizeOutputPosition",
"randomizes",
"the",
"position",
"of",
"a",
"transaction",
"s",
"output",
"by",
"swapping",
"it",
"with",
"a",
"random",
"output",
".",
"The",
"new",
"index",
"is",
"returned",
".",
"This",
"should",
"be",
"done",
"before",
"signing"... | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/wallet/txauthor/author.go#L158-L162 | train |
btcsuite/btcwallet | wallet/txauthor/author.go | RandomizeChangePosition | func (tx *AuthoredTx) RandomizeChangePosition() {
tx.ChangeIndex = RandomizeOutputPosition(tx.Tx.TxOut, tx.ChangeIndex)
} | go | func (tx *AuthoredTx) RandomizeChangePosition() {
tx.ChangeIndex = RandomizeOutputPosition(tx.Tx.TxOut, tx.ChangeIndex)
} | [
"func",
"(",
"tx",
"*",
"AuthoredTx",
")",
"RandomizeChangePosition",
"(",
")",
"{",
"tx",
".",
"ChangeIndex",
"=",
"RandomizeOutputPosition",
"(",
"tx",
".",
"Tx",
".",
"TxOut",
",",
"tx",
".",
"ChangeIndex",
")",
"\n",
"}"
] | // RandomizeChangePosition randomizes the position of an authored transaction's
// change output. This should be done before signing. | [
"RandomizeChangePosition",
"randomizes",
"the",
"position",
"of",
"an",
"authored",
"transaction",
"s",
"change",
"output",
".",
"This",
"should",
"be",
"done",
"before",
"signing",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/wallet/txauthor/author.go#L166-L168 | train |
btcsuite/btcwallet | wallet/txauthor/author.go | AddAllInputScripts | func AddAllInputScripts(tx *wire.MsgTx, prevPkScripts [][]byte, inputValues []btcutil.Amount,
secrets SecretsSource) error {
inputs := tx.TxIn
hashCache := txscript.NewTxSigHashes(tx)
chainParams := secrets.ChainParams()
if len(inputs) != len(prevPkScripts) {
return errors.New("tx.TxIn and prevPkScripts slices... | go | func AddAllInputScripts(tx *wire.MsgTx, prevPkScripts [][]byte, inputValues []btcutil.Amount,
secrets SecretsSource) error {
inputs := tx.TxIn
hashCache := txscript.NewTxSigHashes(tx)
chainParams := secrets.ChainParams()
if len(inputs) != len(prevPkScripts) {
return errors.New("tx.TxIn and prevPkScripts slices... | [
"func",
"AddAllInputScripts",
"(",
"tx",
"*",
"wire",
".",
"MsgTx",
",",
"prevPkScripts",
"[",
"]",
"[",
"]",
"byte",
",",
"inputValues",
"[",
"]",
"btcutil",
".",
"Amount",
",",
"secrets",
"SecretsSource",
")",
"error",
"{",
"inputs",
":=",
"tx",
".",
... | // AddAllInputScripts modifies transaction a transaction by adding inputs
// scripts for each input. Previous output scripts being redeemed by each input
// are passed in prevPkScripts and the slice length must match the number of
// inputs. Private keys and redeem scripts are looked up using a SecretsSource
// based... | [
"AddAllInputScripts",
"modifies",
"transaction",
"a",
"transaction",
"by",
"adding",
"inputs",
"scripts",
"for",
"each",
"input",
".",
"Previous",
"output",
"scripts",
"being",
"redeemed",
"by",
"each",
"input",
"are",
"passed",
"in",
"prevPkScripts",
"and",
"the"... | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/wallet/txauthor/author.go#L192-L239 | train |
btcsuite/btcwallet | wallet/txauthor/author.go | AddAllInputScripts | func (tx *AuthoredTx) AddAllInputScripts(secrets SecretsSource) error {
return AddAllInputScripts(tx.Tx, tx.PrevScripts, tx.PrevInputValues, secrets)
} | go | func (tx *AuthoredTx) AddAllInputScripts(secrets SecretsSource) error {
return AddAllInputScripts(tx.Tx, tx.PrevScripts, tx.PrevInputValues, secrets)
} | [
"func",
"(",
"tx",
"*",
"AuthoredTx",
")",
"AddAllInputScripts",
"(",
"secrets",
"SecretsSource",
")",
"error",
"{",
"return",
"AddAllInputScripts",
"(",
"tx",
".",
"Tx",
",",
"tx",
".",
"PrevScripts",
",",
"tx",
".",
"PrevInputValues",
",",
"secrets",
")",
... | // AddAllInputScripts modifies an authored transaction by adding inputs scripts
// for each input of an authored transaction. Private keys and redeem scripts
// are looked up using a SecretsSource based on the previous output script. | [
"AddAllInputScripts",
"modifies",
"an",
"authored",
"transaction",
"by",
"adding",
"inputs",
"scripts",
"for",
"each",
"input",
"of",
"an",
"authored",
"transaction",
".",
"Private",
"keys",
"and",
"redeem",
"scripts",
"are",
"looked",
"up",
"using",
"a",
"Secre... | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/wallet/txauthor/author.go#L359-L361 | train |
btcsuite/btcwallet | wallet/utxos.go | UnspentOutputs | func (w *Wallet) UnspentOutputs(policy OutputSelectionPolicy) ([]*TransactionOutput, error) {
var outputResults []*TransactionOutput
err := walletdb.View(w.db, func(tx walletdb.ReadTx) error {
addrmgrNs := tx.ReadBucket(waddrmgrNamespaceKey)
txmgrNs := tx.ReadBucket(wtxmgrNamespaceKey)
syncBlock := w.Manager.S... | go | func (w *Wallet) UnspentOutputs(policy OutputSelectionPolicy) ([]*TransactionOutput, error) {
var outputResults []*TransactionOutput
err := walletdb.View(w.db, func(tx walletdb.ReadTx) error {
addrmgrNs := tx.ReadBucket(waddrmgrNamespaceKey)
txmgrNs := tx.ReadBucket(wtxmgrNamespaceKey)
syncBlock := w.Manager.S... | [
"func",
"(",
"w",
"*",
"Wallet",
")",
"UnspentOutputs",
"(",
"policy",
"OutputSelectionPolicy",
")",
"(",
"[",
"]",
"*",
"TransactionOutput",
",",
"error",
")",
"{",
"var",
"outputResults",
"[",
"]",
"*",
"TransactionOutput",
"\n",
"err",
":=",
"walletdb",
... | // UnspentOutputs fetches all unspent outputs from the wallet that match rules
// described in the passed policy. | [
"UnspentOutputs",
"fetches",
"all",
"unspent",
"outputs",
"from",
"the",
"wallet",
"that",
"match",
"rules",
"described",
"in",
"the",
"passed",
"policy",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/wallet/utxos.go#L27-L90 | train |
btcsuite/btcwallet | waddrmgr/manager.go | defaultNewSecretKey | func defaultNewSecretKey(passphrase *[]byte,
config *ScryptOptions) (*snacl.SecretKey, error) {
return snacl.NewSecretKey(passphrase, config.N, config.R, config.P)
} | go | func defaultNewSecretKey(passphrase *[]byte,
config *ScryptOptions) (*snacl.SecretKey, error) {
return snacl.NewSecretKey(passphrase, config.N, config.R, config.P)
} | [
"func",
"defaultNewSecretKey",
"(",
"passphrase",
"*",
"[",
"]",
"byte",
",",
"config",
"*",
"ScryptOptions",
")",
"(",
"*",
"snacl",
".",
"SecretKey",
",",
"error",
")",
"{",
"return",
"snacl",
".",
"NewSecretKey",
"(",
"passphrase",
",",
"config",
".",
... | // defaultNewSecretKey returns a new secret key. See newSecretKey. | [
"defaultNewSecretKey",
"returns",
"a",
"new",
"secret",
"key",
".",
"See",
"newSecretKey",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/manager.go#L183-L186 | train |
btcsuite/btcwallet | waddrmgr/manager.go | SetSecretKeyGen | func SetSecretKeyGen(keyGen SecretKeyGenerator) SecretKeyGenerator {
secretKeyGenMtx.Lock()
oldKeyGen := secretKeyGen
secretKeyGen = keyGen
secretKeyGenMtx.Unlock()
return oldKeyGen
} | go | func SetSecretKeyGen(keyGen SecretKeyGenerator) SecretKeyGenerator {
secretKeyGenMtx.Lock()
oldKeyGen := secretKeyGen
secretKeyGen = keyGen
secretKeyGenMtx.Unlock()
return oldKeyGen
} | [
"func",
"SetSecretKeyGen",
"(",
"keyGen",
"SecretKeyGenerator",
")",
"SecretKeyGenerator",
"{",
"secretKeyGenMtx",
".",
"Lock",
"(",
")",
"\n",
"oldKeyGen",
":=",
"secretKeyGen",
"\n",
"secretKeyGen",
"=",
"keyGen",
"\n",
"secretKeyGenMtx",
".",
"Unlock",
"(",
")"... | // SetSecretKeyGen replaces the existing secret key generator, and returns the
// previous generator. | [
"SetSecretKeyGen",
"replaces",
"the",
"existing",
"secret",
"key",
"generator",
"and",
"returns",
"the",
"previous",
"generator",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/manager.go#L200-L207 | train |
btcsuite/btcwallet | waddrmgr/manager.go | newSecretKey | func newSecretKey(passphrase *[]byte,
config *ScryptOptions) (*snacl.SecretKey, error) {
secretKeyGenMtx.RLock()
defer secretKeyGenMtx.RUnlock()
return secretKeyGen(passphrase, config)
} | go | func newSecretKey(passphrase *[]byte,
config *ScryptOptions) (*snacl.SecretKey, error) {
secretKeyGenMtx.RLock()
defer secretKeyGenMtx.RUnlock()
return secretKeyGen(passphrase, config)
} | [
"func",
"newSecretKey",
"(",
"passphrase",
"*",
"[",
"]",
"byte",
",",
"config",
"*",
"ScryptOptions",
")",
"(",
"*",
"snacl",
".",
"SecretKey",
",",
"error",
")",
"{",
"secretKeyGenMtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"secretKeyGenMtx",
".",
"RU... | // newSecretKey generates a new secret key using the active secretKeyGen. | [
"newSecretKey",
"generates",
"a",
"new",
"secret",
"key",
"using",
"the",
"active",
"secretKeyGen",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/manager.go#L210-L216 | train |
btcsuite/btcwallet | waddrmgr/manager.go | defaultNewCryptoKey | func defaultNewCryptoKey() (EncryptorDecryptor, error) {
key, err := snacl.GenerateCryptoKey()
if err != nil {
return nil, err
}
return &cryptoKey{*key}, nil
} | go | func defaultNewCryptoKey() (EncryptorDecryptor, error) {
key, err := snacl.GenerateCryptoKey()
if err != nil {
return nil, err
}
return &cryptoKey{*key}, nil
} | [
"func",
"defaultNewCryptoKey",
"(",
")",
"(",
"EncryptorDecryptor",
",",
"error",
")",
"{",
"key",
",",
"err",
":=",
"snacl",
".",
"GenerateCryptoKey",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return... | // defaultNewCryptoKey returns a new CryptoKey. See newCryptoKey. | [
"defaultNewCryptoKey",
"returns",
"a",
"new",
"CryptoKey",
".",
"See",
"newCryptoKey",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/manager.go#L244-L250 | train |
btcsuite/btcwallet | waddrmgr/manager.go | WatchOnly | func (m *Manager) WatchOnly() bool {
m.mtx.RLock()
defer m.mtx.RUnlock()
return m.watchOnly()
} | go | func (m *Manager) WatchOnly() bool {
m.mtx.RLock()
defer m.mtx.RUnlock()
return m.watchOnly()
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"WatchOnly",
"(",
")",
"bool",
"{",
"m",
".",
"mtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"m",
".",
"mtx",
".",
"RUnlock",
"(",
")",
"\n\n",
"return",
"m",
".",
"watchOnly",
"(",
")",
"\n",
"}"
] | // WatchOnly returns true if the root manager is in watch only mode, and false
// otherwise. | [
"WatchOnly",
"returns",
"true",
"if",
"the",
"root",
"manager",
"is",
"in",
"watch",
"only",
"mode",
"and",
"false",
"otherwise",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/manager.go#L336-L341 | train |
btcsuite/btcwallet | waddrmgr/manager.go | lock | func (m *Manager) lock() {
for _, manager := range m.scopedManagers {
// Clear all of the account private keys.
for _, acctInfo := range manager.acctInfo {
if acctInfo.acctKeyPriv != nil {
acctInfo.acctKeyPriv.Zero()
}
acctInfo.acctKeyPriv = nil
}
}
// Remove clear text private keys and scripts f... | go | func (m *Manager) lock() {
for _, manager := range m.scopedManagers {
// Clear all of the account private keys.
for _, acctInfo := range manager.acctInfo {
if acctInfo.acctKeyPriv != nil {
acctInfo.acctKeyPriv.Zero()
}
acctInfo.acctKeyPriv = nil
}
}
// Remove clear text private keys and scripts f... | [
"func",
"(",
"m",
"*",
"Manager",
")",
"lock",
"(",
")",
"{",
"for",
"_",
",",
"manager",
":=",
"range",
"m",
".",
"scopedManagers",
"{",
"// Clear all of the account private keys.",
"for",
"_",
",",
"acctInfo",
":=",
"range",
"manager",
".",
"acctInfo",
"... | // lock performs a best try effort to remove and zero all secret keys associated
// with the address manager.
//
// This function MUST be called with the manager lock held for writes. | [
"lock",
"performs",
"a",
"best",
"try",
"effort",
"to",
"remove",
"and",
"zero",
"all",
"secret",
"keys",
"associated",
"with",
"the",
"address",
"manager",
".",
"This",
"function",
"MUST",
"be",
"called",
"with",
"the",
"manager",
"lock",
"held",
"for",
"... | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/manager.go#L355-L392 | train |
btcsuite/btcwallet | waddrmgr/manager.go | FetchScopedKeyManager | func (m *Manager) FetchScopedKeyManager(scope KeyScope) (*ScopedKeyManager, error) {
m.mtx.RLock()
defer m.mtx.RUnlock()
sm, ok := m.scopedManagers[scope]
if !ok {
str := fmt.Sprintf("scope %v not found", scope)
return nil, managerError(ErrScopeNotFound, str, nil)
}
return sm, nil
} | go | func (m *Manager) FetchScopedKeyManager(scope KeyScope) (*ScopedKeyManager, error) {
m.mtx.RLock()
defer m.mtx.RUnlock()
sm, ok := m.scopedManagers[scope]
if !ok {
str := fmt.Sprintf("scope %v not found", scope)
return nil, managerError(ErrScopeNotFound, str, nil)
}
return sm, nil
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"FetchScopedKeyManager",
"(",
"scope",
"KeyScope",
")",
"(",
"*",
"ScopedKeyManager",
",",
"error",
")",
"{",
"m",
".",
"mtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"m",
".",
"mtx",
".",
"RUnlock",
"(",
")",
... | // FetchScopedKeyManager attempts to fetch an active scoped manager according to
// its registered scope. If the manger is found, then a nil error is returned
// along with the active scoped manager. Otherwise, a nil manager and a non-nil
// error will be returned. | [
"FetchScopedKeyManager",
"attempts",
"to",
"fetch",
"an",
"active",
"scoped",
"manager",
"according",
"to",
"its",
"registered",
"scope",
".",
"If",
"the",
"manger",
"is",
"found",
"then",
"a",
"nil",
"error",
"is",
"returned",
"along",
"with",
"the",
"active"... | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/manager.go#L539-L550 | train |
btcsuite/btcwallet | waddrmgr/manager.go | ActiveScopedKeyManagers | func (m *Manager) ActiveScopedKeyManagers() []*ScopedKeyManager {
m.mtx.RLock()
defer m.mtx.RUnlock()
var scopedManagers []*ScopedKeyManager
for _, smgr := range m.scopedManagers {
scopedManagers = append(scopedManagers, smgr)
}
return scopedManagers
} | go | func (m *Manager) ActiveScopedKeyManagers() []*ScopedKeyManager {
m.mtx.RLock()
defer m.mtx.RUnlock()
var scopedManagers []*ScopedKeyManager
for _, smgr := range m.scopedManagers {
scopedManagers = append(scopedManagers, smgr)
}
return scopedManagers
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"ActiveScopedKeyManagers",
"(",
")",
"[",
"]",
"*",
"ScopedKeyManager",
"{",
"m",
".",
"mtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"m",
".",
"mtx",
".",
"RUnlock",
"(",
")",
"\n\n",
"var",
"scopedManagers",
"[... | // ActiveScopedKeyManagers returns a slice of all the active scoped key
// managers currently known by the root key manager. | [
"ActiveScopedKeyManagers",
"returns",
"a",
"slice",
"of",
"all",
"the",
"active",
"scoped",
"key",
"managers",
"currently",
"known",
"by",
"the",
"root",
"key",
"manager",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/manager.go#L554-L564 | train |
btcsuite/btcwallet | waddrmgr/manager.go | ScopesForExternalAddrType | func (m *Manager) ScopesForExternalAddrType(addrType AddressType) []KeyScope {
m.mtx.RLock()
defer m.mtx.RUnlock()
scopes, _ := m.externalAddrSchemas[addrType]
return scopes
} | go | func (m *Manager) ScopesForExternalAddrType(addrType AddressType) []KeyScope {
m.mtx.RLock()
defer m.mtx.RUnlock()
scopes, _ := m.externalAddrSchemas[addrType]
return scopes
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"ScopesForExternalAddrType",
"(",
"addrType",
"AddressType",
")",
"[",
"]",
"KeyScope",
"{",
"m",
".",
"mtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"m",
".",
"mtx",
".",
"RUnlock",
"(",
")",
"\n\n",
"scopes",
"... | // ScopesForExternalAddrType returns the set of key scopes that are able to
// produce the target address type as external addresses. | [
"ScopesForExternalAddrType",
"returns",
"the",
"set",
"of",
"key",
"scopes",
"that",
"are",
"able",
"to",
"produce",
"the",
"target",
"address",
"type",
"as",
"external",
"addresses",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/manager.go#L568-L574 | train |
btcsuite/btcwallet | waddrmgr/manager.go | ScopesForInternalAddrTypes | func (m *Manager) ScopesForInternalAddrTypes(addrType AddressType) []KeyScope {
m.mtx.RLock()
defer m.mtx.RUnlock()
scopes, _ := m.internalAddrSchemas[addrType]
return scopes
} | go | func (m *Manager) ScopesForInternalAddrTypes(addrType AddressType) []KeyScope {
m.mtx.RLock()
defer m.mtx.RUnlock()
scopes, _ := m.internalAddrSchemas[addrType]
return scopes
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"ScopesForInternalAddrTypes",
"(",
"addrType",
"AddressType",
")",
"[",
"]",
"KeyScope",
"{",
"m",
".",
"mtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"m",
".",
"mtx",
".",
"RUnlock",
"(",
")",
"\n\n",
"scopes",
... | // ScopesForInternalAddrTypes returns the set of key scopes that are able to
// produce the target address type as internal addresses. | [
"ScopesForInternalAddrTypes",
"returns",
"the",
"set",
"of",
"key",
"scopes",
"that",
"are",
"able",
"to",
"produce",
"the",
"target",
"address",
"type",
"as",
"internal",
"addresses",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/manager.go#L578-L584 | train |
btcsuite/btcwallet | waddrmgr/manager.go | AddrAccount | func (m *Manager) AddrAccount(ns walletdb.ReadBucket,
address btcutil.Address) (*ScopedKeyManager, uint32, error) {
m.mtx.RLock()
defer m.mtx.RUnlock()
for _, scopedMgr := range m.scopedManagers {
if _, err := scopedMgr.Address(ns, address); err != nil {
continue
}
// We've found the manager that this a... | go | func (m *Manager) AddrAccount(ns walletdb.ReadBucket,
address btcutil.Address) (*ScopedKeyManager, uint32, error) {
m.mtx.RLock()
defer m.mtx.RUnlock()
for _, scopedMgr := range m.scopedManagers {
if _, err := scopedMgr.Address(ns, address); err != nil {
continue
}
// We've found the manager that this a... | [
"func",
"(",
"m",
"*",
"Manager",
")",
"AddrAccount",
"(",
"ns",
"walletdb",
".",
"ReadBucket",
",",
"address",
"btcutil",
".",
"Address",
")",
"(",
"*",
"ScopedKeyManager",
",",
"uint32",
",",
"error",
")",
"{",
"m",
".",
"mtx",
".",
"RLock",
"(",
"... | // AddrAccount returns the account to which the given address belongs. We also
// return the scoped manager that owns the addr+account combo. | [
"AddrAccount",
"returns",
"the",
"account",
"to",
"which",
"the",
"given",
"address",
"belongs",
".",
"We",
"also",
"return",
"the",
"scoped",
"manager",
"that",
"owns",
"the",
"addr",
"+",
"account",
"combo",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/manager.go#L668-L694 | train |
btcsuite/btcwallet | waddrmgr/manager.go | IsLocked | func (m *Manager) IsLocked() bool {
m.mtx.RLock()
defer m.mtx.RUnlock()
return m.isLocked()
} | go | func (m *Manager) IsLocked() bool {
m.mtx.RLock()
defer m.mtx.RUnlock()
return m.isLocked()
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"IsLocked",
"(",
")",
"bool",
"{",
"m",
".",
"mtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"m",
".",
"mtx",
".",
"RUnlock",
"(",
")",
"\n\n",
"return",
"m",
".",
"isLocked",
"(",
")",
"\n",
"}"
] | // IsLocked returns whether or not the address managed is locked. When it is
// unlocked, the decryption key needed to decrypt private keys used for signing
// is in memory. | [
"IsLocked",
"returns",
"whether",
"or",
"not",
"the",
"address",
"managed",
"is",
"locked",
".",
"When",
"it",
"is",
"unlocked",
"the",
"decryption",
"key",
"needed",
"to",
"decrypt",
"private",
"keys",
"used",
"for",
"signing",
"is",
"in",
"memory",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/manager.go#L1007-L1012 | train |
btcsuite/btcwallet | waddrmgr/manager.go | Lock | func (m *Manager) Lock() error {
// A watching-only address manager can't be locked.
if m.watchingOnly {
return managerError(ErrWatchingOnly, errWatchingOnly, nil)
}
m.mtx.Lock()
defer m.mtx.Unlock()
// Error on attempt to lock an already locked manager.
if m.locked {
return managerError(ErrLocked, errLock... | go | func (m *Manager) Lock() error {
// A watching-only address manager can't be locked.
if m.watchingOnly {
return managerError(ErrWatchingOnly, errWatchingOnly, nil)
}
m.mtx.Lock()
defer m.mtx.Unlock()
// Error on attempt to lock an already locked manager.
if m.locked {
return managerError(ErrLocked, errLock... | [
"func",
"(",
"m",
"*",
"Manager",
")",
"Lock",
"(",
")",
"error",
"{",
"// A watching-only address manager can't be locked.",
"if",
"m",
".",
"watchingOnly",
"{",
"return",
"managerError",
"(",
"ErrWatchingOnly",
",",
"errWatchingOnly",
",",
"nil",
")",
"\n",
"}... | // Lock performs a best try effort to remove and zero all secret keys associated
// with the address manager.
//
// This function will return an error if invoked on a watching-only address
// manager. | [
"Lock",
"performs",
"a",
"best",
"try",
"effort",
"to",
"remove",
"and",
"zero",
"all",
"secret",
"keys",
"associated",
"with",
"the",
"address",
"manager",
".",
"This",
"function",
"will",
"return",
"an",
"error",
"if",
"invoked",
"on",
"a",
"watching",
"... | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/manager.go#L1028-L1044 | train |
btcsuite/btcwallet | waddrmgr/manager.go | ValidateAccountName | func ValidateAccountName(name string) error {
if name == "" {
str := "accounts may not be named the empty string"
return managerError(ErrInvalidAccount, str, nil)
}
if isReservedAccountName(name) {
str := "reserved account name"
return managerError(ErrInvalidAccount, str, nil)
}
return nil
} | go | func ValidateAccountName(name string) error {
if name == "" {
str := "accounts may not be named the empty string"
return managerError(ErrInvalidAccount, str, nil)
}
if isReservedAccountName(name) {
str := "reserved account name"
return managerError(ErrInvalidAccount, str, nil)
}
return nil
} | [
"func",
"ValidateAccountName",
"(",
"name",
"string",
")",
"error",
"{",
"if",
"name",
"==",
"\"",
"\"",
"{",
"str",
":=",
"\"",
"\"",
"\n",
"return",
"managerError",
"(",
"ErrInvalidAccount",
",",
"str",
",",
"nil",
")",
"\n",
"}",
"\n",
"if",
"isRese... | // ValidateAccountName validates the given account name and returns an error, if any. | [
"ValidateAccountName",
"validates",
"the",
"given",
"account",
"name",
"and",
"returns",
"an",
"error",
"if",
"any",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/manager.go#L1172-L1182 | train |
btcsuite/btcwallet | waddrmgr/manager.go | selectCryptoKey | func (m *Manager) selectCryptoKey(keyType CryptoKeyType) (EncryptorDecryptor, error) {
if keyType == CKTPrivate || keyType == CKTScript {
// The manager must be unlocked to work with the private keys.
if m.locked || m.watchingOnly {
return nil, managerError(ErrLocked, errLocked, nil)
}
}
var cryptoKey Encr... | go | func (m *Manager) selectCryptoKey(keyType CryptoKeyType) (EncryptorDecryptor, error) {
if keyType == CKTPrivate || keyType == CKTScript {
// The manager must be unlocked to work with the private keys.
if m.locked || m.watchingOnly {
return nil, managerError(ErrLocked, errLocked, nil)
}
}
var cryptoKey Encr... | [
"func",
"(",
"m",
"*",
"Manager",
")",
"selectCryptoKey",
"(",
"keyType",
"CryptoKeyType",
")",
"(",
"EncryptorDecryptor",
",",
"error",
")",
"{",
"if",
"keyType",
"==",
"CKTPrivate",
"||",
"keyType",
"==",
"CKTScript",
"{",
"// The manager must be unlocked to wor... | // selectCryptoKey selects the appropriate crypto key based on the key type. An
// error is returned when an invalid key type is specified or the requested key
// requires the manager to be unlocked when it isn't.
//
// This function MUST be called with the manager lock held for reads. | [
"selectCryptoKey",
"selects",
"the",
"appropriate",
"crypto",
"key",
"based",
"on",
"the",
"key",
"type",
".",
"An",
"error",
"is",
"returned",
"when",
"an",
"invalid",
"key",
"type",
"is",
"specified",
"or",
"the",
"requested",
"key",
"requires",
"the",
"ma... | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/manager.go#L1189-L1211 | train |
btcsuite/btcwallet | waddrmgr/manager.go | Encrypt | func (m *Manager) Encrypt(keyType CryptoKeyType, in []byte) ([]byte, error) {
// Encryption must be performed under the manager mutex since the
// keys are cleared when the manager is locked.
m.mtx.Lock()
defer m.mtx.Unlock()
cryptoKey, err := m.selectCryptoKey(keyType)
if err != nil {
return nil, err
}
enc... | go | func (m *Manager) Encrypt(keyType CryptoKeyType, in []byte) ([]byte, error) {
// Encryption must be performed under the manager mutex since the
// keys are cleared when the manager is locked.
m.mtx.Lock()
defer m.mtx.Unlock()
cryptoKey, err := m.selectCryptoKey(keyType)
if err != nil {
return nil, err
}
enc... | [
"func",
"(",
"m",
"*",
"Manager",
")",
"Encrypt",
"(",
"keyType",
"CryptoKeyType",
",",
"in",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"// Encryption must be performed under the manager mutex since the",
"// keys are cleared when the man... | // Encrypt in using the crypto key type specified by keyType. | [
"Encrypt",
"in",
"using",
"the",
"crypto",
"key",
"type",
"specified",
"by",
"keyType",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/manager.go#L1214-L1230 | train |
btcsuite/btcwallet | waddrmgr/manager.go | newManager | func newManager(chainParams *chaincfg.Params, masterKeyPub *snacl.SecretKey,
masterKeyPriv *snacl.SecretKey, cryptoKeyPub EncryptorDecryptor,
cryptoKeyPrivEncrypted, cryptoKeyScriptEncrypted []byte, syncInfo *syncState,
birthday time.Time, privPassphraseSalt [saltSize]byte,
scopedManagers map[KeyScope]*ScopedKeyMan... | go | func newManager(chainParams *chaincfg.Params, masterKeyPub *snacl.SecretKey,
masterKeyPriv *snacl.SecretKey, cryptoKeyPub EncryptorDecryptor,
cryptoKeyPrivEncrypted, cryptoKeyScriptEncrypted []byte, syncInfo *syncState,
birthday time.Time, privPassphraseSalt [saltSize]byte,
scopedManagers map[KeyScope]*ScopedKeyMan... | [
"func",
"newManager",
"(",
"chainParams",
"*",
"chaincfg",
".",
"Params",
",",
"masterKeyPub",
"*",
"snacl",
".",
"SecretKey",
",",
"masterKeyPriv",
"*",
"snacl",
".",
"SecretKey",
",",
"cryptoKeyPub",
"EncryptorDecryptor",
",",
"cryptoKeyPrivEncrypted",
",",
"cry... | // newManager returns a new locked address manager with the given parameters. | [
"newManager",
"returns",
"a",
"new",
"locked",
"address",
"manager",
"with",
"the",
"given",
"parameters",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/manager.go#L1252-L1290 | train |
btcsuite/btcwallet | waddrmgr/manager.go | Open | func Open(ns walletdb.ReadBucket, pubPassphrase []byte,
chainParams *chaincfg.Params) (*Manager, error) {
// Return an error if the manager has NOT already been created in the
// given database namespace.
exists := managerExists(ns)
if !exists {
str := "the specified address manager does not exist"
return nil... | go | func Open(ns walletdb.ReadBucket, pubPassphrase []byte,
chainParams *chaincfg.Params) (*Manager, error) {
// Return an error if the manager has NOT already been created in the
// given database namespace.
exists := managerExists(ns)
if !exists {
str := "the specified address manager does not exist"
return nil... | [
"func",
"Open",
"(",
"ns",
"walletdb",
".",
"ReadBucket",
",",
"pubPassphrase",
"[",
"]",
"byte",
",",
"chainParams",
"*",
"chaincfg",
".",
"Params",
")",
"(",
"*",
"Manager",
",",
"error",
")",
"{",
"// Return an error if the manager has NOT already been created ... | // Open loads an existing address manager from the given namespace. The public
// passphrase is required to decrypt the public keys used to protect the public
// information such as addresses. This is important since access to BIP0032
// extended keys means it is possible to generate all future addresses.
//
// If a ... | [
"Open",
"loads",
"an",
"existing",
"address",
"manager",
"from",
"the",
"given",
"namespace",
".",
"The",
"public",
"passphrase",
"is",
"required",
"to",
"decrypt",
"the",
"public",
"keys",
"used",
"to",
"protect",
"the",
"public",
"information",
"such",
"as",... | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/manager.go#L1519-L1531 | train |
btcsuite/btcwallet | waddrmgr/manager.go | createManagerKeyScope | func createManagerKeyScope(ns walletdb.ReadWriteBucket,
scope KeyScope, root *hdkeychain.ExtendedKey,
cryptoKeyPub, cryptoKeyPriv EncryptorDecryptor) error {
// Derive the cointype key according to the passed scope.
coinTypeKeyPriv, err := deriveCoinTypeKey(root, scope)
if err != nil {
str := "failed to derive ... | go | func createManagerKeyScope(ns walletdb.ReadWriteBucket,
scope KeyScope, root *hdkeychain.ExtendedKey,
cryptoKeyPub, cryptoKeyPriv EncryptorDecryptor) error {
// Derive the cointype key according to the passed scope.
coinTypeKeyPriv, err := deriveCoinTypeKey(root, scope)
if err != nil {
str := "failed to derive ... | [
"func",
"createManagerKeyScope",
"(",
"ns",
"walletdb",
".",
"ReadWriteBucket",
",",
"scope",
"KeyScope",
",",
"root",
"*",
"hdkeychain",
".",
"ExtendedKey",
",",
"cryptoKeyPub",
",",
"cryptoKeyPriv",
"EncryptorDecryptor",
")",
"error",
"{",
"// Derive the cointype ke... | // createManagerKeyScope creates a new key scoped for a target manager's scope.
// This partitions key derivation for a particular purpose+coin tuple, allowing
// multiple address derivation schems to be maintained concurrently. | [
"createManagerKeyScope",
"creates",
"a",
"new",
"key",
"scoped",
"for",
"a",
"target",
"manager",
"s",
"scope",
".",
"This",
"partitions",
"key",
"derivation",
"for",
"a",
"particular",
"purpose",
"+",
"coin",
"tuple",
"allowing",
"multiple",
"address",
"derivat... | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/manager.go#L1536-L1632 | train |
btcsuite/btcwallet | walletsetup.go | networkDir | func networkDir(dataDir string, chainParams *chaincfg.Params) string {
netname := chainParams.Name
// For now, we must always name the testnet data directory as "testnet"
// and not "testnet3" or any other version, as the chaincfg testnet3
// paramaters will likely be switched to being named "testnet3" in the
// ... | go | func networkDir(dataDir string, chainParams *chaincfg.Params) string {
netname := chainParams.Name
// For now, we must always name the testnet data directory as "testnet"
// and not "testnet3" or any other version, as the chaincfg testnet3
// paramaters will likely be switched to being named "testnet3" in the
// ... | [
"func",
"networkDir",
"(",
"dataDir",
"string",
",",
"chainParams",
"*",
"chaincfg",
".",
"Params",
")",
"string",
"{",
"netname",
":=",
"chainParams",
".",
"Name",
"\n\n",
"// For now, we must always name the testnet data directory as \"testnet\"",
"// and not \"testnet3\"... | // networkDir returns the directory name of a network directory to hold wallet
// files. | [
"networkDir",
"returns",
"the",
"directory",
"name",
"of",
"a",
"network",
"directory",
"to",
"hold",
"wallet",
"files",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/walletsetup.go#L28-L41 | train |
btcsuite/btcwallet | walletsetup.go | convertLegacyKeystore | func convertLegacyKeystore(legacyKeyStore *keystore.Store, w *wallet.Wallet) error {
netParams := legacyKeyStore.Net()
blockStamp := waddrmgr.BlockStamp{
Height: 0,
Hash: *netParams.GenesisHash,
}
for _, walletAddr := range legacyKeyStore.ActiveAddresses() {
switch addr := walletAddr.(type) {
case keystor... | go | func convertLegacyKeystore(legacyKeyStore *keystore.Store, w *wallet.Wallet) error {
netParams := legacyKeyStore.Net()
blockStamp := waddrmgr.BlockStamp{
Height: 0,
Hash: *netParams.GenesisHash,
}
for _, walletAddr := range legacyKeyStore.ActiveAddresses() {
switch addr := walletAddr.(type) {
case keystor... | [
"func",
"convertLegacyKeystore",
"(",
"legacyKeyStore",
"*",
"keystore",
".",
"Store",
",",
"w",
"*",
"wallet",
".",
"Wallet",
")",
"error",
"{",
"netParams",
":=",
"legacyKeyStore",
".",
"Net",
"(",
")",
"\n",
"blockStamp",
":=",
"waddrmgr",
".",
"BlockStam... | // convertLegacyKeystore converts all of the addresses in the passed legacy
// key store to the new waddrmgr.Manager format. Both the legacy keystore and
// the new manager must be unlocked. | [
"convertLegacyKeystore",
"converts",
"all",
"of",
"the",
"addresses",
"in",
"the",
"passed",
"legacy",
"key",
"store",
"to",
"the",
"new",
"waddrmgr",
".",
"Manager",
"format",
".",
"Both",
"the",
"legacy",
"keystore",
"and",
"the",
"new",
"manager",
"must",
... | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/walletsetup.go#L46-L98 | train |
btcsuite/btcwallet | walletsetup.go | createWallet | func createWallet(cfg *config) error {
dbDir := networkDir(cfg.AppDataDir.Value, activeNet.Params)
loader := wallet.NewLoader(activeNet.Params, dbDir, 250)
// When there is a legacy keystore, open it now to ensure any errors
// don't end up exiting the process after the user has spent time
// entering a bunch of ... | go | func createWallet(cfg *config) error {
dbDir := networkDir(cfg.AppDataDir.Value, activeNet.Params)
loader := wallet.NewLoader(activeNet.Params, dbDir, 250)
// When there is a legacy keystore, open it now to ensure any errors
// don't end up exiting the process after the user has spent time
// entering a bunch of ... | [
"func",
"createWallet",
"(",
"cfg",
"*",
"config",
")",
"error",
"{",
"dbDir",
":=",
"networkDir",
"(",
"cfg",
".",
"AppDataDir",
".",
"Value",
",",
"activeNet",
".",
"Params",
")",
"\n",
"loader",
":=",
"wallet",
".",
"NewLoader",
"(",
"activeNet",
".",... | // createWallet prompts the user for information needed to generate a new wallet
// and generates the wallet accordingly. The new wallet will reside at the
// provided path. | [
"createWallet",
"prompts",
"the",
"user",
"for",
"information",
"needed",
"to",
"generate",
"a",
"new",
"wallet",
"and",
"generates",
"the",
"wallet",
"accordingly",
".",
"The",
"new",
"wallet",
"will",
"reside",
"at",
"the",
"provided",
"path",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/walletsetup.go#L103-L204 | train |
btcsuite/btcwallet | walletsetup.go | createSimulationWallet | func createSimulationWallet(cfg *config) error {
// Simulation wallet password is 'password'.
privPass := []byte("password")
// Public passphrase is the default.
pubPass := []byte(wallet.InsecurePubPassphrase)
netDir := networkDir(cfg.AppDataDir.Value, activeNet.Params)
// Create the wallet.
dbPath := filepat... | go | func createSimulationWallet(cfg *config) error {
// Simulation wallet password is 'password'.
privPass := []byte("password")
// Public passphrase is the default.
pubPass := []byte(wallet.InsecurePubPassphrase)
netDir := networkDir(cfg.AppDataDir.Value, activeNet.Params)
// Create the wallet.
dbPath := filepat... | [
"func",
"createSimulationWallet",
"(",
"cfg",
"*",
"config",
")",
"error",
"{",
"// Simulation wallet password is 'password'.",
"privPass",
":=",
"[",
"]",
"byte",
"(",
"\"",
"\"",
")",
"\n\n",
"// Public passphrase is the default.",
"pubPass",
":=",
"[",
"]",
"byte... | // createSimulationWallet is intended to be called from the rpcclient
// and used to create a wallet for actors involved in simulations. | [
"createSimulationWallet",
"is",
"intended",
"to",
"be",
"called",
"from",
"the",
"rpcclient",
"and",
"used",
"to",
"create",
"a",
"wallet",
"for",
"actors",
"involved",
"in",
"simulations",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/walletsetup.go#L208-L236 | train |
btcsuite/btcwallet | walletsetup.go | checkCreateDir | func checkCreateDir(path string) error {
if fi, err := os.Stat(path); err != nil {
if os.IsNotExist(err) {
// Attempt data directory creation
if err = os.MkdirAll(path, 0700); err != nil {
return fmt.Errorf("cannot create directory: %s", err)
}
} else {
return fmt.Errorf("error checking directory: ... | go | func checkCreateDir(path string) error {
if fi, err := os.Stat(path); err != nil {
if os.IsNotExist(err) {
// Attempt data directory creation
if err = os.MkdirAll(path, 0700); err != nil {
return fmt.Errorf("cannot create directory: %s", err)
}
} else {
return fmt.Errorf("error checking directory: ... | [
"func",
"checkCreateDir",
"(",
"path",
"string",
")",
"error",
"{",
"if",
"fi",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"path",
")",
";",
"err",
"!=",
"nil",
"{",
"if",
"os",
".",
"IsNotExist",
"(",
"err",
")",
"{",
"// Attempt data directory creatio... | // checkCreateDir checks that the path exists and is a directory.
// If path does not exist, it is created. | [
"checkCreateDir",
"checks",
"that",
"the",
"path",
"exists",
"and",
"is",
"a",
"directory",
".",
"If",
"path",
"does",
"not",
"exist",
"it",
"is",
"created",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/walletsetup.go#L240-L257 | train |
btcsuite/btcwallet | waddrmgr/db.go | maybeConvertDbError | func maybeConvertDbError(err error) error {
// When the error is already a ManagerError, just return it.
if _, ok := err.(ManagerError); ok {
return err
}
return managerError(ErrDatabase, err.Error(), err)
} | go | func maybeConvertDbError(err error) error {
// When the error is already a ManagerError, just return it.
if _, ok := err.(ManagerError); ok {
return err
}
return managerError(ErrDatabase, err.Error(), err)
} | [
"func",
"maybeConvertDbError",
"(",
"err",
"error",
")",
"error",
"{",
"// When the error is already a ManagerError, just return it.",
"if",
"_",
",",
"ok",
":=",
"err",
".",
"(",
"ManagerError",
")",
";",
"ok",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",... | // maybeConvertDbError converts the passed error to a ManagerError with an
// error code of ErrDatabase if it is not already a ManagerError. This is
// useful for potential errors returned from managed transaction an other parts
// of the walletdb database. | [
"maybeConvertDbError",
"converts",
"the",
"passed",
"error",
"to",
"a",
"ManagerError",
"with",
"an",
"error",
"code",
"of",
"ErrDatabase",
"if",
"it",
"is",
"not",
"already",
"a",
"ManagerError",
".",
"This",
"is",
"useful",
"for",
"potential",
"errors",
"ret... | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L37-L44 | train |
btcsuite/btcwallet | waddrmgr/db.go | scopeToBytes | func scopeToBytes(scope *KeyScope) [scopeKeySize]byte {
var scopeBytes [scopeKeySize]byte
binary.LittleEndian.PutUint32(scopeBytes[:], scope.Purpose)
binary.LittleEndian.PutUint32(scopeBytes[4:], scope.Coin)
return scopeBytes
} | go | func scopeToBytes(scope *KeyScope) [scopeKeySize]byte {
var scopeBytes [scopeKeySize]byte
binary.LittleEndian.PutUint32(scopeBytes[:], scope.Purpose)
binary.LittleEndian.PutUint32(scopeBytes[4:], scope.Coin)
return scopeBytes
} | [
"func",
"scopeToBytes",
"(",
"scope",
"*",
"KeyScope",
")",
"[",
"scopeKeySize",
"]",
"byte",
"{",
"var",
"scopeBytes",
"[",
"scopeKeySize",
"]",
"byte",
"\n",
"binary",
".",
"LittleEndian",
".",
"PutUint32",
"(",
"scopeBytes",
"[",
":",
"]",
",",
"scope",... | // scopeToBytes transforms a manager's scope into the form that will be used to
// retrieve the bucket that all information for a particular scope is stored
// under | [
"scopeToBytes",
"transforms",
"a",
"manager",
"s",
"scope",
"into",
"the",
"form",
"that",
"will",
"be",
"used",
"to",
"retrieve",
"the",
"bucket",
"that",
"all",
"information",
"for",
"a",
"particular",
"scope",
"is",
"stored",
"under"
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L299-L305 | train |
btcsuite/btcwallet | waddrmgr/db.go | scopeFromBytes | func scopeFromBytes(scopeBytes []byte) KeyScope {
return KeyScope{
Purpose: binary.LittleEndian.Uint32(scopeBytes[:]),
Coin: binary.LittleEndian.Uint32(scopeBytes[4:]),
}
} | go | func scopeFromBytes(scopeBytes []byte) KeyScope {
return KeyScope{
Purpose: binary.LittleEndian.Uint32(scopeBytes[:]),
Coin: binary.LittleEndian.Uint32(scopeBytes[4:]),
}
} | [
"func",
"scopeFromBytes",
"(",
"scopeBytes",
"[",
"]",
"byte",
")",
"KeyScope",
"{",
"return",
"KeyScope",
"{",
"Purpose",
":",
"binary",
".",
"LittleEndian",
".",
"Uint32",
"(",
"scopeBytes",
"[",
":",
"]",
")",
",",
"Coin",
":",
"binary",
".",
"LittleE... | // scopeFromBytes decodes a serializes manager scope into its concrete manager
// scope struct. | [
"scopeFromBytes",
"decodes",
"a",
"serializes",
"manager",
"scope",
"into",
"its",
"concrete",
"manager",
"scope",
"struct",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L309-L314 | train |
btcsuite/btcwallet | waddrmgr/db.go | scopeSchemaToBytes | func scopeSchemaToBytes(schema *ScopeAddrSchema) []byte {
var schemaBytes [2]byte
schemaBytes[0] = byte(schema.InternalAddrType)
schemaBytes[1] = byte(schema.ExternalAddrType)
return schemaBytes[:]
} | go | func scopeSchemaToBytes(schema *ScopeAddrSchema) []byte {
var schemaBytes [2]byte
schemaBytes[0] = byte(schema.InternalAddrType)
schemaBytes[1] = byte(schema.ExternalAddrType)
return schemaBytes[:]
} | [
"func",
"scopeSchemaToBytes",
"(",
"schema",
"*",
"ScopeAddrSchema",
")",
"[",
"]",
"byte",
"{",
"var",
"schemaBytes",
"[",
"2",
"]",
"byte",
"\n",
"schemaBytes",
"[",
"0",
"]",
"=",
"byte",
"(",
"schema",
".",
"InternalAddrType",
")",
"\n",
"schemaBytes",... | // scopeSchemaToBytes encodes the passed scope schema as a set of bytes
// suitable for storage within the database. | [
"scopeSchemaToBytes",
"encodes",
"the",
"passed",
"scope",
"schema",
"as",
"a",
"set",
"of",
"bytes",
"suitable",
"for",
"storage",
"within",
"the",
"database",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L318-L324 | train |
btcsuite/btcwallet | waddrmgr/db.go | scopeSchemaFromBytes | func scopeSchemaFromBytes(schemaBytes []byte) *ScopeAddrSchema {
return &ScopeAddrSchema{
InternalAddrType: AddressType(schemaBytes[0]),
ExternalAddrType: AddressType(schemaBytes[1]),
}
} | go | func scopeSchemaFromBytes(schemaBytes []byte) *ScopeAddrSchema {
return &ScopeAddrSchema{
InternalAddrType: AddressType(schemaBytes[0]),
ExternalAddrType: AddressType(schemaBytes[1]),
}
} | [
"func",
"scopeSchemaFromBytes",
"(",
"schemaBytes",
"[",
"]",
"byte",
")",
"*",
"ScopeAddrSchema",
"{",
"return",
"&",
"ScopeAddrSchema",
"{",
"InternalAddrType",
":",
"AddressType",
"(",
"schemaBytes",
"[",
"0",
"]",
")",
",",
"ExternalAddrType",
":",
"AddressT... | // scopeSchemaFromBytes decodes a new scope schema instance from the set of
// serialized bytes. | [
"scopeSchemaFromBytes",
"decodes",
"a",
"new",
"scope",
"schema",
"instance",
"from",
"the",
"set",
"of",
"serialized",
"bytes",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L328-L333 | train |
btcsuite/btcwallet | waddrmgr/db.go | fetchScopeAddrSchema | func fetchScopeAddrSchema(ns walletdb.ReadBucket,
scope *KeyScope) (*ScopeAddrSchema, error) {
schemaBucket := ns.NestedReadBucket(scopeSchemaBucketName)
if schemaBucket == nil {
str := fmt.Sprintf("unable to find scope schema bucket")
return nil, managerError(ErrScopeNotFound, str, nil)
}
scopeKey := scopeT... | go | func fetchScopeAddrSchema(ns walletdb.ReadBucket,
scope *KeyScope) (*ScopeAddrSchema, error) {
schemaBucket := ns.NestedReadBucket(scopeSchemaBucketName)
if schemaBucket == nil {
str := fmt.Sprintf("unable to find scope schema bucket")
return nil, managerError(ErrScopeNotFound, str, nil)
}
scopeKey := scopeT... | [
"func",
"fetchScopeAddrSchema",
"(",
"ns",
"walletdb",
".",
"ReadBucket",
",",
"scope",
"*",
"KeyScope",
")",
"(",
"*",
"ScopeAddrSchema",
",",
"error",
")",
"{",
"schemaBucket",
":=",
"ns",
".",
"NestedReadBucket",
"(",
"scopeSchemaBucketName",
")",
"\n",
"if... | // fetchScopeAddrSchema will attempt to retrieve the address schema for a
// particular manager scope stored within the database. These are used in order
// to properly type each address generated by the scope address manager. | [
"fetchScopeAddrSchema",
"will",
"attempt",
"to",
"retrieve",
"the",
"address",
"schema",
"for",
"a",
"particular",
"manager",
"scope",
"stored",
"within",
"the",
"database",
".",
"These",
"are",
"used",
"in",
"order",
"to",
"properly",
"type",
"each",
"address",... | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L338-L355 | train |
btcsuite/btcwallet | waddrmgr/db.go | putScopeAddrTypes | func putScopeAddrTypes(ns walletdb.ReadWriteBucket, scope *KeyScope,
schema *ScopeAddrSchema) error {
scopeSchemaBucket := ns.NestedReadWriteBucket(scopeSchemaBucketName)
if scopeSchemaBucket == nil {
str := fmt.Sprintf("unable to find scope schema bucket")
return managerError(ErrScopeNotFound, str, nil)
}
s... | go | func putScopeAddrTypes(ns walletdb.ReadWriteBucket, scope *KeyScope,
schema *ScopeAddrSchema) error {
scopeSchemaBucket := ns.NestedReadWriteBucket(scopeSchemaBucketName)
if scopeSchemaBucket == nil {
str := fmt.Sprintf("unable to find scope schema bucket")
return managerError(ErrScopeNotFound, str, nil)
}
s... | [
"func",
"putScopeAddrTypes",
"(",
"ns",
"walletdb",
".",
"ReadWriteBucket",
",",
"scope",
"*",
"KeyScope",
",",
"schema",
"*",
"ScopeAddrSchema",
")",
"error",
"{",
"scopeSchemaBucket",
":=",
"ns",
".",
"NestedReadWriteBucket",
"(",
"scopeSchemaBucketName",
")",
"... | // putScopeAddrSchema attempts to store the passed addr scehma for the given
// manager scope. | [
"putScopeAddrSchema",
"attempts",
"to",
"store",
"the",
"passed",
"addr",
"scehma",
"for",
"the",
"given",
"manager",
"scope",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L359-L371 | train |
btcsuite/btcwallet | waddrmgr/db.go | fetchManagerVersion | func fetchManagerVersion(ns walletdb.ReadBucket) (uint32, error) {
mainBucket := ns.NestedReadBucket(mainBucketName)
verBytes := mainBucket.Get(mgrVersionName)
if verBytes == nil {
str := "required version number not stored in database"
return 0, managerError(ErrDatabase, str, nil)
}
version := binary.LittleEn... | go | func fetchManagerVersion(ns walletdb.ReadBucket) (uint32, error) {
mainBucket := ns.NestedReadBucket(mainBucketName)
verBytes := mainBucket.Get(mgrVersionName)
if verBytes == nil {
str := "required version number not stored in database"
return 0, managerError(ErrDatabase, str, nil)
}
version := binary.LittleEn... | [
"func",
"fetchManagerVersion",
"(",
"ns",
"walletdb",
".",
"ReadBucket",
")",
"(",
"uint32",
",",
"error",
")",
"{",
"mainBucket",
":=",
"ns",
".",
"NestedReadBucket",
"(",
"mainBucketName",
")",
"\n",
"verBytes",
":=",
"mainBucket",
".",
"Get",
"(",
"mgrVer... | // fetchManagerVersion fetches the current manager version from the database. | [
"fetchManagerVersion",
"fetches",
"the",
"current",
"manager",
"version",
"from",
"the",
"database",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L402-L411 | train |
btcsuite/btcwallet | waddrmgr/db.go | putManagerVersion | func putManagerVersion(ns walletdb.ReadWriteBucket, version uint32) error {
bucket := ns.NestedReadWriteBucket(mainBucketName)
verBytes := uint32ToBytes(version)
err := bucket.Put(mgrVersionName, verBytes)
if err != nil {
str := "failed to store version"
return managerError(ErrDatabase, str, err)
}
return ni... | go | func putManagerVersion(ns walletdb.ReadWriteBucket, version uint32) error {
bucket := ns.NestedReadWriteBucket(mainBucketName)
verBytes := uint32ToBytes(version)
err := bucket.Put(mgrVersionName, verBytes)
if err != nil {
str := "failed to store version"
return managerError(ErrDatabase, str, err)
}
return ni... | [
"func",
"putManagerVersion",
"(",
"ns",
"walletdb",
".",
"ReadWriteBucket",
",",
"version",
"uint32",
")",
"error",
"{",
"bucket",
":=",
"ns",
".",
"NestedReadWriteBucket",
"(",
"mainBucketName",
")",
"\n\n",
"verBytes",
":=",
"uint32ToBytes",
"(",
"version",
")... | // putManagerVersion stores the provided version to the database. | [
"putManagerVersion",
"stores",
"the",
"provided",
"version",
"to",
"the",
"database",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L414-L424 | train |
btcsuite/btcwallet | waddrmgr/db.go | putMasterKeyParams | func putMasterKeyParams(ns walletdb.ReadWriteBucket, pubParams, privParams []byte) error {
bucket := ns.NestedReadWriteBucket(mainBucketName)
if privParams != nil {
err := bucket.Put(masterPrivKeyName, privParams)
if err != nil {
str := "failed to store master private key parameters"
return managerError(Er... | go | func putMasterKeyParams(ns walletdb.ReadWriteBucket, pubParams, privParams []byte) error {
bucket := ns.NestedReadWriteBucket(mainBucketName)
if privParams != nil {
err := bucket.Put(masterPrivKeyName, privParams)
if err != nil {
str := "failed to store master private key parameters"
return managerError(Er... | [
"func",
"putMasterKeyParams",
"(",
"ns",
"walletdb",
".",
"ReadWriteBucket",
",",
"pubParams",
",",
"privParams",
"[",
"]",
"byte",
")",
"error",
"{",
"bucket",
":=",
"ns",
".",
"NestedReadWriteBucket",
"(",
"mainBucketName",
")",
"\n\n",
"if",
"privParams",
"... | // putMasterKeyParams stores the master key parameters needed to derive them to
// the database. Either parameter can be nil in which case no value is
// written for the parameter. | [
"putMasterKeyParams",
"stores",
"the",
"master",
"key",
"parameters",
"needed",
"to",
"derive",
"them",
"to",
"the",
"database",
".",
"Either",
"parameter",
"can",
"be",
"nil",
"in",
"which",
"case",
"no",
"value",
"is",
"written",
"for",
"the",
"parameter",
... | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L457-L477 | train |
btcsuite/btcwallet | waddrmgr/db.go | fetchCoinTypeKeys | func fetchCoinTypeKeys(ns walletdb.ReadBucket, scope *KeyScope) ([]byte, []byte, error) {
scopedBucket, err := fetchReadScopeBucket(ns, scope)
if err != nil {
return nil, nil, err
}
coinTypePubKeyEnc := scopedBucket.Get(coinTypePubKeyName)
if coinTypePubKeyEnc == nil {
str := "required encrypted cointype publ... | go | func fetchCoinTypeKeys(ns walletdb.ReadBucket, scope *KeyScope) ([]byte, []byte, error) {
scopedBucket, err := fetchReadScopeBucket(ns, scope)
if err != nil {
return nil, nil, err
}
coinTypePubKeyEnc := scopedBucket.Get(coinTypePubKeyName)
if coinTypePubKeyEnc == nil {
str := "required encrypted cointype publ... | [
"func",
"fetchCoinTypeKeys",
"(",
"ns",
"walletdb",
".",
"ReadBucket",
",",
"scope",
"*",
"KeyScope",
")",
"(",
"[",
"]",
"byte",
",",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"scopedBucket",
",",
"err",
":=",
"fetchReadScopeBucket",
"(",
"ns",
",",
"... | // fetchCoinTypeKeys loads the encrypted cointype keys which are in turn used
// to derive the extended keys for all accounts. Each cointype key is
// associated with a particular manager scoped. | [
"fetchCoinTypeKeys",
"loads",
"the",
"encrypted",
"cointype",
"keys",
"which",
"are",
"in",
"turn",
"used",
"to",
"derive",
"the",
"extended",
"keys",
"for",
"all",
"accounts",
".",
"Each",
"cointype",
"key",
"is",
"associated",
"with",
"a",
"particular",
"man... | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L482-L501 | train |
btcsuite/btcwallet | waddrmgr/db.go | putCoinTypeKeys | func putCoinTypeKeys(ns walletdb.ReadWriteBucket, scope *KeyScope,
coinTypePubKeyEnc []byte, coinTypePrivKeyEnc []byte) error {
scopedBucket, err := fetchWriteScopeBucket(ns, scope)
if err != nil {
return err
}
if coinTypePubKeyEnc != nil {
err := scopedBucket.Put(coinTypePubKeyName, coinTypePubKeyEnc)
if ... | go | func putCoinTypeKeys(ns walletdb.ReadWriteBucket, scope *KeyScope,
coinTypePubKeyEnc []byte, coinTypePrivKeyEnc []byte) error {
scopedBucket, err := fetchWriteScopeBucket(ns, scope)
if err != nil {
return err
}
if coinTypePubKeyEnc != nil {
err := scopedBucket.Put(coinTypePubKeyName, coinTypePubKeyEnc)
if ... | [
"func",
"putCoinTypeKeys",
"(",
"ns",
"walletdb",
".",
"ReadWriteBucket",
",",
"scope",
"*",
"KeyScope",
",",
"coinTypePubKeyEnc",
"[",
"]",
"byte",
",",
"coinTypePrivKeyEnc",
"[",
"]",
"byte",
")",
"error",
"{",
"scopedBucket",
",",
"err",
":=",
"fetchWriteSc... | // putCoinTypeKeys stores the encrypted cointype keys which are in turn used to
// derive the extended keys for all accounts. Either parameter can be nil in
// which case no value is written for the parameter. Each cointype key is
// associated with a particular manager scope. | [
"putCoinTypeKeys",
"stores",
"the",
"encrypted",
"cointype",
"keys",
"which",
"are",
"in",
"turn",
"used",
"to",
"derive",
"the",
"extended",
"keys",
"for",
"all",
"accounts",
".",
"Either",
"parameter",
"can",
"be",
"nil",
"in",
"which",
"case",
"no",
"valu... | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L507-L532 | train |
btcsuite/btcwallet | waddrmgr/db.go | putMasterHDKeys | func putMasterHDKeys(ns walletdb.ReadWriteBucket, masterHDPrivEnc, masterHDPubEnc []byte) error {
// As this is the key for the root manager, we don't need to fetch any
// particular scope, and can insert directly within the main bucket.
bucket := ns.NestedReadWriteBucket(mainBucketName)
// Now that we have the ma... | go | func putMasterHDKeys(ns walletdb.ReadWriteBucket, masterHDPrivEnc, masterHDPubEnc []byte) error {
// As this is the key for the root manager, we don't need to fetch any
// particular scope, and can insert directly within the main bucket.
bucket := ns.NestedReadWriteBucket(mainBucketName)
// Now that we have the ma... | [
"func",
"putMasterHDKeys",
"(",
"ns",
"walletdb",
".",
"ReadWriteBucket",
",",
"masterHDPrivEnc",
",",
"masterHDPubEnc",
"[",
"]",
"byte",
")",
"error",
"{",
"// As this is the key for the root manager, we don't need to fetch any",
"// particular scope, and can insert directly wi... | // putMasterHDKeys stores the encrypted master HD keys in the top level main
// bucket. These are required in order to create any new manager scopes, as
// those are created via hardened derivation of the children of this key. | [
"putMasterHDKeys",
"stores",
"the",
"encrypted",
"master",
"HD",
"keys",
"in",
"the",
"top",
"level",
"main",
"bucket",
".",
"These",
"are",
"required",
"in",
"order",
"to",
"create",
"any",
"new",
"manager",
"scopes",
"as",
"those",
"are",
"created",
"via",... | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L537-L562 | train |
btcsuite/btcwallet | waddrmgr/db.go | fetchMasterHDKeys | func fetchMasterHDKeys(ns walletdb.ReadBucket) ([]byte, []byte, error) {
bucket := ns.NestedReadBucket(mainBucketName)
var masterHDPrivEnc, masterHDPubEnc []byte
// First, we'll try to fetch the master private key. If this database
// is watch only, or the master has been neutered, then this won't be
// found on... | go | func fetchMasterHDKeys(ns walletdb.ReadBucket) ([]byte, []byte, error) {
bucket := ns.NestedReadBucket(mainBucketName)
var masterHDPrivEnc, masterHDPubEnc []byte
// First, we'll try to fetch the master private key. If this database
// is watch only, or the master has been neutered, then this won't be
// found on... | [
"func",
"fetchMasterHDKeys",
"(",
"ns",
"walletdb",
".",
"ReadBucket",
")",
"(",
"[",
"]",
"byte",
",",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"bucket",
":=",
"ns",
".",
"NestedReadBucket",
"(",
"mainBucketName",
")",
"\n\n",
"var",
"masterHDPrivEnc",
... | // fetchMasterHDKeys attempts to fetch both the master HD private and public
// keys from the database. If this is a watch only wallet, then it's possible
// that the master private key isn't stored. | [
"fetchMasterHDKeys",
"attempts",
"to",
"fetch",
"both",
"the",
"master",
"HD",
"private",
"and",
"public",
"keys",
"from",
"the",
"database",
".",
"If",
"this",
"is",
"a",
"watch",
"only",
"wallet",
"then",
"it",
"s",
"possible",
"that",
"the",
"master",
"... | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L567-L588 | train |
btcsuite/btcwallet | waddrmgr/db.go | fetchCryptoKeys | func fetchCryptoKeys(ns walletdb.ReadBucket) ([]byte, []byte, []byte, error) {
bucket := ns.NestedReadBucket(mainBucketName)
// Load the crypto public key parameters. Required.
val := bucket.Get(cryptoPubKeyName)
if val == nil {
str := "required encrypted crypto public not stored in database"
return nil, nil,... | go | func fetchCryptoKeys(ns walletdb.ReadBucket) ([]byte, []byte, []byte, error) {
bucket := ns.NestedReadBucket(mainBucketName)
// Load the crypto public key parameters. Required.
val := bucket.Get(cryptoPubKeyName)
if val == nil {
str := "required encrypted crypto public not stored in database"
return nil, nil,... | [
"func",
"fetchCryptoKeys",
"(",
"ns",
"walletdb",
".",
"ReadBucket",
")",
"(",
"[",
"]",
"byte",
",",
"[",
"]",
"byte",
",",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"bucket",
":=",
"ns",
".",
"NestedReadBucket",
"(",
"mainBucketName",
")",
"\n\n",
... | // fetchCryptoKeys loads the encrypted crypto keys which are in turn used to
// protect the extended keys, imported keys, and scripts. Any of the returned
// values can be nil, but in practice only the crypto private and script keys
// will be nil for a watching-only database. | [
"fetchCryptoKeys",
"loads",
"the",
"encrypted",
"crypto",
"keys",
"which",
"are",
"in",
"turn",
"used",
"to",
"protect",
"the",
"extended",
"keys",
"imported",
"keys",
"and",
"scripts",
".",
"Any",
"of",
"the",
"returned",
"values",
"can",
"be",
"nil",
"but"... | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L594-L623 | train |
btcsuite/btcwallet | waddrmgr/db.go | putCryptoKeys | func putCryptoKeys(ns walletdb.ReadWriteBucket, pubKeyEncrypted, privKeyEncrypted,
scriptKeyEncrypted []byte) error {
bucket := ns.NestedReadWriteBucket(mainBucketName)
if pubKeyEncrypted != nil {
err := bucket.Put(cryptoPubKeyName, pubKeyEncrypted)
if err != nil {
str := "failed to store encrypted crypto p... | go | func putCryptoKeys(ns walletdb.ReadWriteBucket, pubKeyEncrypted, privKeyEncrypted,
scriptKeyEncrypted []byte) error {
bucket := ns.NestedReadWriteBucket(mainBucketName)
if pubKeyEncrypted != nil {
err := bucket.Put(cryptoPubKeyName, pubKeyEncrypted)
if err != nil {
str := "failed to store encrypted crypto p... | [
"func",
"putCryptoKeys",
"(",
"ns",
"walletdb",
".",
"ReadWriteBucket",
",",
"pubKeyEncrypted",
",",
"privKeyEncrypted",
",",
"scriptKeyEncrypted",
"[",
"]",
"byte",
")",
"error",
"{",
"bucket",
":=",
"ns",
".",
"NestedReadWriteBucket",
"(",
"mainBucketName",
")",... | // putCryptoKeys stores the encrypted crypto keys which are in turn used to
// protect the extended and imported keys. Either parameter can be nil in
// which case no value is written for the parameter. | [
"putCryptoKeys",
"stores",
"the",
"encrypted",
"crypto",
"keys",
"which",
"are",
"in",
"turn",
"used",
"to",
"protect",
"the",
"extended",
"and",
"imported",
"keys",
".",
"Either",
"parameter",
"can",
"be",
"nil",
"in",
"which",
"case",
"no",
"value",
"is",
... | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L628-L658 | train |
btcsuite/btcwallet | waddrmgr/db.go | fetchWatchingOnly | func fetchWatchingOnly(ns walletdb.ReadBucket) (bool, error) {
bucket := ns.NestedReadBucket(mainBucketName)
buf := bucket.Get(watchingOnlyName)
if len(buf) != 1 {
str := "malformed watching-only flag stored in database"
return false, managerError(ErrDatabase, str, nil)
}
return buf[0] != 0, nil
} | go | func fetchWatchingOnly(ns walletdb.ReadBucket) (bool, error) {
bucket := ns.NestedReadBucket(mainBucketName)
buf := bucket.Get(watchingOnlyName)
if len(buf) != 1 {
str := "malformed watching-only flag stored in database"
return false, managerError(ErrDatabase, str, nil)
}
return buf[0] != 0, nil
} | [
"func",
"fetchWatchingOnly",
"(",
"ns",
"walletdb",
".",
"ReadBucket",
")",
"(",
"bool",
",",
"error",
")",
"{",
"bucket",
":=",
"ns",
".",
"NestedReadBucket",
"(",
"mainBucketName",
")",
"\n\n",
"buf",
":=",
"bucket",
".",
"Get",
"(",
"watchingOnlyName",
... | // fetchWatchingOnly loads the watching-only flag from the database. | [
"fetchWatchingOnly",
"loads",
"the",
"watching",
"-",
"only",
"flag",
"from",
"the",
"database",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L661-L671 | train |
btcsuite/btcwallet | waddrmgr/db.go | putWatchingOnly | func putWatchingOnly(ns walletdb.ReadWriteBucket, watchingOnly bool) error {
bucket := ns.NestedReadWriteBucket(mainBucketName)
var encoded byte
if watchingOnly {
encoded = 1
}
if err := bucket.Put(watchingOnlyName, []byte{encoded}); err != nil {
str := "failed to store watching only flag"
return managerEr... | go | func putWatchingOnly(ns walletdb.ReadWriteBucket, watchingOnly bool) error {
bucket := ns.NestedReadWriteBucket(mainBucketName)
var encoded byte
if watchingOnly {
encoded = 1
}
if err := bucket.Put(watchingOnlyName, []byte{encoded}); err != nil {
str := "failed to store watching only flag"
return managerEr... | [
"func",
"putWatchingOnly",
"(",
"ns",
"walletdb",
".",
"ReadWriteBucket",
",",
"watchingOnly",
"bool",
")",
"error",
"{",
"bucket",
":=",
"ns",
".",
"NestedReadWriteBucket",
"(",
"mainBucketName",
")",
"\n\n",
"var",
"encoded",
"byte",
"\n",
"if",
"watchingOnly"... | // putWatchingOnly stores the watching-only flag to the database. | [
"putWatchingOnly",
"stores",
"the",
"watching",
"-",
"only",
"flag",
"to",
"the",
"database",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L674-L687 | train |
btcsuite/btcwallet | waddrmgr/db.go | deserializeAccountRow | func deserializeAccountRow(accountID []byte, serializedAccount []byte) (*dbAccountRow, error) {
// The serialized account format is:
// <acctType><rdlen><rawdata>
//
// 1 byte acctType + 4 bytes raw data length + raw data
// Given the above, the length of the entry must be at a minimum
// the constant value si... | go | func deserializeAccountRow(accountID []byte, serializedAccount []byte) (*dbAccountRow, error) {
// The serialized account format is:
// <acctType><rdlen><rawdata>
//
// 1 byte acctType + 4 bytes raw data length + raw data
// Given the above, the length of the entry must be at a minimum
// the constant value si... | [
"func",
"deserializeAccountRow",
"(",
"accountID",
"[",
"]",
"byte",
",",
"serializedAccount",
"[",
"]",
"byte",
")",
"(",
"*",
"dbAccountRow",
",",
"error",
")",
"{",
"// The serialized account format is:",
"// <acctType><rdlen><rawdata>",
"//",
"// 1 byte acctType +... | // deserializeAccountRow deserializes the passed serialized account information.
// This is used as a common base for the various account types to deserialize
// the common parts. | [
"deserializeAccountRow",
"deserializes",
"the",
"passed",
"serialized",
"account",
"information",
".",
"This",
"is",
"used",
"as",
"a",
"common",
"base",
"for",
"the",
"various",
"account",
"types",
"to",
"deserialize",
"the",
"common",
"parts",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L692-L713 | train |
btcsuite/btcwallet | waddrmgr/db.go | serializeAccountRow | func serializeAccountRow(row *dbAccountRow) []byte {
// The serialized account format is:
// <acctType><rdlen><rawdata>
//
// 1 byte acctType + 4 bytes raw data length + raw data
rdlen := len(row.rawData)
buf := make([]byte, 5+rdlen)
buf[0] = byte(row.acctType)
binary.LittleEndian.PutUint32(buf[1:5], uint32(r... | go | func serializeAccountRow(row *dbAccountRow) []byte {
// The serialized account format is:
// <acctType><rdlen><rawdata>
//
// 1 byte acctType + 4 bytes raw data length + raw data
rdlen := len(row.rawData)
buf := make([]byte, 5+rdlen)
buf[0] = byte(row.acctType)
binary.LittleEndian.PutUint32(buf[1:5], uint32(r... | [
"func",
"serializeAccountRow",
"(",
"row",
"*",
"dbAccountRow",
")",
"[",
"]",
"byte",
"{",
"// The serialized account format is:",
"// <acctType><rdlen><rawdata>",
"//",
"// 1 byte acctType + 4 bytes raw data length + raw data",
"rdlen",
":=",
"len",
"(",
"row",
".",
"ra... | // serializeAccountRow returns the serialization of the passed account row. | [
"serializeAccountRow",
"returns",
"the",
"serialization",
"of",
"the",
"passed",
"account",
"row",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L716-L727 | train |
btcsuite/btcwallet | waddrmgr/db.go | deserializeDefaultAccountRow | func deserializeDefaultAccountRow(accountID []byte, row *dbAccountRow) (*dbDefaultAccountRow, error) {
// The serialized BIP0044 account raw data format is:
// <encpubkeylen><encpubkey><encprivkeylen><encprivkey><nextextidx>
// <nextintidx><namelen><name>
//
// 4 bytes encrypted pubkey len + encrypted pubkey +... | go | func deserializeDefaultAccountRow(accountID []byte, row *dbAccountRow) (*dbDefaultAccountRow, error) {
// The serialized BIP0044 account raw data format is:
// <encpubkeylen><encpubkey><encprivkeylen><encprivkey><nextextidx>
// <nextintidx><namelen><name>
//
// 4 bytes encrypted pubkey len + encrypted pubkey +... | [
"func",
"deserializeDefaultAccountRow",
"(",
"accountID",
"[",
"]",
"byte",
",",
"row",
"*",
"dbAccountRow",
")",
"(",
"*",
"dbDefaultAccountRow",
",",
"error",
")",
"{",
"// The serialized BIP0044 account raw data format is:",
"// <encpubkeylen><encpubkey><encprivkeylen><e... | // deserializeDefaultAccountRow deserializes the raw data from the passed
// account row as a BIP0044-like account. | [
"deserializeDefaultAccountRow",
"deserializes",
"the",
"raw",
"data",
"from",
"the",
"passed",
"account",
"row",
"as",
"a",
"BIP0044",
"-",
"like",
"account",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L731-L770 | train |
btcsuite/btcwallet | waddrmgr/db.go | serializeDefaultAccountRow | func serializeDefaultAccountRow(encryptedPubKey, encryptedPrivKey []byte,
nextExternalIndex, nextInternalIndex uint32, name string) []byte {
// The serialized BIP0044 account raw data format is:
// <encpubkeylen><encpubkey><encprivkeylen><encprivkey><nextextidx>
// <nextintidx><namelen><name>
//
// 4 bytes e... | go | func serializeDefaultAccountRow(encryptedPubKey, encryptedPrivKey []byte,
nextExternalIndex, nextInternalIndex uint32, name string) []byte {
// The serialized BIP0044 account raw data format is:
// <encpubkeylen><encpubkey><encprivkeylen><encprivkey><nextextidx>
// <nextintidx><namelen><name>
//
// 4 bytes e... | [
"func",
"serializeDefaultAccountRow",
"(",
"encryptedPubKey",
",",
"encryptedPrivKey",
"[",
"]",
"byte",
",",
"nextExternalIndex",
",",
"nextInternalIndex",
"uint32",
",",
"name",
"string",
")",
"[",
"]",
"byte",
"{",
"// The serialized BIP0044 account raw data format is:... | // serializeDefaultAccountRow returns the serialization of the raw data field
// for a BIP0044-like account. | [
"serializeDefaultAccountRow",
"returns",
"the",
"serialization",
"of",
"the",
"raw",
"data",
"field",
"for",
"a",
"BIP0044",
"-",
"like",
"account",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L774-L803 | train |
btcsuite/btcwallet | waddrmgr/db.go | forEachKeyScope | func forEachKeyScope(ns walletdb.ReadBucket, fn func(KeyScope) error) error {
bucket := ns.NestedReadBucket(scopeBucketName)
return bucket.ForEach(func(k, v []byte) error {
// skip non-bucket
if len(k) != 8 {
return nil
}
scope := KeyScope{
Purpose: binary.LittleEndian.Uint32(k[:]),
Coin: binary... | go | func forEachKeyScope(ns walletdb.ReadBucket, fn func(KeyScope) error) error {
bucket := ns.NestedReadBucket(scopeBucketName)
return bucket.ForEach(func(k, v []byte) error {
// skip non-bucket
if len(k) != 8 {
return nil
}
scope := KeyScope{
Purpose: binary.LittleEndian.Uint32(k[:]),
Coin: binary... | [
"func",
"forEachKeyScope",
"(",
"ns",
"walletdb",
".",
"ReadBucket",
",",
"fn",
"func",
"(",
"KeyScope",
")",
"error",
")",
"error",
"{",
"bucket",
":=",
"ns",
".",
"NestedReadBucket",
"(",
"scopeBucketName",
")",
"\n\n",
"return",
"bucket",
".",
"ForEach",
... | // forEachKeyScope calls the given function for each known manager scope
// within the set of scopes known by the root manager. | [
"forEachKeyScope",
"calls",
"the",
"given",
"function",
"for",
"each",
"known",
"manager",
"scope",
"within",
"the",
"set",
"of",
"scopes",
"known",
"by",
"the",
"root",
"manager",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L807-L823 | train |
btcsuite/btcwallet | waddrmgr/db.go | forEachAccount | func forEachAccount(ns walletdb.ReadBucket, scope *KeyScope,
fn func(account uint32) error) error {
scopedBucket, err := fetchReadScopeBucket(ns, scope)
if err != nil {
return err
}
acctBucket := scopedBucket.NestedReadBucket(acctBucketName)
return acctBucket.ForEach(func(k, v []byte) error {
// Skip bucket... | go | func forEachAccount(ns walletdb.ReadBucket, scope *KeyScope,
fn func(account uint32) error) error {
scopedBucket, err := fetchReadScopeBucket(ns, scope)
if err != nil {
return err
}
acctBucket := scopedBucket.NestedReadBucket(acctBucketName)
return acctBucket.ForEach(func(k, v []byte) error {
// Skip bucket... | [
"func",
"forEachAccount",
"(",
"ns",
"walletdb",
".",
"ReadBucket",
",",
"scope",
"*",
"KeyScope",
",",
"fn",
"func",
"(",
"account",
"uint32",
")",
"error",
")",
"error",
"{",
"scopedBucket",
",",
"err",
":=",
"fetchReadScopeBucket",
"(",
"ns",
",",
"scop... | // forEachAccount calls the given function with each account stored in the
// manager, breaking early on error. | [
"forEachAccount",
"calls",
"the",
"given",
"function",
"with",
"each",
"account",
"stored",
"in",
"the",
"manager",
"breaking",
"early",
"on",
"error",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L827-L843 | train |
btcsuite/btcwallet | waddrmgr/db.go | fetchLastAccount | func fetchLastAccount(ns walletdb.ReadBucket, scope *KeyScope) (uint32, error) {
scopedBucket, err := fetchReadScopeBucket(ns, scope)
if err != nil {
return 0, err
}
metaBucket := scopedBucket.NestedReadBucket(metaBucketName)
val := metaBucket.Get(lastAccountName)
if len(val) != 4 {
str := fmt.Sprintf("malf... | go | func fetchLastAccount(ns walletdb.ReadBucket, scope *KeyScope) (uint32, error) {
scopedBucket, err := fetchReadScopeBucket(ns, scope)
if err != nil {
return 0, err
}
metaBucket := scopedBucket.NestedReadBucket(metaBucketName)
val := metaBucket.Get(lastAccountName)
if len(val) != 4 {
str := fmt.Sprintf("malf... | [
"func",
"fetchLastAccount",
"(",
"ns",
"walletdb",
".",
"ReadBucket",
",",
"scope",
"*",
"KeyScope",
")",
"(",
"uint32",
",",
"error",
")",
"{",
"scopedBucket",
",",
"err",
":=",
"fetchReadScopeBucket",
"(",
"ns",
",",
"scope",
")",
"\n",
"if",
"err",
"!... | // fetchLastAccount retrieves the last account from the database. | [
"fetchLastAccount",
"retrieves",
"the",
"last",
"account",
"from",
"the",
"database",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L846-L863 | train |
btcsuite/btcwallet | waddrmgr/db.go | fetchAccountName | func fetchAccountName(ns walletdb.ReadBucket, scope *KeyScope,
account uint32) (string, error) {
scopedBucket, err := fetchReadScopeBucket(ns, scope)
if err != nil {
return "", err
}
acctIDxBucket := scopedBucket.NestedReadBucket(acctIDIdxBucketName)
val := acctIDxBucket.Get(uint32ToBytes(account))
if val =... | go | func fetchAccountName(ns walletdb.ReadBucket, scope *KeyScope,
account uint32) (string, error) {
scopedBucket, err := fetchReadScopeBucket(ns, scope)
if err != nil {
return "", err
}
acctIDxBucket := scopedBucket.NestedReadBucket(acctIDIdxBucketName)
val := acctIDxBucket.Get(uint32ToBytes(account))
if val =... | [
"func",
"fetchAccountName",
"(",
"ns",
"walletdb",
".",
"ReadBucket",
",",
"scope",
"*",
"KeyScope",
",",
"account",
"uint32",
")",
"(",
"string",
",",
"error",
")",
"{",
"scopedBucket",
",",
"err",
":=",
"fetchReadScopeBucket",
"(",
"ns",
",",
"scope",
")... | // fetchAccountName retrieves the account name given an account number from the
// database. | [
"fetchAccountName",
"retrieves",
"the",
"account",
"name",
"given",
"an",
"account",
"number",
"from",
"the",
"database",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L867-L889 | train |
btcsuite/btcwallet | waddrmgr/db.go | fetchAccountByName | func fetchAccountByName(ns walletdb.ReadBucket, scope *KeyScope,
name string) (uint32, error) {
scopedBucket, err := fetchReadScopeBucket(ns, scope)
if err != nil {
return 0, err
}
idxBucket := scopedBucket.NestedReadBucket(acctNameIdxBucketName)
val := idxBucket.Get(stringToBytes(name))
if val == nil {
s... | go | func fetchAccountByName(ns walletdb.ReadBucket, scope *KeyScope,
name string) (uint32, error) {
scopedBucket, err := fetchReadScopeBucket(ns, scope)
if err != nil {
return 0, err
}
idxBucket := scopedBucket.NestedReadBucket(acctNameIdxBucketName)
val := idxBucket.Get(stringToBytes(name))
if val == nil {
s... | [
"func",
"fetchAccountByName",
"(",
"ns",
"walletdb",
".",
"ReadBucket",
",",
"scope",
"*",
"KeyScope",
",",
"name",
"string",
")",
"(",
"uint32",
",",
"error",
")",
"{",
"scopedBucket",
",",
"err",
":=",
"fetchReadScopeBucket",
"(",
"ns",
",",
"scope",
")"... | // fetchAccountByName retrieves the account number given an account name from
// the database. | [
"fetchAccountByName",
"retrieves",
"the",
"account",
"number",
"given",
"an",
"account",
"name",
"from",
"the",
"database",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L893-L910 | train |
btcsuite/btcwallet | waddrmgr/db.go | fetchAccountInfo | func fetchAccountInfo(ns walletdb.ReadBucket, scope *KeyScope,
account uint32) (interface{}, error) {
scopedBucket, err := fetchReadScopeBucket(ns, scope)
if err != nil {
return nil, err
}
acctBucket := scopedBucket.NestedReadBucket(acctBucketName)
accountID := uint32ToBytes(account)
serializedRow := acctBu... | go | func fetchAccountInfo(ns walletdb.ReadBucket, scope *KeyScope,
account uint32) (interface{}, error) {
scopedBucket, err := fetchReadScopeBucket(ns, scope)
if err != nil {
return nil, err
}
acctBucket := scopedBucket.NestedReadBucket(acctBucketName)
accountID := uint32ToBytes(account)
serializedRow := acctBu... | [
"func",
"fetchAccountInfo",
"(",
"ns",
"walletdb",
".",
"ReadBucket",
",",
"scope",
"*",
"KeyScope",
",",
"account",
"uint32",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"scopedBucket",
",",
"err",
":=",
"fetchReadScopeBucket",
"(",
"ns",
","... | // fetchAccountInfo loads information about the passed account from the
// database. | [
"fetchAccountInfo",
"loads",
"information",
"about",
"the",
"passed",
"account",
"from",
"the",
"database",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L914-L943 | train |
btcsuite/btcwallet | waddrmgr/db.go | deleteAccountNameIndex | func deleteAccountNameIndex(ns walletdb.ReadWriteBucket, scope *KeyScope,
name string) error {
scopedBucket, err := fetchWriteScopeBucket(ns, scope)
if err != nil {
return err
}
bucket := scopedBucket.NestedReadWriteBucket(acctNameIdxBucketName)
// Delete the account name key
err = bucket.Delete(stringToByt... | go | func deleteAccountNameIndex(ns walletdb.ReadWriteBucket, scope *KeyScope,
name string) error {
scopedBucket, err := fetchWriteScopeBucket(ns, scope)
if err != nil {
return err
}
bucket := scopedBucket.NestedReadWriteBucket(acctNameIdxBucketName)
// Delete the account name key
err = bucket.Delete(stringToByt... | [
"func",
"deleteAccountNameIndex",
"(",
"ns",
"walletdb",
".",
"ReadWriteBucket",
",",
"scope",
"*",
"KeyScope",
",",
"name",
"string",
")",
"error",
"{",
"scopedBucket",
",",
"err",
":=",
"fetchWriteScopeBucket",
"(",
"ns",
",",
"scope",
")",
"\n",
"if",
"er... | // deleteAccountNameIndex deletes the given key from the account name index of the database. | [
"deleteAccountNameIndex",
"deletes",
"the",
"given",
"key",
"from",
"the",
"account",
"name",
"index",
"of",
"the",
"database",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L946-L963 | train |
btcsuite/btcwallet | waddrmgr/db.go | deleteAccountIDIndex | func deleteAccountIDIndex(ns walletdb.ReadWriteBucket, scope *KeyScope,
account uint32) error {
scopedBucket, err := fetchWriteScopeBucket(ns, scope)
if err != nil {
return err
}
bucket := scopedBucket.NestedReadWriteBucket(acctIDIdxBucketName)
// Delete the account id key
err = bucket.Delete(uint32ToBytes(... | go | func deleteAccountIDIndex(ns walletdb.ReadWriteBucket, scope *KeyScope,
account uint32) error {
scopedBucket, err := fetchWriteScopeBucket(ns, scope)
if err != nil {
return err
}
bucket := scopedBucket.NestedReadWriteBucket(acctIDIdxBucketName)
// Delete the account id key
err = bucket.Delete(uint32ToBytes(... | [
"func",
"deleteAccountIDIndex",
"(",
"ns",
"walletdb",
".",
"ReadWriteBucket",
",",
"scope",
"*",
"KeyScope",
",",
"account",
"uint32",
")",
"error",
"{",
"scopedBucket",
",",
"err",
":=",
"fetchWriteScopeBucket",
"(",
"ns",
",",
"scope",
")",
"\n",
"if",
"e... | // deleteAccounIdIndex deletes the given key from the account id index of the database. | [
"deleteAccounIdIndex",
"deletes",
"the",
"given",
"key",
"from",
"the",
"account",
"id",
"index",
"of",
"the",
"database",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L966-L983 | train |
btcsuite/btcwallet | waddrmgr/db.go | putAccountNameIndex | func putAccountNameIndex(ns walletdb.ReadWriteBucket, scope *KeyScope,
account uint32, name string) error {
scopedBucket, err := fetchWriteScopeBucket(ns, scope)
if err != nil {
return err
}
bucket := scopedBucket.NestedReadWriteBucket(acctNameIdxBucketName)
// Write the account number keyed by the account n... | go | func putAccountNameIndex(ns walletdb.ReadWriteBucket, scope *KeyScope,
account uint32, name string) error {
scopedBucket, err := fetchWriteScopeBucket(ns, scope)
if err != nil {
return err
}
bucket := scopedBucket.NestedReadWriteBucket(acctNameIdxBucketName)
// Write the account number keyed by the account n... | [
"func",
"putAccountNameIndex",
"(",
"ns",
"walletdb",
".",
"ReadWriteBucket",
",",
"scope",
"*",
"KeyScope",
",",
"account",
"uint32",
",",
"name",
"string",
")",
"error",
"{",
"scopedBucket",
",",
"err",
":=",
"fetchWriteScopeBucket",
"(",
"ns",
",",
"scope",... | // putAccountNameIndex stores the given key to the account name index of the
// database. | [
"putAccountNameIndex",
"stores",
"the",
"given",
"key",
"to",
"the",
"account",
"name",
"index",
"of",
"the",
"database",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L987-L1004 | train |
btcsuite/btcwallet | waddrmgr/db.go | putAddrAccountIndex | func putAddrAccountIndex(ns walletdb.ReadWriteBucket, scope *KeyScope,
account uint32, addrHash []byte) error {
scopedBucket, err := fetchWriteScopeBucket(ns, scope)
if err != nil {
return err
}
bucket := scopedBucket.NestedReadWriteBucket(addrAcctIdxBucketName)
// Write account keyed by address hash
err = ... | go | func putAddrAccountIndex(ns walletdb.ReadWriteBucket, scope *KeyScope,
account uint32, addrHash []byte) error {
scopedBucket, err := fetchWriteScopeBucket(ns, scope)
if err != nil {
return err
}
bucket := scopedBucket.NestedReadWriteBucket(addrAcctIdxBucketName)
// Write account keyed by address hash
err = ... | [
"func",
"putAddrAccountIndex",
"(",
"ns",
"walletdb",
".",
"ReadWriteBucket",
",",
"scope",
"*",
"KeyScope",
",",
"account",
"uint32",
",",
"addrHash",
"[",
"]",
"byte",
")",
"error",
"{",
"scopedBucket",
",",
"err",
":=",
"fetchWriteScopeBucket",
"(",
"ns",
... | // putAddrAccountIndex stores the given key to the address account index of the
// database. | [
"putAddrAccountIndex",
"stores",
"the",
"given",
"key",
"to",
"the",
"address",
"account",
"index",
"of",
"the",
"database",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L1028-L1056 | train |
btcsuite/btcwallet | waddrmgr/db.go | putAccountRow | func putAccountRow(ns walletdb.ReadWriteBucket, scope *KeyScope,
account uint32, row *dbAccountRow) error {
scopedBucket, err := fetchWriteScopeBucket(ns, scope)
if err != nil {
return err
}
bucket := scopedBucket.NestedReadWriteBucket(acctBucketName)
// Write the serialized value keyed by the account number... | go | func putAccountRow(ns walletdb.ReadWriteBucket, scope *KeyScope,
account uint32, row *dbAccountRow) error {
scopedBucket, err := fetchWriteScopeBucket(ns, scope)
if err != nil {
return err
}
bucket := scopedBucket.NestedReadWriteBucket(acctBucketName)
// Write the serialized value keyed by the account number... | [
"func",
"putAccountRow",
"(",
"ns",
"walletdb",
".",
"ReadWriteBucket",
",",
"scope",
"*",
"KeyScope",
",",
"account",
"uint32",
",",
"row",
"*",
"dbAccountRow",
")",
"error",
"{",
"scopedBucket",
",",
"err",
":=",
"fetchWriteScopeBucket",
"(",
"ns",
",",
"s... | // putAccountRow stores the provided account information to the database. This
// is used a common base for storing the various account types. | [
"putAccountRow",
"stores",
"the",
"provided",
"account",
"information",
"to",
"the",
"database",
".",
"This",
"is",
"used",
"a",
"common",
"base",
"for",
"storing",
"the",
"various",
"account",
"types",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L1060-L1077 | train |
btcsuite/btcwallet | waddrmgr/db.go | putAccountInfo | func putAccountInfo(ns walletdb.ReadWriteBucket, scope *KeyScope,
account uint32, encryptedPubKey, encryptedPrivKey []byte,
nextExternalIndex, nextInternalIndex uint32, name string) error {
rawData := serializeDefaultAccountRow(
encryptedPubKey, encryptedPrivKey, nextExternalIndex,
nextInternalIndex, name,
)
... | go | func putAccountInfo(ns walletdb.ReadWriteBucket, scope *KeyScope,
account uint32, encryptedPubKey, encryptedPrivKey []byte,
nextExternalIndex, nextInternalIndex uint32, name string) error {
rawData := serializeDefaultAccountRow(
encryptedPubKey, encryptedPrivKey, nextExternalIndex,
nextInternalIndex, name,
)
... | [
"func",
"putAccountInfo",
"(",
"ns",
"walletdb",
".",
"ReadWriteBucket",
",",
"scope",
"*",
"KeyScope",
",",
"account",
"uint32",
",",
"encryptedPubKey",
",",
"encryptedPrivKey",
"[",
"]",
"byte",
",",
"nextExternalIndex",
",",
"nextInternalIndex",
"uint32",
",",
... | // putAccountInfo stores the provided account information to the database. | [
"putAccountInfo",
"stores",
"the",
"provided",
"account",
"information",
"to",
"the",
"database",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L1080-L1110 | train |
btcsuite/btcwallet | waddrmgr/db.go | putLastAccount | func putLastAccount(ns walletdb.ReadWriteBucket, scope *KeyScope,
account uint32) error {
scopedBucket, err := fetchWriteScopeBucket(ns, scope)
if err != nil {
return err
}
bucket := scopedBucket.NestedReadWriteBucket(metaBucketName)
err = bucket.Put(lastAccountName, uint32ToBytes(account))
if err != nil {
... | go | func putLastAccount(ns walletdb.ReadWriteBucket, scope *KeyScope,
account uint32) error {
scopedBucket, err := fetchWriteScopeBucket(ns, scope)
if err != nil {
return err
}
bucket := scopedBucket.NestedReadWriteBucket(metaBucketName)
err = bucket.Put(lastAccountName, uint32ToBytes(account))
if err != nil {
... | [
"func",
"putLastAccount",
"(",
"ns",
"walletdb",
".",
"ReadWriteBucket",
",",
"scope",
"*",
"KeyScope",
",",
"account",
"uint32",
")",
"error",
"{",
"scopedBucket",
",",
"err",
":=",
"fetchWriteScopeBucket",
"(",
"ns",
",",
"scope",
")",
"\n",
"if",
"err",
... | // putLastAccount stores the provided metadata - last account - to the
// database. | [
"putLastAccount",
"stores",
"the",
"provided",
"metadata",
"-",
"last",
"account",
"-",
"to",
"the",
"database",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L1114-L1130 | train |
btcsuite/btcwallet | waddrmgr/db.go | deserializeAddressRow | func deserializeAddressRow(serializedAddress []byte) (*dbAddressRow, error) {
// The serialized address format is:
// <addrType><account><addedTime><syncStatus><rawdata>
//
// 1 byte addrType + 4 bytes account + 8 bytes addTime + 1 byte
// syncStatus + 4 bytes raw data length + raw data
// Given the above, the... | go | func deserializeAddressRow(serializedAddress []byte) (*dbAddressRow, error) {
// The serialized address format is:
// <addrType><account><addedTime><syncStatus><rawdata>
//
// 1 byte addrType + 4 bytes account + 8 bytes addTime + 1 byte
// syncStatus + 4 bytes raw data length + raw data
// Given the above, the... | [
"func",
"deserializeAddressRow",
"(",
"serializedAddress",
"[",
"]",
"byte",
")",
"(",
"*",
"dbAddressRow",
",",
"error",
")",
"{",
"// The serialized address format is:",
"// <addrType><account><addedTime><syncStatus><rawdata>",
"//",
"// 1 byte addrType + 4 bytes account + 8 ... | // deserializeAddressRow deserializes the passed serialized address
// information. This is used as a common base for the various address types to
// deserialize the common parts. | [
"deserializeAddressRow",
"deserializes",
"the",
"passed",
"serialized",
"address",
"information",
".",
"This",
"is",
"used",
"as",
"a",
"common",
"base",
"for",
"the",
"various",
"address",
"types",
"to",
"deserialize",
"the",
"common",
"parts",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L1135-L1159 | train |
btcsuite/btcwallet | waddrmgr/db.go | serializeAddressRow | func serializeAddressRow(row *dbAddressRow) []byte {
// The serialized address format is:
// <addrType><account><addedTime><syncStatus><commentlen><comment>
// <rawdata>
//
// 1 byte addrType + 4 bytes account + 8 bytes addTime + 1 byte
// syncStatus + 4 bytes raw data length + raw data
rdlen := len(row.rawD... | go | func serializeAddressRow(row *dbAddressRow) []byte {
// The serialized address format is:
// <addrType><account><addedTime><syncStatus><commentlen><comment>
// <rawdata>
//
// 1 byte addrType + 4 bytes account + 8 bytes addTime + 1 byte
// syncStatus + 4 bytes raw data length + raw data
rdlen := len(row.rawD... | [
"func",
"serializeAddressRow",
"(",
"row",
"*",
"dbAddressRow",
")",
"[",
"]",
"byte",
"{",
"// The serialized address format is:",
"// <addrType><account><addedTime><syncStatus><commentlen><comment>",
"// <rawdata>",
"//",
"// 1 byte addrType + 4 bytes account + 8 bytes addTime + ... | // serializeAddressRow returns the serialization of the passed address row. | [
"serializeAddressRow",
"returns",
"the",
"serialization",
"of",
"the",
"passed",
"address",
"row",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L1162-L1178 | train |
btcsuite/btcwallet | waddrmgr/db.go | deserializeChainedAddress | func deserializeChainedAddress(row *dbAddressRow) (*dbChainAddressRow, error) {
// The serialized chain address raw data format is:
// <branch><index>
//
// 4 bytes branch + 4 bytes address index
if len(row.rawData) != 8 {
str := "malformed serialized chained address"
return nil, managerError(ErrDatabase, st... | go | func deserializeChainedAddress(row *dbAddressRow) (*dbChainAddressRow, error) {
// The serialized chain address raw data format is:
// <branch><index>
//
// 4 bytes branch + 4 bytes address index
if len(row.rawData) != 8 {
str := "malformed serialized chained address"
return nil, managerError(ErrDatabase, st... | [
"func",
"deserializeChainedAddress",
"(",
"row",
"*",
"dbAddressRow",
")",
"(",
"*",
"dbChainAddressRow",
",",
"error",
")",
"{",
"// The serialized chain address raw data format is:",
"// <branch><index>",
"//",
"// 4 bytes branch + 4 bytes address index",
"if",
"len",
"("... | // deserializeChainedAddress deserializes the raw data from the passed address
// row as a chained address. | [
"deserializeChainedAddress",
"deserializes",
"the",
"raw",
"data",
"from",
"the",
"passed",
"address",
"row",
"as",
"a",
"chained",
"address",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L1182-L1200 | train |
btcsuite/btcwallet | waddrmgr/db.go | serializeChainedAddress | func serializeChainedAddress(branch, index uint32) []byte {
// The serialized chain address raw data format is:
// <branch><index>
//
// 4 bytes branch + 4 bytes address index
rawData := make([]byte, 8)
binary.LittleEndian.PutUint32(rawData[0:4], branch)
binary.LittleEndian.PutUint32(rawData[4:8], index)
retu... | go | func serializeChainedAddress(branch, index uint32) []byte {
// The serialized chain address raw data format is:
// <branch><index>
//
// 4 bytes branch + 4 bytes address index
rawData := make([]byte, 8)
binary.LittleEndian.PutUint32(rawData[0:4], branch)
binary.LittleEndian.PutUint32(rawData[4:8], index)
retu... | [
"func",
"serializeChainedAddress",
"(",
"branch",
",",
"index",
"uint32",
")",
"[",
"]",
"byte",
"{",
"// The serialized chain address raw data format is:",
"// <branch><index>",
"//",
"// 4 bytes branch + 4 bytes address index",
"rawData",
":=",
"make",
"(",
"[",
"]",
... | // serializeChainedAddress returns the serialization of the raw data field for
// a chained address. | [
"serializeChainedAddress",
"returns",
"the",
"serialization",
"of",
"the",
"raw",
"data",
"field",
"for",
"a",
"chained",
"address",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L1204-L1213 | train |
btcsuite/btcwallet | waddrmgr/db.go | deserializeImportedAddress | func deserializeImportedAddress(row *dbAddressRow) (*dbImportedAddressRow, error) {
// The serialized imported address raw data format is:
// <encpubkeylen><encpubkey><encprivkeylen><encprivkey>
//
// 4 bytes encrypted pubkey len + encrypted pubkey + 4 bytes encrypted
// privkey len + encrypted privkey
// Give... | go | func deserializeImportedAddress(row *dbAddressRow) (*dbImportedAddressRow, error) {
// The serialized imported address raw data format is:
// <encpubkeylen><encpubkey><encprivkeylen><encprivkey>
//
// 4 bytes encrypted pubkey len + encrypted pubkey + 4 bytes encrypted
// privkey len + encrypted privkey
// Give... | [
"func",
"deserializeImportedAddress",
"(",
"row",
"*",
"dbAddressRow",
")",
"(",
"*",
"dbImportedAddressRow",
",",
"error",
")",
"{",
"// The serialized imported address raw data format is:",
"// <encpubkeylen><encpubkey><encprivkeylen><encprivkey>",
"//",
"// 4 bytes encrypted p... | // deserializeImportedAddress deserializes the raw data from the passed address
// row as an imported address. | [
"deserializeImportedAddress",
"deserializes",
"the",
"raw",
"data",
"from",
"the",
"passed",
"address",
"row",
"as",
"an",
"imported",
"address",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L1217-L1245 | train |
btcsuite/btcwallet | waddrmgr/db.go | serializeImportedAddress | func serializeImportedAddress(encryptedPubKey, encryptedPrivKey []byte) []byte {
// The serialized imported address raw data format is:
// <encpubkeylen><encpubkey><encprivkeylen><encprivkey>
//
// 4 bytes encrypted pubkey len + encrypted pubkey + 4 bytes encrypted
// privkey len + encrypted privkey
pubLen := u... | go | func serializeImportedAddress(encryptedPubKey, encryptedPrivKey []byte) []byte {
// The serialized imported address raw data format is:
// <encpubkeylen><encpubkey><encprivkeylen><encprivkey>
//
// 4 bytes encrypted pubkey len + encrypted pubkey + 4 bytes encrypted
// privkey len + encrypted privkey
pubLen := u... | [
"func",
"serializeImportedAddress",
"(",
"encryptedPubKey",
",",
"encryptedPrivKey",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"// The serialized imported address raw data format is:",
"// <encpubkeylen><encpubkey><encprivkeylen><encprivkey>",
"//",
"// 4 bytes encrypted pubk... | // serializeImportedAddress returns the serialization of the raw data field for
// an imported address. | [
"serializeImportedAddress",
"returns",
"the",
"serialization",
"of",
"the",
"raw",
"data",
"field",
"for",
"an",
"imported",
"address",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L1249-L1265 | train |
btcsuite/btcwallet | waddrmgr/db.go | deserializeScriptAddress | func deserializeScriptAddress(row *dbAddressRow) (*dbScriptAddressRow, error) {
// The serialized script address raw data format is:
// <encscripthashlen><encscripthash><encscriptlen><encscript>
//
// 4 bytes encrypted script hash len + encrypted script hash + 4 bytes
// encrypted script len + encrypted script
... | go | func deserializeScriptAddress(row *dbAddressRow) (*dbScriptAddressRow, error) {
// The serialized script address raw data format is:
// <encscripthashlen><encscripthash><encscriptlen><encscript>
//
// 4 bytes encrypted script hash len + encrypted script hash + 4 bytes
// encrypted script len + encrypted script
... | [
"func",
"deserializeScriptAddress",
"(",
"row",
"*",
"dbAddressRow",
")",
"(",
"*",
"dbScriptAddressRow",
",",
"error",
")",
"{",
"// The serialized script address raw data format is:",
"// <encscripthashlen><encscripthash><encscriptlen><encscript>",
"//",
"// 4 bytes encrypted s... | // deserializeScriptAddress deserializes the raw data from the passed address
// row as a script address. | [
"deserializeScriptAddress",
"deserializes",
"the",
"raw",
"data",
"from",
"the",
"passed",
"address",
"row",
"as",
"a",
"script",
"address",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L1269-L1297 | train |
btcsuite/btcwallet | waddrmgr/db.go | serializeScriptAddress | func serializeScriptAddress(encryptedHash, encryptedScript []byte) []byte {
// The serialized script address raw data format is:
// <encscripthashlen><encscripthash><encscriptlen><encscript>
//
// 4 bytes encrypted script hash len + encrypted script hash + 4 bytes
// encrypted script len + encrypted script
has... | go | func serializeScriptAddress(encryptedHash, encryptedScript []byte) []byte {
// The serialized script address raw data format is:
// <encscripthashlen><encscripthash><encscriptlen><encscript>
//
// 4 bytes encrypted script hash len + encrypted script hash + 4 bytes
// encrypted script len + encrypted script
has... | [
"func",
"serializeScriptAddress",
"(",
"encryptedHash",
",",
"encryptedScript",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"// The serialized script address raw data format is:",
"// <encscripthashlen><encscripthash><encscriptlen><encscript>",
"//",
"// 4 bytes encrypted scrip... | // serializeScriptAddress returns the serialization of the raw data field for
// a script address. | [
"serializeScriptAddress",
"returns",
"the",
"serialization",
"of",
"the",
"raw",
"data",
"field",
"for",
"a",
"script",
"address",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L1301-L1318 | train |
btcsuite/btcwallet | waddrmgr/db.go | fetchAddressByHash | func fetchAddressByHash(ns walletdb.ReadBucket, scope *KeyScope,
addrHash []byte) (interface{}, error) {
scopedBucket, err := fetchReadScopeBucket(ns, scope)
if err != nil {
return nil, err
}
bucket := scopedBucket.NestedReadBucket(addrBucketName)
serializedRow := bucket.Get(addrHash[:])
if serializedRow ==... | go | func fetchAddressByHash(ns walletdb.ReadBucket, scope *KeyScope,
addrHash []byte) (interface{}, error) {
scopedBucket, err := fetchReadScopeBucket(ns, scope)
if err != nil {
return nil, err
}
bucket := scopedBucket.NestedReadBucket(addrBucketName)
serializedRow := bucket.Get(addrHash[:])
if serializedRow ==... | [
"func",
"fetchAddressByHash",
"(",
"ns",
"walletdb",
".",
"ReadBucket",
",",
"scope",
"*",
"KeyScope",
",",
"addrHash",
"[",
"]",
"byte",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"scopedBucket",
",",
"err",
":=",
"fetchReadScopeBucket",
"("... | // fetchAddressByHash loads address information for the provided address hash
// from the database. The returned value is one of the address rows for the
// specific address type. The caller should use type assertions to ascertain
// the type. The caller should prefix the error message with the address hash
// which... | [
"fetchAddressByHash",
"loads",
"address",
"information",
"for",
"the",
"provided",
"address",
"hash",
"from",
"the",
"database",
".",
"The",
"returned",
"value",
"is",
"one",
"of",
"the",
"address",
"rows",
"for",
"the",
"specific",
"address",
"type",
".",
"Th... | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L1325-L1357 | train |
btcsuite/btcwallet | waddrmgr/db.go | fetchAddressUsed | func fetchAddressUsed(ns walletdb.ReadBucket, scope *KeyScope,
addressID []byte) bool {
scopedBucket, err := fetchReadScopeBucket(ns, scope)
if err != nil {
return false
}
bucket := scopedBucket.NestedReadBucket(usedAddrBucketName)
addrHash := sha256.Sum256(addressID)
return bucket.Get(addrHash[:]) != nil
} | go | func fetchAddressUsed(ns walletdb.ReadBucket, scope *KeyScope,
addressID []byte) bool {
scopedBucket, err := fetchReadScopeBucket(ns, scope)
if err != nil {
return false
}
bucket := scopedBucket.NestedReadBucket(usedAddrBucketName)
addrHash := sha256.Sum256(addressID)
return bucket.Get(addrHash[:]) != nil
} | [
"func",
"fetchAddressUsed",
"(",
"ns",
"walletdb",
".",
"ReadBucket",
",",
"scope",
"*",
"KeyScope",
",",
"addressID",
"[",
"]",
"byte",
")",
"bool",
"{",
"scopedBucket",
",",
"err",
":=",
"fetchReadScopeBucket",
"(",
"ns",
",",
"scope",
")",
"\n",
"if",
... | // fetchAddressUsed returns true if the provided address id was flagged as used. | [
"fetchAddressUsed",
"returns",
"true",
"if",
"the",
"provided",
"address",
"id",
"was",
"flagged",
"as",
"used",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L1360-L1372 | train |
btcsuite/btcwallet | waddrmgr/db.go | markAddressUsed | func markAddressUsed(ns walletdb.ReadWriteBucket, scope *KeyScope,
addressID []byte) error {
scopedBucket, err := fetchWriteScopeBucket(ns, scope)
if err != nil {
return err
}
bucket := scopedBucket.NestedReadWriteBucket(usedAddrBucketName)
addrHash := sha256.Sum256(addressID)
val := bucket.Get(addrHash[:])... | go | func markAddressUsed(ns walletdb.ReadWriteBucket, scope *KeyScope,
addressID []byte) error {
scopedBucket, err := fetchWriteScopeBucket(ns, scope)
if err != nil {
return err
}
bucket := scopedBucket.NestedReadWriteBucket(usedAddrBucketName)
addrHash := sha256.Sum256(addressID)
val := bucket.Get(addrHash[:])... | [
"func",
"markAddressUsed",
"(",
"ns",
"walletdb",
".",
"ReadWriteBucket",
",",
"scope",
"*",
"KeyScope",
",",
"addressID",
"[",
"]",
"byte",
")",
"error",
"{",
"scopedBucket",
",",
"err",
":=",
"fetchWriteScopeBucket",
"(",
"ns",
",",
"scope",
")",
"\n",
"... | // markAddressUsed flags the provided address id as used in the database. | [
"markAddressUsed",
"flags",
"the",
"provided",
"address",
"id",
"as",
"used",
"in",
"the",
"database",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L1375-L1398 | train |
btcsuite/btcwallet | waddrmgr/db.go | fetchAddress | func fetchAddress(ns walletdb.ReadBucket, scope *KeyScope,
addressID []byte) (interface{}, error) {
addrHash := sha256.Sum256(addressID)
return fetchAddressByHash(ns, scope, addrHash[:])
} | go | func fetchAddress(ns walletdb.ReadBucket, scope *KeyScope,
addressID []byte) (interface{}, error) {
addrHash := sha256.Sum256(addressID)
return fetchAddressByHash(ns, scope, addrHash[:])
} | [
"func",
"fetchAddress",
"(",
"ns",
"walletdb",
".",
"ReadBucket",
",",
"scope",
"*",
"KeyScope",
",",
"addressID",
"[",
"]",
"byte",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"addrHash",
":=",
"sha256",
".",
"Sum256",
"(",
"addressID",
"... | // fetchAddress loads address information for the provided address id from the
// database. The returned value is one of the address rows for the specific
// address type. The caller should use type assertions to ascertain the type.
// The caller should prefix the error message with the address which caused the
// fa... | [
"fetchAddress",
"loads",
"address",
"information",
"for",
"the",
"provided",
"address",
"id",
"from",
"the",
"database",
".",
"The",
"returned",
"value",
"is",
"one",
"of",
"the",
"address",
"rows",
"for",
"the",
"specific",
"address",
"type",
".",
"The",
"c... | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L1405-L1410 | train |
btcsuite/btcwallet | waddrmgr/db.go | putAddress | func putAddress(ns walletdb.ReadWriteBucket, scope *KeyScope,
addressID []byte, row *dbAddressRow) error {
scopedBucket, err := fetchWriteScopeBucket(ns, scope)
if err != nil {
return err
}
bucket := scopedBucket.NestedReadWriteBucket(addrBucketName)
// Write the serialized value keyed by the hash of the add... | go | func putAddress(ns walletdb.ReadWriteBucket, scope *KeyScope,
addressID []byte, row *dbAddressRow) error {
scopedBucket, err := fetchWriteScopeBucket(ns, scope)
if err != nil {
return err
}
bucket := scopedBucket.NestedReadWriteBucket(addrBucketName)
// Write the serialized value keyed by the hash of the add... | [
"func",
"putAddress",
"(",
"ns",
"walletdb",
".",
"ReadWriteBucket",
",",
"scope",
"*",
"KeyScope",
",",
"addressID",
"[",
"]",
"byte",
",",
"row",
"*",
"dbAddressRow",
")",
"error",
"{",
"scopedBucket",
",",
"err",
":=",
"fetchWriteScopeBucket",
"(",
"ns",
... | // putAddress stores the provided address information to the database. This is
// used a common base for storing the various address types. | [
"putAddress",
"stores",
"the",
"provided",
"address",
"information",
"to",
"the",
"database",
".",
"This",
"is",
"used",
"a",
"common",
"base",
"for",
"storing",
"the",
"various",
"address",
"types",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L1414-L1436 | train |
btcsuite/btcwallet | waddrmgr/db.go | putChainedAddress | func putChainedAddress(ns walletdb.ReadWriteBucket, scope *KeyScope,
addressID []byte, account uint32, status syncStatus, branch,
index uint32, addrType addressType) error {
scopedBucket, err := fetchWriteScopeBucket(ns, scope)
if err != nil {
return err
}
addrRow := dbAddressRow{
addrType: addrType,
ac... | go | func putChainedAddress(ns walletdb.ReadWriteBucket, scope *KeyScope,
addressID []byte, account uint32, status syncStatus, branch,
index uint32, addrType addressType) error {
scopedBucket, err := fetchWriteScopeBucket(ns, scope)
if err != nil {
return err
}
addrRow := dbAddressRow{
addrType: addrType,
ac... | [
"func",
"putChainedAddress",
"(",
"ns",
"walletdb",
".",
"ReadWriteBucket",
",",
"scope",
"*",
"KeyScope",
",",
"addressID",
"[",
"]",
"byte",
",",
"account",
"uint32",
",",
"status",
"syncStatus",
",",
"branch",
",",
"index",
"uint32",
",",
"addrType",
"add... | // putChainedAddress stores the provided chained address information to the
// database. | [
"putChainedAddress",
"stores",
"the",
"provided",
"chained",
"address",
"information",
"to",
"the",
"database",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L1440-L1498 | train |
btcsuite/btcwallet | waddrmgr/db.go | putImportedAddress | func putImportedAddress(ns walletdb.ReadWriteBucket, scope *KeyScope,
addressID []byte, account uint32, status syncStatus,
encryptedPubKey, encryptedPrivKey []byte) error {
rawData := serializeImportedAddress(encryptedPubKey, encryptedPrivKey)
addrRow := dbAddressRow{
addrType: adtImport,
account: account... | go | func putImportedAddress(ns walletdb.ReadWriteBucket, scope *KeyScope,
addressID []byte, account uint32, status syncStatus,
encryptedPubKey, encryptedPrivKey []byte) error {
rawData := serializeImportedAddress(encryptedPubKey, encryptedPrivKey)
addrRow := dbAddressRow{
addrType: adtImport,
account: account... | [
"func",
"putImportedAddress",
"(",
"ns",
"walletdb",
".",
"ReadWriteBucket",
",",
"scope",
"*",
"KeyScope",
",",
"addressID",
"[",
"]",
"byte",
",",
"account",
"uint32",
",",
"status",
"syncStatus",
",",
"encryptedPubKey",
",",
"encryptedPrivKey",
"[",
"]",
"b... | // putImportedAddress stores the provided imported address information to the
// database. | [
"putImportedAddress",
"stores",
"the",
"provided",
"imported",
"address",
"information",
"to",
"the",
"database",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L1502-L1515 | train |
btcsuite/btcwallet | waddrmgr/db.go | putScriptAddress | func putScriptAddress(ns walletdb.ReadWriteBucket, scope *KeyScope,
addressID []byte, account uint32, status syncStatus,
encryptedHash, encryptedScript []byte) error {
rawData := serializeScriptAddress(encryptedHash, encryptedScript)
addrRow := dbAddressRow{
addrType: adtScript,
account: account,
addTim... | go | func putScriptAddress(ns walletdb.ReadWriteBucket, scope *KeyScope,
addressID []byte, account uint32, status syncStatus,
encryptedHash, encryptedScript []byte) error {
rawData := serializeScriptAddress(encryptedHash, encryptedScript)
addrRow := dbAddressRow{
addrType: adtScript,
account: account,
addTim... | [
"func",
"putScriptAddress",
"(",
"ns",
"walletdb",
".",
"ReadWriteBucket",
",",
"scope",
"*",
"KeyScope",
",",
"addressID",
"[",
"]",
"byte",
",",
"account",
"uint32",
",",
"status",
"syncStatus",
",",
"encryptedHash",
",",
"encryptedScript",
"[",
"]",
"byte",... | // putScriptAddress stores the provided script address information to the
// database. | [
"putScriptAddress",
"stores",
"the",
"provided",
"script",
"address",
"information",
"to",
"the",
"database",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L1519-L1536 | train |
btcsuite/btcwallet | waddrmgr/db.go | fetchAddrAccount | func fetchAddrAccount(ns walletdb.ReadBucket, scope *KeyScope,
addressID []byte) (uint32, error) {
scopedBucket, err := fetchReadScopeBucket(ns, scope)
if err != nil {
return 0, err
}
bucket := scopedBucket.NestedReadBucket(addrAcctIdxBucketName)
addrHash := sha256.Sum256(addressID)
val := bucket.Get(addrHa... | go | func fetchAddrAccount(ns walletdb.ReadBucket, scope *KeyScope,
addressID []byte) (uint32, error) {
scopedBucket, err := fetchReadScopeBucket(ns, scope)
if err != nil {
return 0, err
}
bucket := scopedBucket.NestedReadBucket(addrAcctIdxBucketName)
addrHash := sha256.Sum256(addressID)
val := bucket.Get(addrHa... | [
"func",
"fetchAddrAccount",
"(",
"ns",
"walletdb",
".",
"ReadBucket",
",",
"scope",
"*",
"KeyScope",
",",
"addressID",
"[",
"]",
"byte",
")",
"(",
"uint32",
",",
"error",
")",
"{",
"scopedBucket",
",",
"err",
":=",
"fetchReadScopeBucket",
"(",
"ns",
",",
... | // fetchAddrAccount returns the account to which the given address belongs to.
// It looks up the account using the addracctidx index which maps the address
// hash to its corresponding account id. | [
"fetchAddrAccount",
"returns",
"the",
"account",
"to",
"which",
"the",
"given",
"address",
"belongs",
"to",
".",
"It",
"looks",
"up",
"the",
"account",
"using",
"the",
"addracctidx",
"index",
"which",
"maps",
"the",
"address",
"hash",
"to",
"its",
"correspondi... | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L1554-L1571 | train |
btcsuite/btcwallet | waddrmgr/db.go | forEachAccountAddress | func forEachAccountAddress(ns walletdb.ReadBucket, scope *KeyScope,
account uint32, fn func(rowInterface interface{}) error) error {
scopedBucket, err := fetchReadScopeBucket(ns, scope)
if err != nil {
return err
}
bucket := scopedBucket.NestedReadBucket(addrAcctIdxBucketName).
NestedReadBucket(uint32ToBytes... | go | func forEachAccountAddress(ns walletdb.ReadBucket, scope *KeyScope,
account uint32, fn func(rowInterface interface{}) error) error {
scopedBucket, err := fetchReadScopeBucket(ns, scope)
if err != nil {
return err
}
bucket := scopedBucket.NestedReadBucket(addrAcctIdxBucketName).
NestedReadBucket(uint32ToBytes... | [
"func",
"forEachAccountAddress",
"(",
"ns",
"walletdb",
".",
"ReadBucket",
",",
"scope",
"*",
"KeyScope",
",",
"account",
"uint32",
",",
"fn",
"func",
"(",
"rowInterface",
"interface",
"{",
"}",
")",
"error",
")",
"error",
"{",
"scopedBucket",
",",
"err",
... | // forEachAccountAddress calls the given function with each address of the
// given account stored in the manager, breaking early on error. | [
"forEachAccountAddress",
"calls",
"the",
"given",
"function",
"with",
"each",
"address",
"of",
"the",
"given",
"account",
"stored",
"in",
"the",
"manager",
"breaking",
"early",
"on",
"error",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L1575-L1615 | train |
btcsuite/btcwallet | waddrmgr/db.go | fetchSyncedTo | func fetchSyncedTo(ns walletdb.ReadBucket) (*BlockStamp, error) {
bucket := ns.NestedReadBucket(syncBucketName)
// The serialized synced to format is:
// <blockheight><blockhash><timestamp>
//
// 4 bytes block height + 32 bytes hash length
buf := bucket.Get(syncedToName)
if len(buf) < 36 {
str := "malformed... | go | func fetchSyncedTo(ns walletdb.ReadBucket) (*BlockStamp, error) {
bucket := ns.NestedReadBucket(syncBucketName)
// The serialized synced to format is:
// <blockheight><blockhash><timestamp>
//
// 4 bytes block height + 32 bytes hash length
buf := bucket.Get(syncedToName)
if len(buf) < 36 {
str := "malformed... | [
"func",
"fetchSyncedTo",
"(",
"ns",
"walletdb",
".",
"ReadBucket",
")",
"(",
"*",
"BlockStamp",
",",
"error",
")",
"{",
"bucket",
":=",
"ns",
".",
"NestedReadBucket",
"(",
"syncBucketName",
")",
"\n\n",
"// The serialized synced to format is:",
"// <blockheight><b... | // fetchSyncedTo loads the block stamp the manager is synced to from the
// database. | [
"fetchSyncedTo",
"loads",
"the",
"block",
"stamp",
"the",
"manager",
"is",
"synced",
"to",
"from",
"the",
"database",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L1807-L1831 | train |
btcsuite/btcwallet | waddrmgr/db.go | PutSyncedTo | func PutSyncedTo(ns walletdb.ReadWriteBucket, bs *BlockStamp) error {
bucket := ns.NestedReadWriteBucket(syncBucketName)
errStr := fmt.Sprintf("failed to store sync information %v", bs.Hash)
// If the block height is greater than zero, check that the previous
// block height exists. This prevents reorg issues in t... | go | func PutSyncedTo(ns walletdb.ReadWriteBucket, bs *BlockStamp) error {
bucket := ns.NestedReadWriteBucket(syncBucketName)
errStr := fmt.Sprintf("failed to store sync information %v", bs.Hash)
// If the block height is greater than zero, check that the previous
// block height exists. This prevents reorg issues in t... | [
"func",
"PutSyncedTo",
"(",
"ns",
"walletdb",
".",
"ReadWriteBucket",
",",
"bs",
"*",
"BlockStamp",
")",
"error",
"{",
"bucket",
":=",
"ns",
".",
"NestedReadWriteBucket",
"(",
"syncBucketName",
")",
"\n",
"errStr",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"... | // PutSyncedTo stores the provided synced to blockstamp to the database. | [
"PutSyncedTo",
"stores",
"the",
"provided",
"synced",
"to",
"blockstamp",
"to",
"the",
"database",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L1834-L1870 | train |
btcsuite/btcwallet | waddrmgr/db.go | fetchBlockHash | func fetchBlockHash(ns walletdb.ReadBucket, height int32) (*chainhash.Hash, error) {
bucket := ns.NestedReadBucket(syncBucketName)
errStr := fmt.Sprintf("failed to fetch block hash for height %d", height)
heightBytes := make([]byte, 4)
binary.BigEndian.PutUint32(heightBytes, uint32(height))
hashBytes := bucket.Ge... | go | func fetchBlockHash(ns walletdb.ReadBucket, height int32) (*chainhash.Hash, error) {
bucket := ns.NestedReadBucket(syncBucketName)
errStr := fmt.Sprintf("failed to fetch block hash for height %d", height)
heightBytes := make([]byte, 4)
binary.BigEndian.PutUint32(heightBytes, uint32(height))
hashBytes := bucket.Ge... | [
"func",
"fetchBlockHash",
"(",
"ns",
"walletdb",
".",
"ReadBucket",
",",
"height",
"int32",
")",
"(",
"*",
"chainhash",
".",
"Hash",
",",
"error",
")",
"{",
"bucket",
":=",
"ns",
".",
"NestedReadBucket",
"(",
"syncBucketName",
")",
"\n",
"errStr",
":=",
... | // fetchBlockHash loads the block hash for the provided height from the
// database. | [
"fetchBlockHash",
"loads",
"the",
"block",
"hash",
"for",
"the",
"provided",
"height",
"from",
"the",
"database",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L1874-L1894 | train |
btcsuite/btcwallet | waddrmgr/db.go | FetchStartBlock | func FetchStartBlock(ns walletdb.ReadBucket) (*BlockStamp, error) {
bucket := ns.NestedReadBucket(syncBucketName)
// The serialized start block format is:
// <blockheight><blockhash>
//
// 4 bytes block height + 32 bytes hash length
buf := bucket.Get(startBlockName)
if len(buf) != 36 {
str := "malformed sta... | go | func FetchStartBlock(ns walletdb.ReadBucket) (*BlockStamp, error) {
bucket := ns.NestedReadBucket(syncBucketName)
// The serialized start block format is:
// <blockheight><blockhash>
//
// 4 bytes block height + 32 bytes hash length
buf := bucket.Get(startBlockName)
if len(buf) != 36 {
str := "malformed sta... | [
"func",
"FetchStartBlock",
"(",
"ns",
"walletdb",
".",
"ReadBucket",
")",
"(",
"*",
"BlockStamp",
",",
"error",
")",
"{",
"bucket",
":=",
"ns",
".",
"NestedReadBucket",
"(",
"syncBucketName",
")",
"\n\n",
"// The serialized start block format is:",
"// <blockheigh... | // FetchStartBlock loads the start block stamp for the manager from the
// database. | [
"FetchStartBlock",
"loads",
"the",
"start",
"block",
"stamp",
"for",
"the",
"manager",
"from",
"the",
"database",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L1898-L1915 | train |
btcsuite/btcwallet | waddrmgr/db.go | putStartBlock | func putStartBlock(ns walletdb.ReadWriteBucket, bs *BlockStamp) error {
bucket := ns.NestedReadWriteBucket(syncBucketName)
// The serialized start block format is:
// <blockheight><blockhash>
//
// 4 bytes block height + 32 bytes hash length
buf := make([]byte, 36)
binary.LittleEndian.PutUint32(buf[0:4], uint... | go | func putStartBlock(ns walletdb.ReadWriteBucket, bs *BlockStamp) error {
bucket := ns.NestedReadWriteBucket(syncBucketName)
// The serialized start block format is:
// <blockheight><blockhash>
//
// 4 bytes block height + 32 bytes hash length
buf := make([]byte, 36)
binary.LittleEndian.PutUint32(buf[0:4], uint... | [
"func",
"putStartBlock",
"(",
"ns",
"walletdb",
".",
"ReadWriteBucket",
",",
"bs",
"*",
"BlockStamp",
")",
"error",
"{",
"bucket",
":=",
"ns",
".",
"NestedReadWriteBucket",
"(",
"syncBucketName",
")",
"\n\n",
"// The serialized start block format is:",
"// <blockhei... | // putStartBlock stores the provided start block stamp to the database. | [
"putStartBlock",
"stores",
"the",
"provided",
"start",
"block",
"stamp",
"to",
"the",
"database",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L1918-L1935 | train |
btcsuite/btcwallet | waddrmgr/db.go | fetchBirthday | func fetchBirthday(ns walletdb.ReadBucket) (time.Time, error) {
var t time.Time
bucket := ns.NestedReadBucket(syncBucketName)
birthdayTimestamp := bucket.Get(birthdayName)
if len(birthdayTimestamp) != 8 {
str := "malformed birthday stored in database"
return t, managerError(ErrDatabase, str, nil)
}
t = time... | go | func fetchBirthday(ns walletdb.ReadBucket) (time.Time, error) {
var t time.Time
bucket := ns.NestedReadBucket(syncBucketName)
birthdayTimestamp := bucket.Get(birthdayName)
if len(birthdayTimestamp) != 8 {
str := "malformed birthday stored in database"
return t, managerError(ErrDatabase, str, nil)
}
t = time... | [
"func",
"fetchBirthday",
"(",
"ns",
"walletdb",
".",
"ReadBucket",
")",
"(",
"time",
".",
"Time",
",",
"error",
")",
"{",
"var",
"t",
"time",
".",
"Time",
"\n\n",
"bucket",
":=",
"ns",
".",
"NestedReadBucket",
"(",
"syncBucketName",
")",
"\n",
"birthdayT... | // fetchBirthday loads the manager's bithday timestamp from the database. | [
"fetchBirthday",
"loads",
"the",
"manager",
"s",
"bithday",
"timestamp",
"from",
"the",
"database",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L1938-L1951 | train |
btcsuite/btcwallet | waddrmgr/db.go | putBirthday | func putBirthday(ns walletdb.ReadWriteBucket, t time.Time) error {
var birthdayTimestamp [8]byte
binary.BigEndian.PutUint64(birthdayTimestamp[:], uint64(t.Unix()))
bucket := ns.NestedReadWriteBucket(syncBucketName)
if err := bucket.Put(birthdayName, birthdayTimestamp[:]); err != nil {
str := "failed to store bir... | go | func putBirthday(ns walletdb.ReadWriteBucket, t time.Time) error {
var birthdayTimestamp [8]byte
binary.BigEndian.PutUint64(birthdayTimestamp[:], uint64(t.Unix()))
bucket := ns.NestedReadWriteBucket(syncBucketName)
if err := bucket.Put(birthdayName, birthdayTimestamp[:]); err != nil {
str := "failed to store bir... | [
"func",
"putBirthday",
"(",
"ns",
"walletdb",
".",
"ReadWriteBucket",
",",
"t",
"time",
".",
"Time",
")",
"error",
"{",
"var",
"birthdayTimestamp",
"[",
"8",
"]",
"byte",
"\n",
"binary",
".",
"BigEndian",
".",
"PutUint64",
"(",
"birthdayTimestamp",
"[",
":... | // putBirthday stores the provided birthday timestamp to the database. | [
"putBirthday",
"stores",
"the",
"provided",
"birthday",
"timestamp",
"to",
"the",
"database",
"."
] | 9d95f76e99a72ffaf73b8a6581d8781c52d756f5 | https://github.com/btcsuite/btcwallet/blob/9d95f76e99a72ffaf73b8a6581d8781c52d756f5/waddrmgr/db.go#L1954-L1965 | train |
Subsets and Splits
SQL Console for semeru/code-text-go
Retrieves a limited set of code samples with their languages, with a specific case adjustment for 'Go' language.