id
int32
0
167k
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
27,500
hashicorp/errwrap
errwrap.go
GetType
func GetType(err error, v interface{}) error { es := GetAllType(err, v) if len(es) > 0 { return es[len(es)-1] } return nil }
go
func GetType(err error, v interface{}) error { es := GetAllType(err, v) if len(es) > 0 { return es[len(es)-1] } return nil }
[ "func", "GetType", "(", "err", "error", ",", "v", "interface", "{", "}", ")", "error", "{", "es", ":=", "GetAllType", "(", "err", ",", "v", ")", "\n", "if", "len", "(", "es", ")", ">", "0", "{", "return", "es", "[", "len", "(", "es", ")", "-"...
// GetType is the same as GetAllType but returns the deepest matching error.
[ "GetType", "is", "the", "same", "as", "GetAllType", "but", "returns", "the", "deepest", "matching", "error", "." ]
8a6fb523712970c966eefc6b39ed2c5e74880354
https://github.com/hashicorp/errwrap/blob/8a6fb523712970c966eefc6b39ed2c5e74880354/errwrap.go#L84-L91
27,501
hashicorp/errwrap
errwrap.go
GetAllType
func GetAllType(err error, v interface{}) []error { var result []error var search string if v != nil { search = reflect.TypeOf(v).String() } Walk(err, func(err error) { var needle string if err != nil { needle = reflect.TypeOf(err).String() } if needle == search { result = append(result, err) }...
go
func GetAllType(err error, v interface{}) []error { var result []error var search string if v != nil { search = reflect.TypeOf(v).String() } Walk(err, func(err error) { var needle string if err != nil { needle = reflect.TypeOf(err).String() } if needle == search { result = append(result, err) }...
[ "func", "GetAllType", "(", "err", "error", ",", "v", "interface", "{", "}", ")", "[", "]", "error", "{", "var", "result", "[", "]", "error", "\n\n", "var", "search", "string", "\n", "if", "v", "!=", "nil", "{", "search", "=", "reflect", ".", "TypeO...
// GetAllType gets all the errors that are the same type as v. // // The order of the return value is the same as described in GetAll.
[ "GetAllType", "gets", "all", "the", "errors", "that", "are", "the", "same", "type", "as", "v", ".", "The", "order", "of", "the", "return", "value", "is", "the", "same", "as", "described", "in", "GetAll", "." ]
8a6fb523712970c966eefc6b39ed2c5e74880354
https://github.com/hashicorp/errwrap/blob/8a6fb523712970c966eefc6b39ed2c5e74880354/errwrap.go#L111-L130
27,502
hashicorp/errwrap
errwrap.go
Walk
func Walk(err error, cb WalkFunc) { if err == nil { return } switch e := err.(type) { case *wrappedError: cb(e.Outer) Walk(e.Inner, cb) case Wrapper: cb(err) for _, err := range e.WrappedErrors() { Walk(err, cb) } default: cb(err) } }
go
func Walk(err error, cb WalkFunc) { if err == nil { return } switch e := err.(type) { case *wrappedError: cb(e.Outer) Walk(e.Inner, cb) case Wrapper: cb(err) for _, err := range e.WrappedErrors() { Walk(err, cb) } default: cb(err) } }
[ "func", "Walk", "(", "err", "error", ",", "cb", "WalkFunc", ")", "{", "if", "err", "==", "nil", "{", "return", "\n", "}", "\n\n", "switch", "e", ":=", "err", ".", "(", "type", ")", "{", "case", "*", "wrappedError", ":", "cb", "(", "e", ".", "Ou...
// Walk walks all the wrapped errors in err and calls the callback. If // err isn't a wrapped error, this will be called once for err. If err // is a wrapped error, the callback will be called for both the wrapper // that implements error as well as the wrapped error itself.
[ "Walk", "walks", "all", "the", "wrapped", "errors", "in", "err", "and", "calls", "the", "callback", ".", "If", "err", "isn", "t", "a", "wrapped", "error", "this", "will", "be", "called", "once", "for", "err", ".", "If", "err", "is", "a", "wrapped", "...
8a6fb523712970c966eefc6b39ed2c5e74880354
https://github.com/hashicorp/errwrap/blob/8a6fb523712970c966eefc6b39ed2c5e74880354/errwrap.go#L136-L154
27,503
btcsuite/btcutil
gcs/gcs.go
NPBytes
func (f *Filter) NPBytes() ([]byte, error) { var buffer bytes.Buffer buffer.Grow(wire.VarIntSerializeSize(uint64(f.n)) + 1 + len(f.filterData)) err := wire.WriteVarInt(&buffer, varIntProtoVer, uint64(f.n)) if err != nil { return nil, err } err = buffer.WriteByte(f.p) if err != nil { return nil, err } _,...
go
func (f *Filter) NPBytes() ([]byte, error) { var buffer bytes.Buffer buffer.Grow(wire.VarIntSerializeSize(uint64(f.n)) + 1 + len(f.filterData)) err := wire.WriteVarInt(&buffer, varIntProtoVer, uint64(f.n)) if err != nil { return nil, err } err = buffer.WriteByte(f.p) if err != nil { return nil, err } _,...
[ "func", "(", "f", "*", "Filter", ")", "NPBytes", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "var", "buffer", "bytes", ".", "Buffer", "\n", "buffer", ".", "Grow", "(", "wire", ".", "VarIntSerializeSize", "(", "uint64", "(", "f", ".", ...
// NPBytes returns the serialized format of the GCS filter with N and P, which // does not include the key used by SipHash.
[ "NPBytes", "returns", "the", "serialized", "format", "of", "the", "GCS", "filter", "with", "N", "and", "P", "which", "does", "not", "include", "the", "key", "used", "by", "SipHash", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/gcs/gcs.go#L253-L273
27,504
btcsuite/btcutil
appdata.go
appDataDir
func appDataDir(goos, appName string, roaming bool) string { if appName == "" || appName == "." { return "." } // The caller really shouldn't prepend the appName with a period, but // if they do, handle it gracefully by trimming it. appName = strings.TrimPrefix(appName, ".") appNameUpper := string(unicode.ToUp...
go
func appDataDir(goos, appName string, roaming bool) string { if appName == "" || appName == "." { return "." } // The caller really shouldn't prepend the appName with a period, but // if they do, handle it gracefully by trimming it. appName = strings.TrimPrefix(appName, ".") appNameUpper := string(unicode.ToUp...
[ "func", "appDataDir", "(", "goos", ",", "appName", "string", ",", "roaming", "bool", ")", "string", "{", "if", "appName", "==", "\"", "\"", "||", "appName", "==", "\"", "\"", "{", "return", "\"", "\"", "\n", "}", "\n\n", "// The caller really shouldn't pre...
// appDataDir returns an operating system specific directory to be used for // storing application data for an application. See AppDataDir for more // details. This unexported version takes an operating system argument // primarily to enable the testing package to properly test the function by // forcing an operating...
[ "appDataDir", "returns", "an", "operating", "system", "specific", "directory", "to", "be", "used", "for", "storing", "application", "data", "for", "an", "application", ".", "See", "AppDataDir", "for", "more", "details", ".", "This", "unexported", "version", "tak...
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/appdata.go#L21-L80
27,505
btcsuite/btcutil
hdkeychain/extendedkey.go
NewExtendedKey
func NewExtendedKey(version, key, chainCode, parentFP []byte, depth uint8, childNum uint32, isPrivate bool) *ExtendedKey { // NOTE: The pubKey field is intentionally left nil so it is only // computed and memoized as required. return &ExtendedKey{ key: key, chainCode: chainCode, depth: depth, par...
go
func NewExtendedKey(version, key, chainCode, parentFP []byte, depth uint8, childNum uint32, isPrivate bool) *ExtendedKey { // NOTE: The pubKey field is intentionally left nil so it is only // computed and memoized as required. return &ExtendedKey{ key: key, chainCode: chainCode, depth: depth, par...
[ "func", "NewExtendedKey", "(", "version", ",", "key", ",", "chainCode", ",", "parentFP", "[", "]", "byte", ",", "depth", "uint8", ",", "childNum", "uint32", ",", "isPrivate", "bool", ")", "*", "ExtendedKey", "{", "// NOTE: The pubKey field is intentionally left ni...
// NewExtendedKey returns a new instance of an extended key with the given // fields. No error checking is performed here as it's only intended to be a // convenience method used to create a populated struct. This function should // only by used by applications that need to create custom ExtendedKeys. All // other app...
[ "NewExtendedKey", "returns", "a", "new", "instance", "of", "an", "extended", "key", "with", "the", "given", "fields", ".", "No", "error", "checking", "is", "performed", "here", "as", "it", "s", "only", "intended", "to", "be", "a", "convenience", "method", ...
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/hdkeychain/extendedkey.go#L124-L138
27,506
btcsuite/btcutil
hdkeychain/extendedkey.go
Neuter
func (k *ExtendedKey) Neuter() (*ExtendedKey, error) { // Already an extended public key. if !k.isPrivate { return k, nil } // Get the associated public extended key version bytes. version, err := chaincfg.HDPrivateKeyToPublicKeyID(k.version) if err != nil { return nil, err } // Convert it to an extended ...
go
func (k *ExtendedKey) Neuter() (*ExtendedKey, error) { // Already an extended public key. if !k.isPrivate { return k, nil } // Get the associated public extended key version bytes. version, err := chaincfg.HDPrivateKeyToPublicKeyID(k.version) if err != nil { return nil, err } // Convert it to an extended ...
[ "func", "(", "k", "*", "ExtendedKey", ")", "Neuter", "(", ")", "(", "*", "ExtendedKey", ",", "error", ")", "{", "// Already an extended public key.", "if", "!", "k", ".", "isPrivate", "{", "return", "k", ",", "nil", "\n", "}", "\n\n", "// Get the associate...
// Neuter returns a new extended public key from this extended private key. The // same extended key will be returned unaltered if it is already an extended // public key. // // As the name implies, an extended public key does not have access to the // private key, so it is not capable of signing transactions or deriv...
[ "Neuter", "returns", "a", "new", "extended", "public", "key", "from", "this", "extended", "private", "key", ".", "The", "same", "extended", "key", "will", "be", "returned", "unaltered", "if", "it", "is", "already", "an", "extended", "public", "key", ".", "...
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/hdkeychain/extendedkey.go#L340-L358
27,507
btcsuite/btcutil
hdkeychain/extendedkey.go
ECPubKey
func (k *ExtendedKey) ECPubKey() (*btcec.PublicKey, error) { return btcec.ParsePubKey(k.pubKeyBytes(), btcec.S256()) }
go
func (k *ExtendedKey) ECPubKey() (*btcec.PublicKey, error) { return btcec.ParsePubKey(k.pubKeyBytes(), btcec.S256()) }
[ "func", "(", "k", "*", "ExtendedKey", ")", "ECPubKey", "(", ")", "(", "*", "btcec", ".", "PublicKey", ",", "error", ")", "{", "return", "btcec", ".", "ParsePubKey", "(", "k", ".", "pubKeyBytes", "(", ")", ",", "btcec", ".", "S256", "(", ")", ")", ...
// ECPubKey converts the extended key to a btcec public key and returns it.
[ "ECPubKey", "converts", "the", "extended", "key", "to", "a", "btcec", "public", "key", "and", "returns", "it", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/hdkeychain/extendedkey.go#L361-L363
27,508
btcsuite/btcutil
hdkeychain/extendedkey.go
String
func (k *ExtendedKey) String() string { if len(k.key) == 0 { return "zeroed extended key" } var childNumBytes [4]byte binary.BigEndian.PutUint32(childNumBytes[:], k.childNum) // The serialized format is: // version (4) || depth (1) || parent fingerprint (4)) || // child num (4) || chain code (32) || key ...
go
func (k *ExtendedKey) String() string { if len(k.key) == 0 { return "zeroed extended key" } var childNumBytes [4]byte binary.BigEndian.PutUint32(childNumBytes[:], k.childNum) // The serialized format is: // version (4) || depth (1) || parent fingerprint (4)) || // child num (4) || chain code (32) || key ...
[ "func", "(", "k", "*", "ExtendedKey", ")", "String", "(", ")", "string", "{", "if", "len", "(", "k", ".", "key", ")", "==", "0", "{", "return", "\"", "\"", "\n", "}", "\n\n", "var", "childNumBytes", "[", "4", "]", "byte", "\n", "binary", ".", "...
// String returns the extended key as a human-readable base58-encoded string.
[ "String", "returns", "the", "extended", "key", "as", "a", "human", "-", "readable", "base58", "-", "encoded", "string", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/hdkeychain/extendedkey.go#L396-L423
27,509
btcsuite/btcutil
hdkeychain/extendedkey.go
IsForNet
func (k *ExtendedKey) IsForNet(net *chaincfg.Params) bool { return bytes.Equal(k.version, net.HDPrivateKeyID[:]) || bytes.Equal(k.version, net.HDPublicKeyID[:]) }
go
func (k *ExtendedKey) IsForNet(net *chaincfg.Params) bool { return bytes.Equal(k.version, net.HDPrivateKeyID[:]) || bytes.Equal(k.version, net.HDPublicKeyID[:]) }
[ "func", "(", "k", "*", "ExtendedKey", ")", "IsForNet", "(", "net", "*", "chaincfg", ".", "Params", ")", "bool", "{", "return", "bytes", ".", "Equal", "(", "k", ".", "version", ",", "net", ".", "HDPrivateKeyID", "[", ":", "]", ")", "||", "bytes", "....
// IsForNet returns whether or not the extended key is associated with the // passed bitcoin network.
[ "IsForNet", "returns", "whether", "or", "not", "the", "extended", "key", "is", "associated", "with", "the", "passed", "bitcoin", "network", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/hdkeychain/extendedkey.go#L427-L430
27,510
btcsuite/btcutil
hdkeychain/extendedkey.go
SetNet
func (k *ExtendedKey) SetNet(net *chaincfg.Params) { if k.isPrivate { k.version = net.HDPrivateKeyID[:] } else { k.version = net.HDPublicKeyID[:] } }
go
func (k *ExtendedKey) SetNet(net *chaincfg.Params) { if k.isPrivate { k.version = net.HDPrivateKeyID[:] } else { k.version = net.HDPublicKeyID[:] } }
[ "func", "(", "k", "*", "ExtendedKey", ")", "SetNet", "(", "net", "*", "chaincfg", ".", "Params", ")", "{", "if", "k", ".", "isPrivate", "{", "k", ".", "version", "=", "net", ".", "HDPrivateKeyID", "[", ":", "]", "\n", "}", "else", "{", "k", ".", ...
// SetNet associates the extended key, and any child keys yet to be derived from // it, with the passed network.
[ "SetNet", "associates", "the", "extended", "key", "and", "any", "child", "keys", "yet", "to", "be", "derived", "from", "it", "with", "the", "passed", "network", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/hdkeychain/extendedkey.go#L434-L440
27,511
btcsuite/btcutil
hdkeychain/extendedkey.go
zero
func zero(b []byte) { lenb := len(b) for i := 0; i < lenb; i++ { b[i] = 0 } }
go
func zero(b []byte) { lenb := len(b) for i := 0; i < lenb; i++ { b[i] = 0 } }
[ "func", "zero", "(", "b", "[", "]", "byte", ")", "{", "lenb", ":=", "len", "(", "b", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "lenb", ";", "i", "++", "{", "b", "[", "i", "]", "=", "0", "\n", "}", "\n", "}" ]
// zero sets all bytes in the passed slice to zero. This is used to // explicitly clear private key material from memory.
[ "zero", "sets", "all", "bytes", "in", "the", "passed", "slice", "to", "zero", ".", "This", "is", "used", "to", "explicitly", "clear", "private", "key", "material", "from", "memory", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/hdkeychain/extendedkey.go#L444-L449
27,512
btcsuite/btcutil
hdkeychain/extendedkey.go
Zero
func (k *ExtendedKey) Zero() { zero(k.key) zero(k.pubKey) zero(k.chainCode) zero(k.parentFP) k.version = nil k.key = nil k.depth = 0 k.childNum = 0 k.isPrivate = false }
go
func (k *ExtendedKey) Zero() { zero(k.key) zero(k.pubKey) zero(k.chainCode) zero(k.parentFP) k.version = nil k.key = nil k.depth = 0 k.childNum = 0 k.isPrivate = false }
[ "func", "(", "k", "*", "ExtendedKey", ")", "Zero", "(", ")", "{", "zero", "(", "k", ".", "key", ")", "\n", "zero", "(", "k", ".", "pubKey", ")", "\n", "zero", "(", "k", ".", "chainCode", ")", "\n", "zero", "(", "k", ".", "parentFP", ")", "\n"...
// Zero manually clears all fields and bytes in the extended key. This can be // used to explicitly clear key material from memory for enhanced security // against memory scraping. This function only clears this particular key and // not any children that have already been derived.
[ "Zero", "manually", "clears", "all", "fields", "and", "bytes", "in", "the", "extended", "key", ".", "This", "can", "be", "used", "to", "explicitly", "clear", "key", "material", "from", "memory", "for", "enhanced", "security", "against", "memory", "scraping", ...
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/hdkeychain/extendedkey.go#L455-L465
27,513
btcsuite/btcutil
hdkeychain/extendedkey.go
NewKeyFromString
func NewKeyFromString(key string) (*ExtendedKey, error) { // The base58-decoded extended key must consist of a serialized payload // plus an additional 4 bytes for the checksum. decoded := base58.Decode(key) if len(decoded) != serializedKeyLen+4 { return nil, ErrInvalidKeyLen } // The serialized format is: //...
go
func NewKeyFromString(key string) (*ExtendedKey, error) { // The base58-decoded extended key must consist of a serialized payload // plus an additional 4 bytes for the checksum. decoded := base58.Decode(key) if len(decoded) != serializedKeyLen+4 { return nil, ErrInvalidKeyLen } // The serialized format is: //...
[ "func", "NewKeyFromString", "(", "key", "string", ")", "(", "*", "ExtendedKey", ",", "error", ")", "{", "// The base58-decoded extended key must consist of a serialized payload", "// plus an additional 4 bytes for the checksum.", "decoded", ":=", "base58", ".", "Decode", "(",...
// NewKeyFromString returns a new extended key instance from a base58-encoded // extended key.
[ "NewKeyFromString", "returns", "a", "new", "extended", "key", "instance", "from", "a", "base58", "-", "encoded", "extended", "key", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/hdkeychain/extendedkey.go#L506-L556
27,514
btcsuite/btcutil
bloom/filter.go
IsLoaded
func (bf *Filter) IsLoaded() bool { bf.mtx.Lock() loaded := bf.msgFilterLoad != nil bf.mtx.Unlock() return loaded }
go
func (bf *Filter) IsLoaded() bool { bf.mtx.Lock() loaded := bf.msgFilterLoad != nil bf.mtx.Unlock() return loaded }
[ "func", "(", "bf", "*", "Filter", ")", "IsLoaded", "(", ")", "bool", "{", "bf", ".", "mtx", ".", "Lock", "(", ")", "\n", "loaded", ":=", "bf", ".", "msgFilterLoad", "!=", "nil", "\n", "bf", ".", "mtx", ".", "Unlock", "(", ")", "\n", "return", "...
// IsLoaded returns true if a filter is loaded, otherwise false. // // This function is safe for concurrent access.
[ "IsLoaded", "returns", "true", "if", "a", "filter", "is", "loaded", "otherwise", "false", ".", "This", "function", "is", "safe", "for", "concurrent", "access", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/bloom/filter.go#L90-L95
27,515
btcsuite/btcutil
bloom/filter.go
Reload
func (bf *Filter) Reload(filter *wire.MsgFilterLoad) { bf.mtx.Lock() bf.msgFilterLoad = filter bf.mtx.Unlock() }
go
func (bf *Filter) Reload(filter *wire.MsgFilterLoad) { bf.mtx.Lock() bf.msgFilterLoad = filter bf.mtx.Unlock() }
[ "func", "(", "bf", "*", "Filter", ")", "Reload", "(", "filter", "*", "wire", ".", "MsgFilterLoad", ")", "{", "bf", ".", "mtx", ".", "Lock", "(", ")", "\n", "bf", ".", "msgFilterLoad", "=", "filter", "\n", "bf", ".", "mtx", ".", "Unlock", "(", ")"...
// Reload loads a new filter replacing any existing filter. // // This function is safe for concurrent access.
[ "Reload", "loads", "a", "new", "filter", "replacing", "any", "existing", "filter", ".", "This", "function", "is", "safe", "for", "concurrent", "access", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/bloom/filter.go#L100-L104
27,516
btcsuite/btcutil
bloom/filter.go
Unload
func (bf *Filter) Unload() { bf.mtx.Lock() bf.msgFilterLoad = nil bf.mtx.Unlock() }
go
func (bf *Filter) Unload() { bf.mtx.Lock() bf.msgFilterLoad = nil bf.mtx.Unlock() }
[ "func", "(", "bf", "*", "Filter", ")", "Unload", "(", ")", "{", "bf", ".", "mtx", ".", "Lock", "(", ")", "\n", "bf", ".", "msgFilterLoad", "=", "nil", "\n", "bf", ".", "mtx", ".", "Unlock", "(", ")", "\n", "}" ]
// Unload unloads the bloom filter. // // This function is safe for concurrent access.
[ "Unload", "unloads", "the", "bloom", "filter", ".", "This", "function", "is", "safe", "for", "concurrent", "access", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/bloom/filter.go#L109-L113
27,517
btcsuite/btcutil
bloom/filter.go
hash
func (bf *Filter) hash(hashNum uint32, data []byte) uint32 { // bitcoind: 0xfba4c795 chosen as it guarantees a reasonable bit // difference between hashNum values. // // Note that << 3 is equivalent to multiplying by 8, but is faster. // Thus the returned hash is brought into range of the number of bits // the fi...
go
func (bf *Filter) hash(hashNum uint32, data []byte) uint32 { // bitcoind: 0xfba4c795 chosen as it guarantees a reasonable bit // difference between hashNum values. // // Note that << 3 is equivalent to multiplying by 8, but is faster. // Thus the returned hash is brought into range of the number of bits // the fi...
[ "func", "(", "bf", "*", "Filter", ")", "hash", "(", "hashNum", "uint32", ",", "data", "[", "]", "byte", ")", "uint32", "{", "// bitcoind: 0xfba4c795 chosen as it guarantees a reasonable bit", "// difference between hashNum values.", "//", "// Note that << 3 is equivalent to...
// hash returns the bit offset in the bloom filter which corresponds to the // passed data for the given indepedent hash function number.
[ "hash", "returns", "the", "bit", "offset", "in", "the", "bloom", "filter", "which", "corresponds", "to", "the", "passed", "data", "for", "the", "given", "indepedent", "hash", "function", "number", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/bloom/filter.go#L117-L126
27,518
btcsuite/btcutil
bloom/filter.go
matches
func (bf *Filter) matches(data []byte) bool { if bf.msgFilterLoad == nil { return false } // The bloom filter does not contain the data if any of the bit offsets // which result from hashing the data using each independent hash // function are not set. The shifts and masks below are a faster // equivalent of:...
go
func (bf *Filter) matches(data []byte) bool { if bf.msgFilterLoad == nil { return false } // The bloom filter does not contain the data if any of the bit offsets // which result from hashing the data using each independent hash // function are not set. The shifts and masks below are a faster // equivalent of:...
[ "func", "(", "bf", "*", "Filter", ")", "matches", "(", "data", "[", "]", "byte", ")", "bool", "{", "if", "bf", ".", "msgFilterLoad", "==", "nil", "{", "return", "false", "\n", "}", "\n\n", "// The bloom filter does not contain the data if any of the bit offsets"...
// matches returns true if the bloom filter might contain the passed data and // false if it definitely does not. // // This function MUST be called with the filter lock held.
[ "matches", "returns", "true", "if", "the", "bloom", "filter", "might", "contain", "the", "passed", "data", "and", "false", "if", "it", "definitely", "does", "not", ".", "This", "function", "MUST", "be", "called", "with", "the", "filter", "lock", "held", "....
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/bloom/filter.go#L132-L151
27,519
btcsuite/btcutil
bloom/filter.go
Matches
func (bf *Filter) Matches(data []byte) bool { bf.mtx.Lock() match := bf.matches(data) bf.mtx.Unlock() return match }
go
func (bf *Filter) Matches(data []byte) bool { bf.mtx.Lock() match := bf.matches(data) bf.mtx.Unlock() return match }
[ "func", "(", "bf", "*", "Filter", ")", "Matches", "(", "data", "[", "]", "byte", ")", "bool", "{", "bf", ".", "mtx", ".", "Lock", "(", ")", "\n", "match", ":=", "bf", ".", "matches", "(", "data", ")", "\n", "bf", ".", "mtx", ".", "Unlock", "(...
// Matches returns true if the bloom filter might contain the passed data and // false if it definitely does not. // // This function is safe for concurrent access.
[ "Matches", "returns", "true", "if", "the", "bloom", "filter", "might", "contain", "the", "passed", "data", "and", "false", "if", "it", "definitely", "does", "not", ".", "This", "function", "is", "safe", "for", "concurrent", "access", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/bloom/filter.go#L157-L162
27,520
btcsuite/btcutil
bloom/filter.go
matchesOutPoint
func (bf *Filter) matchesOutPoint(outpoint *wire.OutPoint) bool { // Serialize var buf [chainhash.HashSize + 4]byte copy(buf[:], outpoint.Hash[:]) binary.LittleEndian.PutUint32(buf[chainhash.HashSize:], outpoint.Index) return bf.matches(buf[:]) }
go
func (bf *Filter) matchesOutPoint(outpoint *wire.OutPoint) bool { // Serialize var buf [chainhash.HashSize + 4]byte copy(buf[:], outpoint.Hash[:]) binary.LittleEndian.PutUint32(buf[chainhash.HashSize:], outpoint.Index) return bf.matches(buf[:]) }
[ "func", "(", "bf", "*", "Filter", ")", "matchesOutPoint", "(", "outpoint", "*", "wire", ".", "OutPoint", ")", "bool", "{", "// Serialize", "var", "buf", "[", "chainhash", ".", "HashSize", "+", "4", "]", "byte", "\n", "copy", "(", "buf", "[", ":", "]"...
// matchesOutPoint returns true if the bloom filter might contain the passed // outpoint and false if it definitely does not. // // This function MUST be called with the filter lock held.
[ "matchesOutPoint", "returns", "true", "if", "the", "bloom", "filter", "might", "contain", "the", "passed", "outpoint", "and", "false", "if", "it", "definitely", "does", "not", ".", "This", "function", "MUST", "be", "called", "with", "the", "filter", "lock", ...
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/bloom/filter.go#L168-L175
27,521
btcsuite/btcutil
bloom/filter.go
MatchesOutPoint
func (bf *Filter) MatchesOutPoint(outpoint *wire.OutPoint) bool { bf.mtx.Lock() match := bf.matchesOutPoint(outpoint) bf.mtx.Unlock() return match }
go
func (bf *Filter) MatchesOutPoint(outpoint *wire.OutPoint) bool { bf.mtx.Lock() match := bf.matchesOutPoint(outpoint) bf.mtx.Unlock() return match }
[ "func", "(", "bf", "*", "Filter", ")", "MatchesOutPoint", "(", "outpoint", "*", "wire", ".", "OutPoint", ")", "bool", "{", "bf", ".", "mtx", ".", "Lock", "(", ")", "\n", "match", ":=", "bf", ".", "matchesOutPoint", "(", "outpoint", ")", "\n", "bf", ...
// MatchesOutPoint returns true if the bloom filter might contain the passed // outpoint and false if it definitely does not. // // This function is safe for concurrent access.
[ "MatchesOutPoint", "returns", "true", "if", "the", "bloom", "filter", "might", "contain", "the", "passed", "outpoint", "and", "false", "if", "it", "definitely", "does", "not", ".", "This", "function", "is", "safe", "for", "concurrent", "access", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/bloom/filter.go#L181-L186
27,522
btcsuite/btcutil
bloom/filter.go
add
func (bf *Filter) add(data []byte) { if bf.msgFilterLoad == nil { return } // Adding data to a bloom filter consists of setting all of the bit // offsets which result from hashing the data using each independent // hash function. The shifts and masks below are a faster equivalent // of: // arrayIndex := id...
go
func (bf *Filter) add(data []byte) { if bf.msgFilterLoad == nil { return } // Adding data to a bloom filter consists of setting all of the bit // offsets which result from hashing the data using each independent // hash function. The shifts and masks below are a faster equivalent // of: // arrayIndex := id...
[ "func", "(", "bf", "*", "Filter", ")", "add", "(", "data", "[", "]", "byte", ")", "{", "if", "bf", ".", "msgFilterLoad", "==", "nil", "{", "return", "\n", "}", "\n\n", "// Adding data to a bloom filter consists of setting all of the bit", "// offsets which result ...
// add adds the passed byte slice to the bloom filter. // // This function MUST be called with the filter lock held.
[ "add", "adds", "the", "passed", "byte", "slice", "to", "the", "bloom", "filter", ".", "This", "function", "MUST", "be", "called", "with", "the", "filter", "lock", "held", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/bloom/filter.go#L191-L207
27,523
btcsuite/btcutil
bloom/filter.go
Add
func (bf *Filter) Add(data []byte) { bf.mtx.Lock() bf.add(data) bf.mtx.Unlock() }
go
func (bf *Filter) Add(data []byte) { bf.mtx.Lock() bf.add(data) bf.mtx.Unlock() }
[ "func", "(", "bf", "*", "Filter", ")", "Add", "(", "data", "[", "]", "byte", ")", "{", "bf", ".", "mtx", ".", "Lock", "(", ")", "\n", "bf", ".", "add", "(", "data", ")", "\n", "bf", ".", "mtx", ".", "Unlock", "(", ")", "\n", "}" ]
// Add adds the passed byte slice to the bloom filter. // // This function is safe for concurrent access.
[ "Add", "adds", "the", "passed", "byte", "slice", "to", "the", "bloom", "filter", ".", "This", "function", "is", "safe", "for", "concurrent", "access", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/bloom/filter.go#L212-L216
27,524
btcsuite/btcutil
bloom/filter.go
AddHash
func (bf *Filter) AddHash(hash *chainhash.Hash) { bf.mtx.Lock() bf.add(hash[:]) bf.mtx.Unlock() }
go
func (bf *Filter) AddHash(hash *chainhash.Hash) { bf.mtx.Lock() bf.add(hash[:]) bf.mtx.Unlock() }
[ "func", "(", "bf", "*", "Filter", ")", "AddHash", "(", "hash", "*", "chainhash", ".", "Hash", ")", "{", "bf", ".", "mtx", ".", "Lock", "(", ")", "\n", "bf", ".", "add", "(", "hash", "[", ":", "]", ")", "\n", "bf", ".", "mtx", ".", "Unlock", ...
// AddHash adds the passed chainhash.Hash to the Filter. // // This function is safe for concurrent access.
[ "AddHash", "adds", "the", "passed", "chainhash", ".", "Hash", "to", "the", "Filter", ".", "This", "function", "is", "safe", "for", "concurrent", "access", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/bloom/filter.go#L221-L225
27,525
btcsuite/btcutil
bloom/filter.go
addOutPoint
func (bf *Filter) addOutPoint(outpoint *wire.OutPoint) { // Serialize var buf [chainhash.HashSize + 4]byte copy(buf[:], outpoint.Hash[:]) binary.LittleEndian.PutUint32(buf[chainhash.HashSize:], outpoint.Index) bf.add(buf[:]) }
go
func (bf *Filter) addOutPoint(outpoint *wire.OutPoint) { // Serialize var buf [chainhash.HashSize + 4]byte copy(buf[:], outpoint.Hash[:]) binary.LittleEndian.PutUint32(buf[chainhash.HashSize:], outpoint.Index) bf.add(buf[:]) }
[ "func", "(", "bf", "*", "Filter", ")", "addOutPoint", "(", "outpoint", "*", "wire", ".", "OutPoint", ")", "{", "// Serialize", "var", "buf", "[", "chainhash", ".", "HashSize", "+", "4", "]", "byte", "\n", "copy", "(", "buf", "[", ":", "]", ",", "ou...
// addOutPoint adds the passed transaction outpoint to the bloom filter. // // This function MUST be called with the filter lock held.
[ "addOutPoint", "adds", "the", "passed", "transaction", "outpoint", "to", "the", "bloom", "filter", ".", "This", "function", "MUST", "be", "called", "with", "the", "filter", "lock", "held", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/bloom/filter.go#L230-L237
27,526
btcsuite/btcutil
bloom/filter.go
AddOutPoint
func (bf *Filter) AddOutPoint(outpoint *wire.OutPoint) { bf.mtx.Lock() bf.addOutPoint(outpoint) bf.mtx.Unlock() }
go
func (bf *Filter) AddOutPoint(outpoint *wire.OutPoint) { bf.mtx.Lock() bf.addOutPoint(outpoint) bf.mtx.Unlock() }
[ "func", "(", "bf", "*", "Filter", ")", "AddOutPoint", "(", "outpoint", "*", "wire", ".", "OutPoint", ")", "{", "bf", ".", "mtx", ".", "Lock", "(", ")", "\n", "bf", ".", "addOutPoint", "(", "outpoint", ")", "\n", "bf", ".", "mtx", ".", "Unlock", "...
// AddOutPoint adds the passed transaction outpoint to the bloom filter. // // This function is safe for concurrent access.
[ "AddOutPoint", "adds", "the", "passed", "transaction", "outpoint", "to", "the", "bloom", "filter", ".", "This", "function", "is", "safe", "for", "concurrent", "access", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/bloom/filter.go#L242-L246
27,527
btcsuite/btcutil
bloom/filter.go
maybeAddOutpoint
func (bf *Filter) maybeAddOutpoint(pkScript []byte, outHash *chainhash.Hash, outIdx uint32) { switch bf.msgFilterLoad.Flags { case wire.BloomUpdateAll: outpoint := wire.NewOutPoint(outHash, outIdx) bf.addOutPoint(outpoint) case wire.BloomUpdateP2PubkeyOnly: class := txscript.GetScriptClass(pkScript) if class...
go
func (bf *Filter) maybeAddOutpoint(pkScript []byte, outHash *chainhash.Hash, outIdx uint32) { switch bf.msgFilterLoad.Flags { case wire.BloomUpdateAll: outpoint := wire.NewOutPoint(outHash, outIdx) bf.addOutPoint(outpoint) case wire.BloomUpdateP2PubkeyOnly: class := txscript.GetScriptClass(pkScript) if class...
[ "func", "(", "bf", "*", "Filter", ")", "maybeAddOutpoint", "(", "pkScript", "[", "]", "byte", ",", "outHash", "*", "chainhash", ".", "Hash", ",", "outIdx", "uint32", ")", "{", "switch", "bf", ".", "msgFilterLoad", ".", "Flags", "{", "case", "wire", "."...
// maybeAddOutpoint potentially adds the passed outpoint to the bloom filter // depending on the bloom update flags and the type of the passed public key // script. // // This function MUST be called with the filter lock held.
[ "maybeAddOutpoint", "potentially", "adds", "the", "passed", "outpoint", "to", "the", "bloom", "filter", "depending", "on", "the", "bloom", "update", "flags", "and", "the", "type", "of", "the", "passed", "public", "key", "script", ".", "This", "function", "MUST...
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/bloom/filter.go#L253-L265
27,528
btcsuite/btcutil
bloom/filter.go
matchTxAndUpdate
func (bf *Filter) matchTxAndUpdate(tx *btcutil.Tx) bool { // Check if the filter matches the hash of the transaction. // This is useful for finding transactions when they appear in a block. matched := bf.matches(tx.Hash()[:]) // Check if the filter matches any data elements in the public key // scripts of any of ...
go
func (bf *Filter) matchTxAndUpdate(tx *btcutil.Tx) bool { // Check if the filter matches the hash of the transaction. // This is useful for finding transactions when they appear in a block. matched := bf.matches(tx.Hash()[:]) // Check if the filter matches any data elements in the public key // scripts of any of ...
[ "func", "(", "bf", "*", "Filter", ")", "matchTxAndUpdate", "(", "tx", "*", "btcutil", ".", "Tx", ")", "bool", "{", "// Check if the filter matches the hash of the transaction.", "// This is useful for finding transactions when they appear in a block.", "matched", ":=", "bf", ...
// matchTxAndUpdate returns true if the bloom filter matches data within the // passed transaction, otherwise false is returned. If the filter does match // the passed transaction, it will also update the filter depending on the bloom // update flags set via the loaded filter if needed. // // This function MUST be cal...
[ "matchTxAndUpdate", "returns", "true", "if", "the", "bloom", "filter", "matches", "data", "within", "the", "passed", "transaction", "otherwise", "false", "is", "returned", ".", "If", "the", "filter", "does", "match", "the", "passed", "transaction", "it", "will",...
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/bloom/filter.go#L273-L330
27,529
btcsuite/btcutil
bloom/filter.go
MatchTxAndUpdate
func (bf *Filter) MatchTxAndUpdate(tx *btcutil.Tx) bool { bf.mtx.Lock() match := bf.matchTxAndUpdate(tx) bf.mtx.Unlock() return match }
go
func (bf *Filter) MatchTxAndUpdate(tx *btcutil.Tx) bool { bf.mtx.Lock() match := bf.matchTxAndUpdate(tx) bf.mtx.Unlock() return match }
[ "func", "(", "bf", "*", "Filter", ")", "MatchTxAndUpdate", "(", "tx", "*", "btcutil", ".", "Tx", ")", "bool", "{", "bf", ".", "mtx", ".", "Lock", "(", ")", "\n", "match", ":=", "bf", ".", "matchTxAndUpdate", "(", "tx", ")", "\n", "bf", ".", "mtx"...
// MatchTxAndUpdate returns true if the bloom filter matches data within the // passed transaction, otherwise false is returned. If the filter does match // the passed transaction, it will also update the filter depending on the bloom // update flags set via the loaded filter if needed. // // This function is safe for...
[ "MatchTxAndUpdate", "returns", "true", "if", "the", "bloom", "filter", "matches", "data", "within", "the", "passed", "transaction", "otherwise", "false", "is", "returned", ".", "If", "the", "filter", "does", "match", "the", "passed", "transaction", "it", "will",...
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/bloom/filter.go#L338-L343
27,530
btcsuite/btcutil
bloom/filter.go
MsgFilterLoad
func (bf *Filter) MsgFilterLoad() *wire.MsgFilterLoad { bf.mtx.Lock() msg := bf.msgFilterLoad bf.mtx.Unlock() return msg }
go
func (bf *Filter) MsgFilterLoad() *wire.MsgFilterLoad { bf.mtx.Lock() msg := bf.msgFilterLoad bf.mtx.Unlock() return msg }
[ "func", "(", "bf", "*", "Filter", ")", "MsgFilterLoad", "(", ")", "*", "wire", ".", "MsgFilterLoad", "{", "bf", ".", "mtx", ".", "Lock", "(", ")", "\n", "msg", ":=", "bf", ".", "msgFilterLoad", "\n", "bf", ".", "mtx", ".", "Unlock", "(", ")", "\n...
// MsgFilterLoad returns the underlying wire.MsgFilterLoad for the bloom // filter. // // This function is safe for concurrent access.
[ "MsgFilterLoad", "returns", "the", "underlying", "wire", ".", "MsgFilterLoad", "for", "the", "bloom", "filter", ".", "This", "function", "is", "safe", "for", "concurrent", "access", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/bloom/filter.go#L349-L354
27,531
btcsuite/btcutil
amount.go
String
func (u AmountUnit) String() string { switch u { case AmountMegaBTC: return "MBTC" case AmountKiloBTC: return "kBTC" case AmountBTC: return "BTC" case AmountMilliBTC: return "mBTC" case AmountMicroBTC: return "μBTC" case AmountSatoshi: return "Satoshi" default: return "1e" + strconv.FormatInt(int6...
go
func (u AmountUnit) String() string { switch u { case AmountMegaBTC: return "MBTC" case AmountKiloBTC: return "kBTC" case AmountBTC: return "BTC" case AmountMilliBTC: return "mBTC" case AmountMicroBTC: return "μBTC" case AmountSatoshi: return "Satoshi" default: return "1e" + strconv.FormatInt(int6...
[ "func", "(", "u", "AmountUnit", ")", "String", "(", ")", "string", "{", "switch", "u", "{", "case", "AmountMegaBTC", ":", "return", "\"", "\"", "\n", "case", "AmountKiloBTC", ":", "return", "\"", "\"", "\n", "case", "AmountBTC", ":", "return", "\"", "\...
// String returns the unit as a string. For recognized units, the SI // prefix is used, or "Satoshi" for the base unit. For all unrecognized // units, "1eN BTC" is returned, where N is the AmountUnit.
[ "String", "returns", "the", "unit", "as", "a", "string", ".", "For", "recognized", "units", "the", "SI", "prefix", "is", "used", "or", "Satoshi", "for", "the", "base", "unit", ".", "For", "all", "unrecognized", "units", "1eN", "BTC", "is", "returned", "w...
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/amount.go#L33-L50
27,532
btcsuite/btcutil
amount.go
ToUnit
func (a Amount) ToUnit(u AmountUnit) float64 { return float64(a) / math.Pow10(int(u+8)) }
go
func (a Amount) ToUnit(u AmountUnit) float64 { return float64(a) / math.Pow10(int(u+8)) }
[ "func", "(", "a", "Amount", ")", "ToUnit", "(", "u", "AmountUnit", ")", "float64", "{", "return", "float64", "(", "a", ")", "/", "math", ".", "Pow10", "(", "int", "(", "u", "+", "8", ")", ")", "\n", "}" ]
// ToUnit converts a monetary amount counted in bitcoin base units to a // floating point value representing an amount of bitcoin.
[ "ToUnit", "converts", "a", "monetary", "amount", "counted", "in", "bitcoin", "base", "units", "to", "a", "floating", "point", "value", "representing", "an", "amount", "of", "bitcoin", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/amount.go#L93-L95
27,533
btcsuite/btcutil
amount.go
Format
func (a Amount) Format(u AmountUnit) string { units := " " + u.String() return strconv.FormatFloat(a.ToUnit(u), 'f', -int(u+8), 64) + units }
go
func (a Amount) Format(u AmountUnit) string { units := " " + u.String() return strconv.FormatFloat(a.ToUnit(u), 'f', -int(u+8), 64) + units }
[ "func", "(", "a", "Amount", ")", "Format", "(", "u", "AmountUnit", ")", "string", "{", "units", ":=", "\"", "\"", "+", "u", ".", "String", "(", ")", "\n", "return", "strconv", ".", "FormatFloat", "(", "a", ".", "ToUnit", "(", "u", ")", ",", "'f'"...
// Format formats a monetary amount counted in bitcoin base units as a // string for a given unit. The conversion will succeed for any unit, // however, known units will be formated with an appended label describing // the units with SI notation, or "Satoshi" for the base unit.
[ "Format", "formats", "a", "monetary", "amount", "counted", "in", "bitcoin", "base", "units", "as", "a", "string", "for", "a", "given", "unit", ".", "The", "conversion", "will", "succeed", "for", "any", "unit", "however", "known", "units", "will", "be", "fo...
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/amount.go#L106-L109
27,534
btcsuite/btcutil
bloom/merkleblock.go
calcHash
func (m *merkleBlock) calcHash(height, pos uint32) *chainhash.Hash { if height == 0 { return m.allHashes[pos] } var right *chainhash.Hash left := m.calcHash(height-1, pos*2) if pos*2+1 < m.calcTreeWidth(height-1) { right = m.calcHash(height-1, pos*2+1) } else { right = left } return blockchain.HashMerkle...
go
func (m *merkleBlock) calcHash(height, pos uint32) *chainhash.Hash { if height == 0 { return m.allHashes[pos] } var right *chainhash.Hash left := m.calcHash(height-1, pos*2) if pos*2+1 < m.calcTreeWidth(height-1) { right = m.calcHash(height-1, pos*2+1) } else { right = left } return blockchain.HashMerkle...
[ "func", "(", "m", "*", "merkleBlock", ")", "calcHash", "(", "height", ",", "pos", "uint32", ")", "*", "chainhash", ".", "Hash", "{", "if", "height", "==", "0", "{", "return", "m", ".", "allHashes", "[", "pos", "]", "\n", "}", "\n\n", "var", "right"...
// calcHash returns the hash for a sub-tree given a depth-first height and // node position.
[ "calcHash", "returns", "the", "hash", "for", "a", "sub", "-", "tree", "given", "a", "depth", "-", "first", "height", "and", "node", "position", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/bloom/merkleblock.go#L32-L45
27,535
btcsuite/btcutil
bloom/merkleblock.go
traverseAndBuild
func (m *merkleBlock) traverseAndBuild(height, pos uint32) { // Determine whether this node is a parent of a matched node. var isParent byte for i := pos << height; i < (pos+1)<<height && i < m.numTx; i++ { isParent |= m.matchedBits[i] } m.bits = append(m.bits, isParent) // When the node is a leaf node or not ...
go
func (m *merkleBlock) traverseAndBuild(height, pos uint32) { // Determine whether this node is a parent of a matched node. var isParent byte for i := pos << height; i < (pos+1)<<height && i < m.numTx; i++ { isParent |= m.matchedBits[i] } m.bits = append(m.bits, isParent) // When the node is a leaf node or not ...
[ "func", "(", "m", "*", "merkleBlock", ")", "traverseAndBuild", "(", "height", ",", "pos", "uint32", ")", "{", "// Determine whether this node is a parent of a matched node.", "var", "isParent", "byte", "\n", "for", "i", ":=", "pos", "<<", "height", ";", "i", "<"...
// traverseAndBuild builds a partial merkle tree using a recursive depth-first // approach. As it calculates the hashes, it also saves whether or not each // node is a parent node and a list of final hashes to be included in the // merkle block.
[ "traverseAndBuild", "builds", "a", "partial", "merkle", "tree", "using", "a", "recursive", "depth", "-", "first", "approach", ".", "As", "it", "calculates", "the", "hashes", "it", "also", "saves", "whether", "or", "not", "each", "node", "is", "a", "parent", ...
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/bloom/merkleblock.go#L51-L78
27,536
btcsuite/btcutil
address.go
encodeSegWitAddress
func encodeSegWitAddress(hrp string, witnessVersion byte, witnessProgram []byte) (string, error) { // Group the address bytes into 5 bit groups, as this is what is used to // encode each character in the address string. converted, err := bech32.ConvertBits(witnessProgram, 8, 5, true) if err != nil { return "", er...
go
func encodeSegWitAddress(hrp string, witnessVersion byte, witnessProgram []byte) (string, error) { // Group the address bytes into 5 bit groups, as this is what is used to // encode each character in the address string. converted, err := bech32.ConvertBits(witnessProgram, 8, 5, true) if err != nil { return "", er...
[ "func", "encodeSegWitAddress", "(", "hrp", "string", ",", "witnessVersion", "byte", ",", "witnessProgram", "[", "]", "byte", ")", "(", "string", ",", "error", ")", "{", "// Group the address bytes into 5 bit groups, as this is what is used to", "// encode each character in ...
// encodeSegWitAddress creates a bech32 encoded address string representation // from witness version and witness program.
[ "encodeSegWitAddress", "creates", "a", "bech32", "encoded", "address", "string", "representation", "from", "witness", "version", "and", "witness", "program", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/address.go#L69-L98
27,537
btcsuite/btcutil
address.go
decodeSegWitAddress
func decodeSegWitAddress(address string) (byte, []byte, error) { // Decode the bech32 encoded address. _, data, err := bech32.Decode(address) if err != nil { return 0, nil, err } // The first byte of the decoded address is the witness version, it must // exist. if len(data) < 1 { return 0, nil, fmt.Errorf("...
go
func decodeSegWitAddress(address string) (byte, []byte, error) { // Decode the bech32 encoded address. _, data, err := bech32.Decode(address) if err != nil { return 0, nil, err } // The first byte of the decoded address is the witness version, it must // exist. if len(data) < 1 { return 0, nil, fmt.Errorf("...
[ "func", "decodeSegWitAddress", "(", "address", "string", ")", "(", "byte", ",", "[", "]", "byte", ",", "error", ")", "{", "// Decode the bech32 encoded address.", "_", ",", "data", ",", "err", ":=", "bech32", ".", "Decode", "(", "address", ")", "\n", "if",...
// decodeSegWitAddress parses a bech32 encoded segwit address string and // returns the witness version and witness program byte representation.
[ "decodeSegWitAddress", "parses", "a", "bech32", "encoded", "segwit", "address", "string", "and", "returns", "the", "witness", "version", "and", "witness", "program", "byte", "representation", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/address.go#L211-L250
27,538
btcsuite/btcutil
address.go
NewAddressPubKeyHash
func NewAddressPubKeyHash(pkHash []byte, net *chaincfg.Params) (*AddressPubKeyHash, error) { return newAddressPubKeyHash(pkHash, net.PubKeyHashAddrID) }
go
func NewAddressPubKeyHash(pkHash []byte, net *chaincfg.Params) (*AddressPubKeyHash, error) { return newAddressPubKeyHash(pkHash, net.PubKeyHashAddrID) }
[ "func", "NewAddressPubKeyHash", "(", "pkHash", "[", "]", "byte", ",", "net", "*", "chaincfg", ".", "Params", ")", "(", "*", "AddressPubKeyHash", ",", "error", ")", "{", "return", "newAddressPubKeyHash", "(", "pkHash", ",", "net", ".", "PubKeyHashAddrID", ")"...
// NewAddressPubKeyHash returns a new AddressPubKeyHash. pkHash mustbe 20 // bytes.
[ "NewAddressPubKeyHash", "returns", "a", "new", "AddressPubKeyHash", ".", "pkHash", "mustbe", "20", "bytes", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/address.go#L261-L263
27,539
btcsuite/btcutil
address.go
newAddressPubKeyHash
func newAddressPubKeyHash(pkHash []byte, netID byte) (*AddressPubKeyHash, error) { // Check for a valid pubkey hash length. if len(pkHash) != ripemd160.Size { return nil, errors.New("pkHash must be 20 bytes") } addr := &AddressPubKeyHash{netID: netID} copy(addr.hash[:], pkHash) return addr, nil }
go
func newAddressPubKeyHash(pkHash []byte, netID byte) (*AddressPubKeyHash, error) { // Check for a valid pubkey hash length. if len(pkHash) != ripemd160.Size { return nil, errors.New("pkHash must be 20 bytes") } addr := &AddressPubKeyHash{netID: netID} copy(addr.hash[:], pkHash) return addr, nil }
[ "func", "newAddressPubKeyHash", "(", "pkHash", "[", "]", "byte", ",", "netID", "byte", ")", "(", "*", "AddressPubKeyHash", ",", "error", ")", "{", "// Check for a valid pubkey hash length.", "if", "len", "(", "pkHash", ")", "!=", "ripemd160", ".", "Size", "{",...
// newAddressPubKeyHash is the internal API to create a pubkey hash address // with a known leading identifier byte for a network, rather than looking // it up through its parameters. This is useful when creating a new address // structure from a string encoding where the identifer byte is already // known.
[ "newAddressPubKeyHash", "is", "the", "internal", "API", "to", "create", "a", "pubkey", "hash", "address", "with", "a", "known", "leading", "identifier", "byte", "for", "a", "network", "rather", "than", "looking", "it", "up", "through", "its", "parameters", "."...
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/address.go#L270-L279
27,540
btcsuite/btcutil
address.go
IsForNet
func (a *AddressPubKeyHash) IsForNet(net *chaincfg.Params) bool { return a.netID == net.PubKeyHashAddrID }
go
func (a *AddressPubKeyHash) IsForNet(net *chaincfg.Params) bool { return a.netID == net.PubKeyHashAddrID }
[ "func", "(", "a", "*", "AddressPubKeyHash", ")", "IsForNet", "(", "net", "*", "chaincfg", ".", "Params", ")", "bool", "{", "return", "a", ".", "netID", "==", "net", ".", "PubKeyHashAddrID", "\n", "}" ]
// IsForNet returns whether or not the pay-to-pubkey-hash address is associated // with the passed bitcoin network.
[ "IsForNet", "returns", "whether", "or", "not", "the", "pay", "-", "to", "-", "pubkey", "-", "hash", "address", "is", "associated", "with", "the", "passed", "bitcoin", "network", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/address.go#L295-L297
27,541
btcsuite/btcutil
address.go
NewAddressScriptHash
func NewAddressScriptHash(serializedScript []byte, net *chaincfg.Params) (*AddressScriptHash, error) { scriptHash := Hash160(serializedScript) return newAddressScriptHashFromHash(scriptHash, net.ScriptHashAddrID) }
go
func NewAddressScriptHash(serializedScript []byte, net *chaincfg.Params) (*AddressScriptHash, error) { scriptHash := Hash160(serializedScript) return newAddressScriptHashFromHash(scriptHash, net.ScriptHashAddrID) }
[ "func", "NewAddressScriptHash", "(", "serializedScript", "[", "]", "byte", ",", "net", "*", "chaincfg", ".", "Params", ")", "(", "*", "AddressScriptHash", ",", "error", ")", "{", "scriptHash", ":=", "Hash160", "(", "serializedScript", ")", "\n", "return", "n...
// NewAddressScriptHash returns a new AddressScriptHash.
[ "NewAddressScriptHash", "returns", "a", "new", "AddressScriptHash", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/address.go#L321-L324
27,542
btcsuite/btcutil
address.go
NewAddressScriptHashFromHash
func NewAddressScriptHashFromHash(scriptHash []byte, net *chaincfg.Params) (*AddressScriptHash, error) { return newAddressScriptHashFromHash(scriptHash, net.ScriptHashAddrID) }
go
func NewAddressScriptHashFromHash(scriptHash []byte, net *chaincfg.Params) (*AddressScriptHash, error) { return newAddressScriptHashFromHash(scriptHash, net.ScriptHashAddrID) }
[ "func", "NewAddressScriptHashFromHash", "(", "scriptHash", "[", "]", "byte", ",", "net", "*", "chaincfg", ".", "Params", ")", "(", "*", "AddressScriptHash", ",", "error", ")", "{", "return", "newAddressScriptHashFromHash", "(", "scriptHash", ",", "net", ".", "...
// NewAddressScriptHashFromHash returns a new AddressScriptHash. scriptHash // must be 20 bytes.
[ "NewAddressScriptHashFromHash", "returns", "a", "new", "AddressScriptHash", ".", "scriptHash", "must", "be", "20", "bytes", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/address.go#L328-L330
27,543
btcsuite/btcutil
address.go
newAddressScriptHashFromHash
func newAddressScriptHashFromHash(scriptHash []byte, netID byte) (*AddressScriptHash, error) { // Check for a valid script hash length. if len(scriptHash) != ripemd160.Size { return nil, errors.New("scriptHash must be 20 bytes") } addr := &AddressScriptHash{netID: netID} copy(addr.hash[:], scriptHash) return a...
go
func newAddressScriptHashFromHash(scriptHash []byte, netID byte) (*AddressScriptHash, error) { // Check for a valid script hash length. if len(scriptHash) != ripemd160.Size { return nil, errors.New("scriptHash must be 20 bytes") } addr := &AddressScriptHash{netID: netID} copy(addr.hash[:], scriptHash) return a...
[ "func", "newAddressScriptHashFromHash", "(", "scriptHash", "[", "]", "byte", ",", "netID", "byte", ")", "(", "*", "AddressScriptHash", ",", "error", ")", "{", "// Check for a valid script hash length.", "if", "len", "(", "scriptHash", ")", "!=", "ripemd160", ".", ...
// newAddressScriptHashFromHash is the internal API to create a script hash // address with a known leading identifier byte for a network, rather than // looking it up through its parameters. This is useful when creating a new // address structure from a string encoding where the identifer byte is already // known.
[ "newAddressScriptHashFromHash", "is", "the", "internal", "API", "to", "create", "a", "script", "hash", "address", "with", "a", "known", "leading", "identifier", "byte", "for", "a", "network", "rather", "than", "looking", "it", "up", "through", "its", "parameters...
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/address.go#L337-L346
27,544
btcsuite/btcutil
address.go
IsForNet
func (a *AddressScriptHash) IsForNet(net *chaincfg.Params) bool { return a.netID == net.ScriptHashAddrID }
go
func (a *AddressScriptHash) IsForNet(net *chaincfg.Params) bool { return a.netID == net.ScriptHashAddrID }
[ "func", "(", "a", "*", "AddressScriptHash", ")", "IsForNet", "(", "net", "*", "chaincfg", ".", "Params", ")", "bool", "{", "return", "a", ".", "netID", "==", "net", ".", "ScriptHashAddrID", "\n", "}" ]
// IsForNet returns whether or not the pay-to-script-hash address is associated // with the passed bitcoin network.
[ "IsForNet", "returns", "whether", "or", "not", "the", "pay", "-", "to", "-", "script", "-", "hash", "address", "is", "associated", "with", "the", "passed", "bitcoin", "network", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/address.go#L362-L364
27,545
btcsuite/btcutil
address.go
serialize
func (a *AddressPubKey) serialize() []byte { switch a.pubKeyFormat { default: fallthrough case PKFUncompressed: return a.pubKey.SerializeUncompressed() case PKFCompressed: return a.pubKey.SerializeCompressed() case PKFHybrid: return a.pubKey.SerializeHybrid() } }
go
func (a *AddressPubKey) serialize() []byte { switch a.pubKeyFormat { default: fallthrough case PKFUncompressed: return a.pubKey.SerializeUncompressed() case PKFCompressed: return a.pubKey.SerializeCompressed() case PKFHybrid: return a.pubKey.SerializeHybrid() } }
[ "func", "(", "a", "*", "AddressPubKey", ")", "serialize", "(", ")", "[", "]", "byte", "{", "switch", "a", ".", "pubKeyFormat", "{", "default", ":", "fallthrough", "\n", "case", "PKFUncompressed", ":", "return", "a", ".", "pubKey", ".", "SerializeUncompress...
// serialize returns the serialization of the public key according to the // format associated with the address.
[ "serialize", "returns", "the", "serialization", "of", "the", "public", "key", "according", "to", "the", "format", "associated", "with", "the", "address", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/address.go#L434-L447
27,546
btcsuite/btcutil
address.go
IsForNet
func (a *AddressPubKey) IsForNet(net *chaincfg.Params) bool { return a.pubKeyHashID == net.PubKeyHashAddrID }
go
func (a *AddressPubKey) IsForNet(net *chaincfg.Params) bool { return a.pubKeyHashID == net.PubKeyHashAddrID }
[ "func", "(", "a", "*", "AddressPubKey", ")", "IsForNet", "(", "net", "*", "chaincfg", ".", "Params", ")", "bool", "{", "return", "a", ".", "pubKeyHashID", "==", "net", ".", "PubKeyHashAddrID", "\n", "}" ]
// IsForNet returns whether or not the pay-to-pubkey address is associated // with the passed bitcoin network.
[ "IsForNet", "returns", "whether", "or", "not", "the", "pay", "-", "to", "-", "pubkey", "address", "is", "associated", "with", "the", "passed", "bitcoin", "network", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/address.go#L470-L472
27,547
btcsuite/btcutil
address.go
NewAddressWitnessPubKeyHash
func NewAddressWitnessPubKeyHash(witnessProg []byte, net *chaincfg.Params) (*AddressWitnessPubKeyHash, error) { return newAddressWitnessPubKeyHash(net.Bech32HRPSegwit, witnessProg) }
go
func NewAddressWitnessPubKeyHash(witnessProg []byte, net *chaincfg.Params) (*AddressWitnessPubKeyHash, error) { return newAddressWitnessPubKeyHash(net.Bech32HRPSegwit, witnessProg) }
[ "func", "NewAddressWitnessPubKeyHash", "(", "witnessProg", "[", "]", "byte", ",", "net", "*", "chaincfg", ".", "Params", ")", "(", "*", "AddressWitnessPubKeyHash", ",", "error", ")", "{", "return", "newAddressWitnessPubKeyHash", "(", "net", ".", "Bech32HRPSegwit",...
// NewAddressWitnessPubKeyHash returns a new AddressWitnessPubKeyHash.
[ "NewAddressWitnessPubKeyHash", "returns", "a", "new", "AddressWitnessPubKeyHash", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/address.go#L520-L522
27,548
btcsuite/btcutil
address.go
newAddressWitnessPubKeyHash
func newAddressWitnessPubKeyHash(hrp string, witnessProg []byte) (*AddressWitnessPubKeyHash, error) { // Check for valid program length for witness version 0, which is 20 // for P2WPKH. if len(witnessProg) != 20 { return nil, errors.New("witness program must be 20 " + "bytes for p2wpkh") } addr := &AddressWi...
go
func newAddressWitnessPubKeyHash(hrp string, witnessProg []byte) (*AddressWitnessPubKeyHash, error) { // Check for valid program length for witness version 0, which is 20 // for P2WPKH. if len(witnessProg) != 20 { return nil, errors.New("witness program must be 20 " + "bytes for p2wpkh") } addr := &AddressWi...
[ "func", "newAddressWitnessPubKeyHash", "(", "hrp", "string", ",", "witnessProg", "[", "]", "byte", ")", "(", "*", "AddressWitnessPubKeyHash", ",", "error", ")", "{", "// Check for valid program length for witness version 0, which is 20", "// for P2WPKH.", "if", "len", "("...
// newAddressWitnessPubKeyHash is an internal helper function to create an // AddressWitnessPubKeyHash with a known human-readable part, rather than // looking it up through its parameters.
[ "newAddressWitnessPubKeyHash", "is", "an", "internal", "helper", "function", "to", "create", "an", "AddressWitnessPubKeyHash", "with", "a", "known", "human", "-", "readable", "part", "rather", "than", "looking", "it", "up", "through", "its", "parameters", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/address.go#L527-L543
27,549
btcsuite/btcutil
address.go
EncodeAddress
func (a *AddressWitnessPubKeyHash) EncodeAddress() string { str, err := encodeSegWitAddress(a.hrp, a.witnessVersion, a.witnessProgram[:]) if err != nil { return "" } return str }
go
func (a *AddressWitnessPubKeyHash) EncodeAddress() string { str, err := encodeSegWitAddress(a.hrp, a.witnessVersion, a.witnessProgram[:]) if err != nil { return "" } return str }
[ "func", "(", "a", "*", "AddressWitnessPubKeyHash", ")", "EncodeAddress", "(", ")", "string", "{", "str", ",", "err", ":=", "encodeSegWitAddress", "(", "a", ".", "hrp", ",", "a", ".", "witnessVersion", ",", "a", ".", "witnessProgram", "[", ":", "]", ")", ...
// EncodeAddress returns the bech32 string encoding of an // AddressWitnessPubKeyHash. // Part of the Address interface.
[ "EncodeAddress", "returns", "the", "bech32", "string", "encoding", "of", "an", "AddressWitnessPubKeyHash", ".", "Part", "of", "the", "Address", "interface", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/address.go#L548-L555
27,550
btcsuite/btcutil
address.go
IsForNet
func (a *AddressWitnessPubKeyHash) IsForNet(net *chaincfg.Params) bool { return a.hrp == net.Bech32HRPSegwit }
go
func (a *AddressWitnessPubKeyHash) IsForNet(net *chaincfg.Params) bool { return a.hrp == net.Bech32HRPSegwit }
[ "func", "(", "a", "*", "AddressWitnessPubKeyHash", ")", "IsForNet", "(", "net", "*", "chaincfg", ".", "Params", ")", "bool", "{", "return", "a", ".", "hrp", "==", "net", ".", "Bech32HRPSegwit", "\n", "}" ]
// IsForNet returns whether or not the AddressWitnessPubKeyHash is associated // with the passed bitcoin network. // Part of the Address interface.
[ "IsForNet", "returns", "whether", "or", "not", "the", "AddressWitnessPubKeyHash", "is", "associated", "with", "the", "passed", "bitcoin", "network", ".", "Part", "of", "the", "Address", "interface", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/address.go#L566-L568
27,551
btcsuite/btcutil
address.go
NewAddressWitnessScriptHash
func NewAddressWitnessScriptHash(witnessProg []byte, net *chaincfg.Params) (*AddressWitnessScriptHash, error) { return newAddressWitnessScriptHash(net.Bech32HRPSegwit, witnessProg) }
go
func NewAddressWitnessScriptHash(witnessProg []byte, net *chaincfg.Params) (*AddressWitnessScriptHash, error) { return newAddressWitnessScriptHash(net.Bech32HRPSegwit, witnessProg) }
[ "func", "NewAddressWitnessScriptHash", "(", "witnessProg", "[", "]", "byte", ",", "net", "*", "chaincfg", ".", "Params", ")", "(", "*", "AddressWitnessScriptHash", ",", "error", ")", "{", "return", "newAddressWitnessScriptHash", "(", "net", ".", "Bech32HRPSegwit",...
// NewAddressWitnessScriptHash returns a new AddressWitnessPubKeyHash.
[ "NewAddressWitnessScriptHash", "returns", "a", "new", "AddressWitnessPubKeyHash", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/address.go#L611-L613
27,552
btcsuite/btcutil
address.go
newAddressWitnessScriptHash
func newAddressWitnessScriptHash(hrp string, witnessProg []byte) (*AddressWitnessScriptHash, error) { // Check for valid program length for witness version 0, which is 32 // for P2WSH. if len(witnessProg) != 32 { return nil, errors.New("witness program must be 32 " + "bytes for p2wsh") } addr := &AddressWitn...
go
func newAddressWitnessScriptHash(hrp string, witnessProg []byte) (*AddressWitnessScriptHash, error) { // Check for valid program length for witness version 0, which is 32 // for P2WSH. if len(witnessProg) != 32 { return nil, errors.New("witness program must be 32 " + "bytes for p2wsh") } addr := &AddressWitn...
[ "func", "newAddressWitnessScriptHash", "(", "hrp", "string", ",", "witnessProg", "[", "]", "byte", ")", "(", "*", "AddressWitnessScriptHash", ",", "error", ")", "{", "// Check for valid program length for witness version 0, which is 32", "// for P2WSH.", "if", "len", "(",...
// newAddressWitnessScriptHash is an internal helper function to create an // AddressWitnessScriptHash with a known human-readable part, rather than // looking it up through its parameters.
[ "newAddressWitnessScriptHash", "is", "an", "internal", "helper", "function", "to", "create", "an", "AddressWitnessScriptHash", "with", "a", "known", "human", "-", "readable", "part", "rather", "than", "looking", "it", "up", "through", "its", "parameters", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/address.go#L618-L634
27,553
btcsuite/btcutil
base58/base58check.go
CheckEncode
func CheckEncode(input []byte, version byte) string { b := make([]byte, 0, 1+len(input)+4) b = append(b, version) b = append(b, input[:]...) cksum := checksum(b) b = append(b, cksum[:]...) return Encode(b) }
go
func CheckEncode(input []byte, version byte) string { b := make([]byte, 0, 1+len(input)+4) b = append(b, version) b = append(b, input[:]...) cksum := checksum(b) b = append(b, cksum[:]...) return Encode(b) }
[ "func", "CheckEncode", "(", "input", "[", "]", "byte", ",", "version", "byte", ")", "string", "{", "b", ":=", "make", "(", "[", "]", "byte", ",", "0", ",", "1", "+", "len", "(", "input", ")", "+", "4", ")", "\n", "b", "=", "append", "(", "b",...
// CheckEncode prepends a version byte and appends a four byte checksum.
[ "CheckEncode", "prepends", "a", "version", "byte", "and", "appends", "a", "four", "byte", "checksum", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/base58/base58check.go#L28-L35
27,554
btcsuite/btcutil
base58/base58check.go
CheckDecode
func CheckDecode(input string) (result []byte, version byte, err error) { decoded := Decode(input) if len(decoded) < 5 { return nil, 0, ErrInvalidFormat } version = decoded[0] var cksum [4]byte copy(cksum[:], decoded[len(decoded)-4:]) if checksum(decoded[:len(decoded)-4]) != cksum { return nil, 0, ErrChecksu...
go
func CheckDecode(input string) (result []byte, version byte, err error) { decoded := Decode(input) if len(decoded) < 5 { return nil, 0, ErrInvalidFormat } version = decoded[0] var cksum [4]byte copy(cksum[:], decoded[len(decoded)-4:]) if checksum(decoded[:len(decoded)-4]) != cksum { return nil, 0, ErrChecksu...
[ "func", "CheckDecode", "(", "input", "string", ")", "(", "result", "[", "]", "byte", ",", "version", "byte", ",", "err", "error", ")", "{", "decoded", ":=", "Decode", "(", "input", ")", "\n", "if", "len", "(", "decoded", ")", "<", "5", "{", "return...
// CheckDecode decodes a string that was encoded with CheckEncode and verifies the checksum.
[ "CheckDecode", "decodes", "a", "string", "that", "was", "encoded", "with", "CheckEncode", "and", "verifies", "the", "checksum", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/base58/base58check.go#L38-L52
27,555
btcsuite/btcutil
bloom/murmurhash3.go
MurmurHash3
func MurmurHash3(seed uint32, data []byte) uint32 { dataLen := uint32(len(data)) hash := seed k := uint32(0) numBlocks := dataLen / 4 // Calculate the hash in 4-byte chunks. for i := uint32(0); i < numBlocks; i++ { k = binary.LittleEndian.Uint32(data[i*4:]) k *= murmurC1 k = (k << murmurR1) | (k >> (32 - m...
go
func MurmurHash3(seed uint32, data []byte) uint32 { dataLen := uint32(len(data)) hash := seed k := uint32(0) numBlocks := dataLen / 4 // Calculate the hash in 4-byte chunks. for i := uint32(0); i < numBlocks; i++ { k = binary.LittleEndian.Uint32(data[i*4:]) k *= murmurC1 k = (k << murmurR1) | (k >> (32 - m...
[ "func", "MurmurHash3", "(", "seed", "uint32", ",", "data", "[", "]", "byte", ")", "uint32", "{", "dataLen", ":=", "uint32", "(", "len", "(", "data", ")", ")", "\n", "hash", ":=", "seed", "\n", "k", ":=", "uint32", "(", "0", ")", "\n", "numBlocks", ...
// MurmurHash3 implements a non-cryptographic hash function using the // MurmurHash3 algorithm. This implementation yields a 32-bit hash value which // is suitable for general hash-based lookups. The seed can be used to // effectively randomize the hash function. This makes it ideal for use in // bloom filters which...
[ "MurmurHash3", "implements", "a", "non", "-", "cryptographic", "hash", "function", "using", "the", "MurmurHash3", "algorithm", ".", "This", "implementation", "yields", "a", "32", "-", "bit", "hash", "value", "which", "is", "suitable", "for", "general", "hash", ...
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/bloom/murmurhash3.go#L26-L72
27,556
btcsuite/btcutil
coinset/coins.go
NewCoinSet
func NewCoinSet(coins []Coin) *CoinSet { newCoinSet := &CoinSet{ coinList: list.New(), totalValue: 0, totalValueAge: 0, } for _, coin := range coins { newCoinSet.PushCoin(coin) } return newCoinSet }
go
func NewCoinSet(coins []Coin) *CoinSet { newCoinSet := &CoinSet{ coinList: list.New(), totalValue: 0, totalValueAge: 0, } for _, coin := range coins { newCoinSet.PushCoin(coin) } return newCoinSet }
[ "func", "NewCoinSet", "(", "coins", "[", "]", "Coin", ")", "*", "CoinSet", "{", "newCoinSet", ":=", "&", "CoinSet", "{", "coinList", ":", "list", ".", "New", "(", ")", ",", "totalValue", ":", "0", ",", "totalValueAge", ":", "0", ",", "}", "\n", "fo...
// NewCoinSet creates a CoinSet containing the coins provided. // To create an empty CoinSet, you may pass null as the coins input parameter.
[ "NewCoinSet", "creates", "a", "CoinSet", "containing", "the", "coins", "provided", ".", "To", "create", "an", "empty", "CoinSet", "you", "may", "pass", "null", "as", "the", "coins", "input", "parameter", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/coinset/coins.go#L51-L61
27,557
btcsuite/btcutil
coinset/coins.go
Coins
func (cs *CoinSet) Coins() []Coin { coins := make([]Coin, cs.coinList.Len()) for i, e := 0, cs.coinList.Front(); e != nil; i, e = i+1, e.Next() { coins[i] = e.Value.(Coin) } return coins }
go
func (cs *CoinSet) Coins() []Coin { coins := make([]Coin, cs.coinList.Len()) for i, e := 0, cs.coinList.Front(); e != nil; i, e = i+1, e.Next() { coins[i] = e.Value.(Coin) } return coins }
[ "func", "(", "cs", "*", "CoinSet", ")", "Coins", "(", ")", "[", "]", "Coin", "{", "coins", ":=", "make", "(", "[", "]", "Coin", ",", "cs", ".", "coinList", ".", "Len", "(", ")", ")", "\n", "for", "i", ",", "e", ":=", "0", ",", "cs", ".", ...
// Coins returns a new slice of the coins contained in the set.
[ "Coins", "returns", "a", "new", "slice", "of", "the", "coins", "contained", "in", "the", "set", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/coinset/coins.go#L64-L70
27,558
btcsuite/btcutil
coinset/coins.go
PushCoin
func (cs *CoinSet) PushCoin(c Coin) { cs.coinList.PushBack(c) cs.totalValue += c.Value() cs.totalValueAge += c.ValueAge() }
go
func (cs *CoinSet) PushCoin(c Coin) { cs.coinList.PushBack(c) cs.totalValue += c.Value() cs.totalValueAge += c.ValueAge() }
[ "func", "(", "cs", "*", "CoinSet", ")", "PushCoin", "(", "c", "Coin", ")", "{", "cs", ".", "coinList", ".", "PushBack", "(", "c", ")", "\n", "cs", ".", "totalValue", "+=", "c", ".", "Value", "(", ")", "\n", "cs", ".", "totalValueAge", "+=", "c", ...
// PushCoin adds a coin to the end of the list and updates // the cached value amounts.
[ "PushCoin", "adds", "a", "coin", "to", "the", "end", "of", "the", "list", "and", "updates", "the", "cached", "value", "amounts", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/coinset/coins.go#L90-L94
27,559
btcsuite/btcutil
coinset/coins.go
PopCoin
func (cs *CoinSet) PopCoin() Coin { back := cs.coinList.Back() if back == nil { return nil } return cs.removeElement(back) }
go
func (cs *CoinSet) PopCoin() Coin { back := cs.coinList.Back() if back == nil { return nil } return cs.removeElement(back) }
[ "func", "(", "cs", "*", "CoinSet", ")", "PopCoin", "(", ")", "Coin", "{", "back", ":=", "cs", ".", "coinList", ".", "Back", "(", ")", "\n", "if", "back", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "cs", ".", "removeElement", "(...
// PopCoin removes the last coin on the list and returns it.
[ "PopCoin", "removes", "the", "last", "coin", "on", "the", "list", "and", "returns", "it", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/coinset/coins.go#L97-L103
27,560
btcsuite/btcutil
coinset/coins.go
ShiftCoin
func (cs *CoinSet) ShiftCoin() Coin { front := cs.coinList.Front() if front == nil { return nil } return cs.removeElement(front) }
go
func (cs *CoinSet) ShiftCoin() Coin { front := cs.coinList.Front() if front == nil { return nil } return cs.removeElement(front) }
[ "func", "(", "cs", "*", "CoinSet", ")", "ShiftCoin", "(", ")", "Coin", "{", "front", ":=", "cs", ".", "coinList", ".", "Front", "(", ")", "\n", "if", "front", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "cs", ".", "removeElement",...
// ShiftCoin removes the first coin on the list and returns it.
[ "ShiftCoin", "removes", "the", "first", "coin", "on", "the", "list", "and", "returns", "it", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/coinset/coins.go#L106-L112
27,561
btcsuite/btcutil
coinset/coins.go
removeElement
func (cs *CoinSet) removeElement(e *list.Element) Coin { c := e.Value.(Coin) cs.coinList.Remove(e) cs.totalValue -= c.Value() cs.totalValueAge -= c.ValueAge() return c }
go
func (cs *CoinSet) removeElement(e *list.Element) Coin { c := e.Value.(Coin) cs.coinList.Remove(e) cs.totalValue -= c.Value() cs.totalValueAge -= c.ValueAge() return c }
[ "func", "(", "cs", "*", "CoinSet", ")", "removeElement", "(", "e", "*", "list", ".", "Element", ")", "Coin", "{", "c", ":=", "e", ".", "Value", ".", "(", "Coin", ")", "\n", "cs", ".", "coinList", ".", "Remove", "(", "e", ")", "\n", "cs", ".", ...
// removeElement updates the cached value amounts in the CoinSet, // removes the element from the list, then returns the Coin that // was removed to the caller.
[ "removeElement", "updates", "the", "cached", "value", "amounts", "in", "the", "CoinSet", "removes", "the", "element", "from", "the", "list", "then", "returns", "the", "Coin", "that", "was", "removed", "to", "the", "caller", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/coinset/coins.go#L117-L123
27,562
btcsuite/btcutil
coinset/coins.go
NewMsgTxWithInputCoins
func NewMsgTxWithInputCoins(txVersion int32, inputCoins Coins) *wire.MsgTx { msgTx := wire.NewMsgTx(txVersion) coins := inputCoins.Coins() msgTx.TxIn = make([]*wire.TxIn, len(coins)) for i, coin := range coins { msgTx.TxIn[i] = &wire.TxIn{ PreviousOutPoint: wire.OutPoint{ Hash: *coin.Hash(), Index: co...
go
func NewMsgTxWithInputCoins(txVersion int32, inputCoins Coins) *wire.MsgTx { msgTx := wire.NewMsgTx(txVersion) coins := inputCoins.Coins() msgTx.TxIn = make([]*wire.TxIn, len(coins)) for i, coin := range coins { msgTx.TxIn[i] = &wire.TxIn{ PreviousOutPoint: wire.OutPoint{ Hash: *coin.Hash(), Index: co...
[ "func", "NewMsgTxWithInputCoins", "(", "txVersion", "int32", ",", "inputCoins", "Coins", ")", "*", "wire", ".", "MsgTx", "{", "msgTx", ":=", "wire", ".", "NewMsgTx", "(", "txVersion", ")", "\n", "coins", ":=", "inputCoins", ".", "Coins", "(", ")", "\n", ...
// NewMsgTxWithInputCoins takes the coins in the CoinSet and makes them // the inputs to a new wire.MsgTx which is returned.
[ "NewMsgTxWithInputCoins", "takes", "the", "coins", "in", "the", "CoinSet", "and", "makes", "them", "the", "inputs", "to", "a", "new", "wire", ".", "MsgTx", "which", "is", "returned", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/coinset/coins.go#L127-L142
27,563
btcsuite/btcutil
coinset/coins.go
CoinSelect
func (s MinIndexCoinSelector) CoinSelect(targetValue btcutil.Amount, coins []Coin) (Coins, error) { cs := NewCoinSet(nil) for n := 0; n < len(coins) && n < s.MaxInputs; n++ { cs.PushCoin(coins[n]) if satisfiesTargetValue(targetValue, s.MinChangeAmount, cs.TotalValue()) { return cs, nil } } return nil, ErrC...
go
func (s MinIndexCoinSelector) CoinSelect(targetValue btcutil.Amount, coins []Coin) (Coins, error) { cs := NewCoinSet(nil) for n := 0; n < len(coins) && n < s.MaxInputs; n++ { cs.PushCoin(coins[n]) if satisfiesTargetValue(targetValue, s.MinChangeAmount, cs.TotalValue()) { return cs, nil } } return nil, ErrC...
[ "func", "(", "s", "MinIndexCoinSelector", ")", "CoinSelect", "(", "targetValue", "btcutil", ".", "Amount", ",", "coins", "[", "]", "Coin", ")", "(", "Coins", ",", "error", ")", "{", "cs", ":=", "NewCoinSet", "(", "nil", ")", "\n", "for", "n", ":=", "...
// CoinSelect will attempt to select coins using the algorithm described // in the MinIndexCoinSelector struct.
[ "CoinSelect", "will", "attempt", "to", "select", "coins", "using", "the", "algorithm", "described", "in", "the", "MinIndexCoinSelector", "struct", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/coinset/coins.go#L181-L190
27,564
btcsuite/btcutil
coinset/coins.go
CoinSelect
func (s MinNumberCoinSelector) CoinSelect(targetValue btcutil.Amount, coins []Coin) (Coins, error) { sortedCoins := make([]Coin, 0, len(coins)) sortedCoins = append(sortedCoins, coins...) sort.Sort(sort.Reverse(byAmount(sortedCoins))) return MinIndexCoinSelector(s).CoinSelect(targetValue, sortedCoins) }
go
func (s MinNumberCoinSelector) CoinSelect(targetValue btcutil.Amount, coins []Coin) (Coins, error) { sortedCoins := make([]Coin, 0, len(coins)) sortedCoins = append(sortedCoins, coins...) sort.Sort(sort.Reverse(byAmount(sortedCoins))) return MinIndexCoinSelector(s).CoinSelect(targetValue, sortedCoins) }
[ "func", "(", "s", "MinNumberCoinSelector", ")", "CoinSelect", "(", "targetValue", "btcutil", ".", "Amount", ",", "coins", "[", "]", "Coin", ")", "(", "Coins", ",", "error", ")", "{", "sortedCoins", ":=", "make", "(", "[", "]", "Coin", ",", "0", ",", ...
// CoinSelect will attempt to select coins using the algorithm described // in the MinNumberCoinSelector struct.
[ "CoinSelect", "will", "attempt", "to", "select", "coins", "using", "the", "algorithm", "described", "in", "the", "MinNumberCoinSelector", "struct", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/coinset/coins.go#L202-L208
27,565
btcsuite/btcutil
coinset/coins.go
CoinSelect
func (s MinPriorityCoinSelector) CoinSelect(targetValue btcutil.Amount, coins []Coin) (Coins, error) { possibleCoins := make([]Coin, 0, len(coins)) possibleCoins = append(possibleCoins, coins...) sort.Sort(byValueAge(possibleCoins)) // find the first coin with sufficient valueAge cutoffIndex := -1 for i := 0; i...
go
func (s MinPriorityCoinSelector) CoinSelect(targetValue btcutil.Amount, coins []Coin) (Coins, error) { possibleCoins := make([]Coin, 0, len(coins)) possibleCoins = append(possibleCoins, coins...) sort.Sort(byValueAge(possibleCoins)) // find the first coin with sufficient valueAge cutoffIndex := -1 for i := 0; i...
[ "func", "(", "s", "MinPriorityCoinSelector", ")", "CoinSelect", "(", "targetValue", "btcutil", ".", "Amount", ",", "coins", "[", "]", "Coin", ")", "(", "Coins", ",", "error", ")", "{", "possibleCoins", ":=", "make", "(", "[", "]", "Coin", ",", "0", ","...
// CoinSelect will attempt to select coins using the algorithm described // in the MinPriorityCoinSelector struct.
[ "CoinSelect", "will", "attempt", "to", "select", "coins", "using", "the", "algorithm", "described", "in", "the", "MinPriorityCoinSelector", "struct", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/coinset/coins.go#L250-L331
27,566
btcsuite/btcutil
coinset/coins.go
txOut
func (c *SimpleCoin) txOut() *wire.TxOut { return c.Tx.MsgTx().TxOut[c.TxIndex] }
go
func (c *SimpleCoin) txOut() *wire.TxOut { return c.Tx.MsgTx().TxOut[c.TxIndex] }
[ "func", "(", "c", "*", "SimpleCoin", ")", "txOut", "(", ")", "*", "wire", ".", "TxOut", "{", "return", "c", ".", "Tx", ".", "MsgTx", "(", ")", ".", "TxOut", "[", "c", ".", "TxIndex", "]", "\n", "}" ]
// txOut returns the TxOut of the transaction the Coin represents
[ "txOut", "returns", "the", "TxOut", "of", "the", "transaction", "the", "Coin", "represents" ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/coinset/coins.go#L368-L370
27,567
btcsuite/btcutil
gcs/builder/builder.go
DeriveKey
func DeriveKey(keyHash *chainhash.Hash) [gcs.KeySize]byte { var key [gcs.KeySize]byte copy(key[:], keyHash.CloneBytes()[:]) return key }
go
func DeriveKey(keyHash *chainhash.Hash) [gcs.KeySize]byte { var key [gcs.KeySize]byte copy(key[:], keyHash.CloneBytes()[:]) return key }
[ "func", "DeriveKey", "(", "keyHash", "*", "chainhash", ".", "Hash", ")", "[", "gcs", ".", "KeySize", "]", "byte", "{", "var", "key", "[", "gcs", ".", "KeySize", "]", "byte", "\n", "copy", "(", "key", "[", ":", "]", ",", "keyHash", ".", "CloneBytes"...
// DeriveKey is a utility function that derives a key from a chainhash.Hash by // truncating the bytes of the hash to the appopriate key size.
[ "DeriveKey", "is", "a", "utility", "function", "that", "derives", "a", "key", "from", "a", "chainhash", ".", "Hash", "by", "truncating", "the", "bytes", "of", "the", "hash", "to", "the", "appopriate", "key", "size", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/gcs/builder/builder.go#L63-L67
27,568
btcsuite/btcutil
gcs/builder/builder.go
Key
func (b *GCSBuilder) Key() ([gcs.KeySize]byte, error) { // Do nothing if the builder's errored out. if b.err != nil { return [gcs.KeySize]byte{}, b.err } return b.key, nil }
go
func (b *GCSBuilder) Key() ([gcs.KeySize]byte, error) { // Do nothing if the builder's errored out. if b.err != nil { return [gcs.KeySize]byte{}, b.err } return b.key, nil }
[ "func", "(", "b", "*", "GCSBuilder", ")", "Key", "(", ")", "(", "[", "gcs", ".", "KeySize", "]", "byte", ",", "error", ")", "{", "// Do nothing if the builder's errored out.", "if", "b", ".", "err", "!=", "nil", "{", "return", "[", "gcs", ".", "KeySize...
// Key retrieves the key with which the builder will build a filter. This is // useful if the builder is created with a random initial key.
[ "Key", "retrieves", "the", "key", "with", "which", "the", "builder", "will", "build", "a", "filter", ".", "This", "is", "useful", "if", "the", "builder", "is", "created", "with", "a", "random", "initial", "key", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/gcs/builder/builder.go#L71-L78
27,569
btcsuite/btcutil
gcs/builder/builder.go
AddHash
func (b *GCSBuilder) AddHash(hash *chainhash.Hash) *GCSBuilder { // Do nothing if the builder's already errored out. if b.err != nil { return b } return b.AddEntry(hash.CloneBytes()) }
go
func (b *GCSBuilder) AddHash(hash *chainhash.Hash) *GCSBuilder { // Do nothing if the builder's already errored out. if b.err != nil { return b } return b.AddEntry(hash.CloneBytes()) }
[ "func", "(", "b", "*", "GCSBuilder", ")", "AddHash", "(", "hash", "*", "chainhash", ".", "Hash", ")", "*", "GCSBuilder", "{", "// Do nothing if the builder's already errored out.", "if", "b", ".", "err", "!=", "nil", "{", "return", "b", "\n", "}", "\n\n", ...
// AddHash adds a chainhash.Hash to the list of entries to be included in the // GCS filter when it's built.
[ "AddHash", "adds", "a", "chainhash", ".", "Hash", "to", "the", "list", "of", "entries", "to", "be", "included", "in", "the", "GCS", "filter", "when", "it", "s", "built", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/gcs/builder/builder.go#L181-L188
27,570
btcsuite/btcutil
gcs/builder/builder.go
AddWitness
func (b *GCSBuilder) AddWitness(witness wire.TxWitness) *GCSBuilder { // Do nothing if the builder's already errored out. if b.err != nil { return b } return b.AddEntries(witness) }
go
func (b *GCSBuilder) AddWitness(witness wire.TxWitness) *GCSBuilder { // Do nothing if the builder's already errored out. if b.err != nil { return b } return b.AddEntries(witness) }
[ "func", "(", "b", "*", "GCSBuilder", ")", "AddWitness", "(", "witness", "wire", ".", "TxWitness", ")", "*", "GCSBuilder", "{", "// Do nothing if the builder's already errored out.", "if", "b", ".", "err", "!=", "nil", "{", "return", "b", "\n", "}", "\n\n", "...
// AddWitness adds each item of the passed filter stack to the filter, and then // adds each item as a script.
[ "AddWitness", "adds", "each", "item", "of", "the", "passed", "filter", "stack", "to", "the", "filter", "and", "then", "adds", "each", "item", "as", "a", "script", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/gcs/builder/builder.go#L192-L199
27,571
btcsuite/btcutil
gcs/builder/builder.go
Build
func (b *GCSBuilder) Build() (*gcs.Filter, error) { // Do nothing if the builder's already errored out. if b.err != nil { return nil, b.err } // We'll ensure that all the parmaters we need to actually build the // filter properly are set. if b.p == 0 { return nil, fmt.Errorf("p value is not set, cannot build...
go
func (b *GCSBuilder) Build() (*gcs.Filter, error) { // Do nothing if the builder's already errored out. if b.err != nil { return nil, b.err } // We'll ensure that all the parmaters we need to actually build the // filter properly are set. if b.p == 0 { return nil, fmt.Errorf("p value is not set, cannot build...
[ "func", "(", "b", "*", "GCSBuilder", ")", "Build", "(", ")", "(", "*", "gcs", ".", "Filter", ",", "error", ")", "{", "// Do nothing if the builder's already errored out.", "if", "b", ".", "err", "!=", "nil", "{", "return", "nil", ",", "b", ".", "err", ...
// Build returns a function which builds a GCS filter with the given parameters // and data.
[ "Build", "returns", "a", "function", "which", "builds", "a", "GCS", "filter", "with", "the", "given", "parameters", "and", "data", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/gcs/builder/builder.go#L203-L224
27,572
btcsuite/btcutil
gcs/builder/builder.go
WithKeyPNM
func WithKeyPNM(key [gcs.KeySize]byte, p uint8, n uint32, m uint64) *GCSBuilder { b := GCSBuilder{} return b.SetKey(key).SetP(p).SetM(m).Preallocate(n) }
go
func WithKeyPNM(key [gcs.KeySize]byte, p uint8, n uint32, m uint64) *GCSBuilder { b := GCSBuilder{} return b.SetKey(key).SetP(p).SetM(m).Preallocate(n) }
[ "func", "WithKeyPNM", "(", "key", "[", "gcs", ".", "KeySize", "]", "byte", ",", "p", "uint8", ",", "n", "uint32", ",", "m", "uint64", ")", "*", "GCSBuilder", "{", "b", ":=", "GCSBuilder", "{", "}", "\n", "return", "b", ".", "SetKey", "(", "key", ...
// WithKeyPNM creates a GCSBuilder with specified key and the passed // probability, modulus and estimated filter size.
[ "WithKeyPNM", "creates", "a", "GCSBuilder", "with", "specified", "key", "and", "the", "passed", "probability", "modulus", "and", "estimated", "filter", "size", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/gcs/builder/builder.go#L228-L231
27,573
btcsuite/btcutil
gcs/builder/builder.go
WithKeyPM
func WithKeyPM(key [gcs.KeySize]byte, p uint8, m uint64) *GCSBuilder { return WithKeyPNM(key, p, 0, m) }
go
func WithKeyPM(key [gcs.KeySize]byte, p uint8, m uint64) *GCSBuilder { return WithKeyPNM(key, p, 0, m) }
[ "func", "WithKeyPM", "(", "key", "[", "gcs", ".", "KeySize", "]", "byte", ",", "p", "uint8", ",", "m", "uint64", ")", "*", "GCSBuilder", "{", "return", "WithKeyPNM", "(", "key", ",", "p", ",", "0", ",", "m", ")", "\n", "}" ]
// WithKeyPM creates a GCSBuilder with specified key and the passed // probability. Estimated filter size is set to zero, which means more // reallocations are done when building the filter.
[ "WithKeyPM", "creates", "a", "GCSBuilder", "with", "specified", "key", "and", "the", "passed", "probability", ".", "Estimated", "filter", "size", "is", "set", "to", "zero", "which", "means", "more", "reallocations", "are", "done", "when", "building", "the", "f...
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/gcs/builder/builder.go#L236-L238
27,574
btcsuite/btcutil
gcs/builder/builder.go
WithKeyHashPNM
func WithKeyHashPNM(keyHash *chainhash.Hash, p uint8, n uint32, m uint64) *GCSBuilder { return WithKeyPNM(DeriveKey(keyHash), p, n, m) }
go
func WithKeyHashPNM(keyHash *chainhash.Hash, p uint8, n uint32, m uint64) *GCSBuilder { return WithKeyPNM(DeriveKey(keyHash), p, n, m) }
[ "func", "WithKeyHashPNM", "(", "keyHash", "*", "chainhash", ".", "Hash", ",", "p", "uint8", ",", "n", "uint32", ",", "m", "uint64", ")", "*", "GCSBuilder", "{", "return", "WithKeyPNM", "(", "DeriveKey", "(", "keyHash", ")", ",", "p", ",", "n", ",", "...
// WithKeyHashPNM creates a GCSBuilder with key derived from the specified // chainhash.Hash and the passed probability and estimated filter size.
[ "WithKeyHashPNM", "creates", "a", "GCSBuilder", "with", "key", "derived", "from", "the", "specified", "chainhash", ".", "Hash", "and", "the", "passed", "probability", "and", "estimated", "filter", "size", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/gcs/builder/builder.go#L249-L253
27,575
btcsuite/btcutil
gcs/builder/builder.go
WithKeyHashPM
func WithKeyHashPM(keyHash *chainhash.Hash, p uint8, m uint64) *GCSBuilder { return WithKeyHashPNM(keyHash, p, 0, m) }
go
func WithKeyHashPM(keyHash *chainhash.Hash, p uint8, m uint64) *GCSBuilder { return WithKeyHashPNM(keyHash, p, 0, m) }
[ "func", "WithKeyHashPM", "(", "keyHash", "*", "chainhash", ".", "Hash", ",", "p", "uint8", ",", "m", "uint64", ")", "*", "GCSBuilder", "{", "return", "WithKeyHashPNM", "(", "keyHash", ",", "p", ",", "0", ",", "m", ")", "\n", "}" ]
// WithKeyHashPM creates a GCSBuilder with key derived from the specified // chainhash.Hash and the passed probability. Estimated filter size is set to // zero, which means more reallocations are done when building the filter.
[ "WithKeyHashPM", "creates", "a", "GCSBuilder", "with", "key", "derived", "from", "the", "specified", "chainhash", ".", "Hash", "and", "the", "passed", "probability", ".", "Estimated", "filter", "size", "is", "set", "to", "zero", "which", "means", "more", "real...
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/gcs/builder/builder.go#L258-L260
27,576
btcsuite/btcutil
gcs/builder/builder.go
WithRandomKeyPNM
func WithRandomKeyPNM(p uint8, n uint32, m uint64) *GCSBuilder { key, err := RandomKey() if err != nil { b := GCSBuilder{err: err} return &b } return WithKeyPNM(key, p, n, m) }
go
func WithRandomKeyPNM(p uint8, n uint32, m uint64) *GCSBuilder { key, err := RandomKey() if err != nil { b := GCSBuilder{err: err} return &b } return WithKeyPNM(key, p, n, m) }
[ "func", "WithRandomKeyPNM", "(", "p", "uint8", ",", "n", "uint32", ",", "m", "uint64", ")", "*", "GCSBuilder", "{", "key", ",", "err", ":=", "RandomKey", "(", ")", "\n", "if", "err", "!=", "nil", "{", "b", ":=", "GCSBuilder", "{", "err", ":", "err"...
// WithRandomKeyPNM creates a GCSBuilder with a cryptographically random key and // the passed probability and estimated filter size.
[ "WithRandomKeyPNM", "creates", "a", "GCSBuilder", "with", "a", "cryptographically", "random", "key", "and", "the", "passed", "probability", "and", "estimated", "filter", "size", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/gcs/builder/builder.go#L272-L279
27,577
btcsuite/btcutil
gcs/builder/builder.go
BuildBasicFilter
func BuildBasicFilter(block *wire.MsgBlock, prevOutScripts [][]byte) (*gcs.Filter, error) { blockHash := block.BlockHash() b := WithKeyHash(&blockHash) // If the filter had an issue with the specified key, then we force it // to bubble up here by calling the Key() function. _, err := b.Key() if err != nil { re...
go
func BuildBasicFilter(block *wire.MsgBlock, prevOutScripts [][]byte) (*gcs.Filter, error) { blockHash := block.BlockHash() b := WithKeyHash(&blockHash) // If the filter had an issue with the specified key, then we force it // to bubble up here by calling the Key() function. _, err := b.Key() if err != nil { re...
[ "func", "BuildBasicFilter", "(", "block", "*", "wire", ".", "MsgBlock", ",", "prevOutScripts", "[", "]", "[", "]", "byte", ")", "(", "*", "gcs", ".", "Filter", ",", "error", ")", "{", "blockHash", ":=", "block", ".", "BlockHash", "(", ")", "\n", "b",...
// BuildBasicFilter builds a basic GCS filter from a block. A basic GCS filter // will contain all the previous output scripts spent by inputs within a block, // as well as the data pushes within all the outputs created within a block.
[ "BuildBasicFilter", "builds", "a", "basic", "GCS", "filter", "from", "a", "block", ".", "A", "basic", "GCS", "filter", "will", "contain", "all", "the", "previous", "output", "scripts", "spent", "by", "inputs", "within", "a", "block", "as", "well", "as", "t...
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/gcs/builder/builder.go#L299-L342
27,578
btcsuite/btcutil
gcs/builder/builder.go
GetFilterHash
func GetFilterHash(filter *gcs.Filter) (chainhash.Hash, error) { filterData, err := filter.NBytes() if err != nil { return chainhash.Hash{}, err } return chainhash.DoubleHashH(filterData), nil }
go
func GetFilterHash(filter *gcs.Filter) (chainhash.Hash, error) { filterData, err := filter.NBytes() if err != nil { return chainhash.Hash{}, err } return chainhash.DoubleHashH(filterData), nil }
[ "func", "GetFilterHash", "(", "filter", "*", "gcs", ".", "Filter", ")", "(", "chainhash", ".", "Hash", ",", "error", ")", "{", "filterData", ",", "err", ":=", "filter", ".", "NBytes", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "chainhas...
// GetFilterHash returns the double-SHA256 of the filter.
[ "GetFilterHash", "returns", "the", "double", "-", "SHA256", "of", "the", "filter", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/gcs/builder/builder.go#L345-L352
27,579
btcsuite/btcutil
gcs/builder/builder.go
MakeHeaderForFilter
func MakeHeaderForFilter(filter *gcs.Filter, prevHeader chainhash.Hash) (chainhash.Hash, error) { filterTip := make([]byte, 2*chainhash.HashSize) filterHash, err := GetFilterHash(filter) if err != nil { return chainhash.Hash{}, err } // In the buffer we created above we'll compute hash || prevHash as an // int...
go
func MakeHeaderForFilter(filter *gcs.Filter, prevHeader chainhash.Hash) (chainhash.Hash, error) { filterTip := make([]byte, 2*chainhash.HashSize) filterHash, err := GetFilterHash(filter) if err != nil { return chainhash.Hash{}, err } // In the buffer we created above we'll compute hash || prevHash as an // int...
[ "func", "MakeHeaderForFilter", "(", "filter", "*", "gcs", ".", "Filter", ",", "prevHeader", "chainhash", ".", "Hash", ")", "(", "chainhash", ".", "Hash", ",", "error", ")", "{", "filterTip", ":=", "make", "(", "[", "]", "byte", ",", "2", "*", "chainhas...
// MakeHeaderForFilter makes a filter chain header for a filter, given the // filter and the previous filter chain header.
[ "MakeHeaderForFilter", "makes", "a", "filter", "chain", "header", "for", "a", "filter", "given", "the", "filter", "and", "the", "previous", "filter", "chain", "header", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/gcs/builder/builder.go#L356-L371
27,580
btcsuite/btcutil
block.go
Bytes
func (b *Block) Bytes() ([]byte, error) { // Return the cached serialized bytes if it has already been generated. if len(b.serializedBlock) != 0 { return b.serializedBlock, nil } // Serialize the MsgBlock. w := bytes.NewBuffer(make([]byte, 0, b.msgBlock.SerializeSize())) err := b.msgBlock.Serialize(w) if err ...
go
func (b *Block) Bytes() ([]byte, error) { // Return the cached serialized bytes if it has already been generated. if len(b.serializedBlock) != 0 { return b.serializedBlock, nil } // Serialize the MsgBlock. w := bytes.NewBuffer(make([]byte, 0, b.msgBlock.SerializeSize())) err := b.msgBlock.Serialize(w) if err ...
[ "func", "(", "b", "*", "Block", ")", "Bytes", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "// Return the cached serialized bytes if it has already been generated.", "if", "len", "(", "b", ".", "serializedBlock", ")", "!=", "0", "{", "return", "b...
// Bytes returns the serialized bytes for the Block. This is equivalent to // calling Serialize on the underlying wire.MsgBlock, however it caches the // result so subsequent calls are more efficient.
[ "Bytes", "returns", "the", "serialized", "bytes", "for", "the", "Block", ".", "This", "is", "equivalent", "to", "calling", "Serialize", "on", "the", "underlying", "wire", ".", "MsgBlock", "however", "it", "caches", "the", "result", "so", "subsequent", "calls",...
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/block.go#L53-L70
27,581
btcsuite/btcutil
block.go
BytesNoWitness
func (b *Block) BytesNoWitness() ([]byte, error) { // Return the cached serialized bytes if it has already been generated. if len(b.serializedBlockNoWitness) != 0 { return b.serializedBlockNoWitness, nil } // Serialize the MsgBlock. var w bytes.Buffer err := b.msgBlock.SerializeNoWitness(&w) if err != nil { ...
go
func (b *Block) BytesNoWitness() ([]byte, error) { // Return the cached serialized bytes if it has already been generated. if len(b.serializedBlockNoWitness) != 0 { return b.serializedBlockNoWitness, nil } // Serialize the MsgBlock. var w bytes.Buffer err := b.msgBlock.SerializeNoWitness(&w) if err != nil { ...
[ "func", "(", "b", "*", "Block", ")", "BytesNoWitness", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "// Return the cached serialized bytes if it has already been generated.", "if", "len", "(", "b", ".", "serializedBlockNoWitness", ")", "!=", "0", "{"...
// BytesNoWitness returns the serialized bytes for the block with transactions // encoded without any witness data.
[ "BytesNoWitness", "returns", "the", "serialized", "bytes", "for", "the", "block", "with", "transactions", "encoded", "without", "any", "witness", "data", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/block.go#L74-L91
27,582
btcsuite/btcutil
block.go
Hash
func (b *Block) Hash() *chainhash.Hash { // Return the cached block hash if it has already been generated. if b.blockHash != nil { return b.blockHash } // Cache the block hash and return it. hash := b.msgBlock.BlockHash() b.blockHash = &hash return &hash }
go
func (b *Block) Hash() *chainhash.Hash { // Return the cached block hash if it has already been generated. if b.blockHash != nil { return b.blockHash } // Cache the block hash and return it. hash := b.msgBlock.BlockHash() b.blockHash = &hash return &hash }
[ "func", "(", "b", "*", "Block", ")", "Hash", "(", ")", "*", "chainhash", ".", "Hash", "{", "// Return the cached block hash if it has already been generated.", "if", "b", ".", "blockHash", "!=", "nil", "{", "return", "b", ".", "blockHash", "\n", "}", "\n\n", ...
// Hash returns the block identifier hash for the Block. This is equivalent to // calling BlockHash on the underlying wire.MsgBlock, however it caches the // result so subsequent calls are more efficient.
[ "Hash", "returns", "the", "block", "identifier", "hash", "for", "the", "Block", ".", "This", "is", "equivalent", "to", "calling", "BlockHash", "on", "the", "underlying", "wire", ".", "MsgBlock", "however", "it", "caches", "the", "result", "so", "subsequent", ...
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/block.go#L96-L106
27,583
btcsuite/btcutil
block.go
TxHash
func (b *Block) TxHash(txNum int) (*chainhash.Hash, error) { // Attempt to get a wrapped transaction for the specified index. It // will be created lazily if needed or simply return the cached version // if it has already been generated. tx, err := b.Tx(txNum) if err != nil { return nil, err } // Defer to th...
go
func (b *Block) TxHash(txNum int) (*chainhash.Hash, error) { // Attempt to get a wrapped transaction for the specified index. It // will be created lazily if needed or simply return the cached version // if it has already been generated. tx, err := b.Tx(txNum) if err != nil { return nil, err } // Defer to th...
[ "func", "(", "b", "*", "Block", ")", "TxHash", "(", "txNum", "int", ")", "(", "*", "chainhash", ".", "Hash", ",", "error", ")", "{", "// Attempt to get a wrapped transaction for the specified index. It", "// will be created lazily if needed or simply return the cached vers...
// TxHash returns the hash for the requested transaction number in the Block. // The supplied index is 0 based. That is to say, the first transaction in the // block is txNum 0. This is equivalent to calling TxHash on the underlying // wire.MsgTx, however it caches the result so subsequent calls are more // efficient...
[ "TxHash", "returns", "the", "hash", "for", "the", "requested", "transaction", "number", "in", "the", "Block", ".", "The", "supplied", "index", "is", "0", "based", ".", "That", "is", "to", "say", "the", "first", "transaction", "in", "the", "block", "is", ...
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/block.go#L176-L188
27,584
btcsuite/btcutil
block.go
TxLoc
func (b *Block) TxLoc() ([]wire.TxLoc, error) { rawMsg, err := b.Bytes() if err != nil { return nil, err } rbuf := bytes.NewBuffer(rawMsg) var mblock wire.MsgBlock txLocs, err := mblock.DeserializeTxLoc(rbuf) if err != nil { return nil, err } return txLocs, err }
go
func (b *Block) TxLoc() ([]wire.TxLoc, error) { rawMsg, err := b.Bytes() if err != nil { return nil, err } rbuf := bytes.NewBuffer(rawMsg) var mblock wire.MsgBlock txLocs, err := mblock.DeserializeTxLoc(rbuf) if err != nil { return nil, err } return txLocs, err }
[ "func", "(", "b", "*", "Block", ")", "TxLoc", "(", ")", "(", "[", "]", "wire", ".", "TxLoc", ",", "error", ")", "{", "rawMsg", ",", "err", ":=", "b", ".", "Bytes", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", ...
// TxLoc returns the offsets and lengths of each transaction in a raw block. // It is used to allow fast indexing into transactions within the raw byte // stream.
[ "TxLoc", "returns", "the", "offsets", "and", "lengths", "of", "each", "transaction", "in", "a", "raw", "block", ".", "It", "is", "used", "to", "allow", "fast", "indexing", "into", "transactions", "within", "the", "raw", "byte", "stream", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/block.go#L193-L206
27,585
btcsuite/btcutil
block.go
NewBlock
func NewBlock(msgBlock *wire.MsgBlock) *Block { return &Block{ msgBlock: msgBlock, blockHeight: BlockHeightUnknown, } }
go
func NewBlock(msgBlock *wire.MsgBlock) *Block { return &Block{ msgBlock: msgBlock, blockHeight: BlockHeightUnknown, } }
[ "func", "NewBlock", "(", "msgBlock", "*", "wire", ".", "MsgBlock", ")", "*", "Block", "{", "return", "&", "Block", "{", "msgBlock", ":", "msgBlock", ",", "blockHeight", ":", "BlockHeightUnknown", ",", "}", "\n", "}" ]
// NewBlock returns a new instance of a bitcoin block given an underlying // wire.MsgBlock. See Block.
[ "NewBlock", "returns", "a", "new", "instance", "of", "a", "bitcoin", "block", "given", "an", "underlying", "wire", ".", "MsgBlock", ".", "See", "Block", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/block.go#L221-L226
27,586
btcsuite/btcutil
block.go
NewBlockFromBytes
func NewBlockFromBytes(serializedBlock []byte) (*Block, error) { br := bytes.NewReader(serializedBlock) b, err := NewBlockFromReader(br) if err != nil { return nil, err } b.serializedBlock = serializedBlock return b, nil }
go
func NewBlockFromBytes(serializedBlock []byte) (*Block, error) { br := bytes.NewReader(serializedBlock) b, err := NewBlockFromReader(br) if err != nil { return nil, err } b.serializedBlock = serializedBlock return b, nil }
[ "func", "NewBlockFromBytes", "(", "serializedBlock", "[", "]", "byte", ")", "(", "*", "Block", ",", "error", ")", "{", "br", ":=", "bytes", ".", "NewReader", "(", "serializedBlock", ")", "\n", "b", ",", "err", ":=", "NewBlockFromReader", "(", "br", ")", ...
// NewBlockFromBytes returns a new instance of a bitcoin block given the // serialized bytes. See Block.
[ "NewBlockFromBytes", "returns", "a", "new", "instance", "of", "a", "bitcoin", "block", "given", "the", "serialized", "bytes", ".", "See", "Block", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/block.go#L230-L238
27,587
btcsuite/btcutil
block.go
NewBlockFromReader
func NewBlockFromReader(r io.Reader) (*Block, error) { // Deserialize the bytes into a MsgBlock. var msgBlock wire.MsgBlock err := msgBlock.Deserialize(r) if err != nil { return nil, err } b := Block{ msgBlock: &msgBlock, blockHeight: BlockHeightUnknown, } return &b, nil }
go
func NewBlockFromReader(r io.Reader) (*Block, error) { // Deserialize the bytes into a MsgBlock. var msgBlock wire.MsgBlock err := msgBlock.Deserialize(r) if err != nil { return nil, err } b := Block{ msgBlock: &msgBlock, blockHeight: BlockHeightUnknown, } return &b, nil }
[ "func", "NewBlockFromReader", "(", "r", "io", ".", "Reader", ")", "(", "*", "Block", ",", "error", ")", "{", "// Deserialize the bytes into a MsgBlock.", "var", "msgBlock", "wire", ".", "MsgBlock", "\n", "err", ":=", "msgBlock", ".", "Deserialize", "(", "r", ...
// NewBlockFromReader returns a new instance of a bitcoin block given a // Reader to deserialize the block. See Block.
[ "NewBlockFromReader", "returns", "a", "new", "instance", "of", "a", "bitcoin", "block", "given", "a", "Reader", "to", "deserialize", "the", "block", ".", "See", "Block", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/block.go#L242-L255
27,588
btcsuite/btcutil
block.go
NewBlockFromBlockAndBytes
func NewBlockFromBlockAndBytes(msgBlock *wire.MsgBlock, serializedBlock []byte) *Block { return &Block{ msgBlock: msgBlock, serializedBlock: serializedBlock, blockHeight: BlockHeightUnknown, } }
go
func NewBlockFromBlockAndBytes(msgBlock *wire.MsgBlock, serializedBlock []byte) *Block { return &Block{ msgBlock: msgBlock, serializedBlock: serializedBlock, blockHeight: BlockHeightUnknown, } }
[ "func", "NewBlockFromBlockAndBytes", "(", "msgBlock", "*", "wire", ".", "MsgBlock", ",", "serializedBlock", "[", "]", "byte", ")", "*", "Block", "{", "return", "&", "Block", "{", "msgBlock", ":", "msgBlock", ",", "serializedBlock", ":", "serializedBlock", ",",...
// NewBlockFromBlockAndBytes returns a new instance of a bitcoin block given // an underlying wire.MsgBlock and the serialized bytes for it. See Block.
[ "NewBlockFromBlockAndBytes", "returns", "a", "new", "instance", "of", "a", "bitcoin", "block", "given", "an", "underlying", "wire", ".", "MsgBlock", "and", "the", "serialized", "bytes", "for", "it", ".", "See", "Block", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/block.go#L259-L265
27,589
btcsuite/btcutil
base58/base58.go
Decode
func Decode(b string) []byte { answer := big.NewInt(0) j := big.NewInt(1) scratch := new(big.Int) for i := len(b) - 1; i >= 0; i-- { tmp := b58[b[i]] if tmp == 255 { return []byte("") } scratch.SetInt64(int64(tmp)) scratch.Mul(j, scratch) answer.Add(answer, scratch) j.Mul(j, bigRadix) } tmpval ...
go
func Decode(b string) []byte { answer := big.NewInt(0) j := big.NewInt(1) scratch := new(big.Int) for i := len(b) - 1; i >= 0; i-- { tmp := b58[b[i]] if tmp == 255 { return []byte("") } scratch.SetInt64(int64(tmp)) scratch.Mul(j, scratch) answer.Add(answer, scratch) j.Mul(j, bigRadix) } tmpval ...
[ "func", "Decode", "(", "b", "string", ")", "[", "]", "byte", "{", "answer", ":=", "big", ".", "NewInt", "(", "0", ")", "\n", "j", ":=", "big", ".", "NewInt", "(", "1", ")", "\n\n", "scratch", ":=", "new", "(", "big", ".", "Int", ")", "\n", "f...
// Decode decodes a modified base58 string to a byte slice.
[ "Decode", "decodes", "a", "modified", "base58", "string", "to", "a", "byte", "slice", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/base58/base58.go#L17-L46
27,590
btcsuite/btcutil
wif.go
NewWIF
func NewWIF(privKey *btcec.PrivateKey, net *chaincfg.Params, compress bool) (*WIF, error) { if net == nil { return nil, errors.New("no network") } return &WIF{privKey, compress, net.PrivateKeyID}, nil }
go
func NewWIF(privKey *btcec.PrivateKey, net *chaincfg.Params, compress bool) (*WIF, error) { if net == nil { return nil, errors.New("no network") } return &WIF{privKey, compress, net.PrivateKeyID}, nil }
[ "func", "NewWIF", "(", "privKey", "*", "btcec", ".", "PrivateKey", ",", "net", "*", "chaincfg", ".", "Params", ",", "compress", "bool", ")", "(", "*", "WIF", ",", "error", ")", "{", "if", "net", "==", "nil", "{", "return", "nil", ",", "errors", "."...
// NewWIF creates a new WIF structure to export an address and its private key // as a string encoded in the Wallet Import Format. The compress argument // specifies whether the address intended to be imported or exported was created // by serializing the public key compressed rather than uncompressed.
[ "NewWIF", "creates", "a", "new", "WIF", "structure", "to", "export", "an", "address", "and", "its", "private", "key", "as", "a", "string", "encoded", "in", "the", "Wallet", "Import", "Format", ".", "The", "compress", "argument", "specifies", "whether", "the"...
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/wif.go#L52-L57
27,591
btcsuite/btcutil
wif.go
IsForNet
func (w *WIF) IsForNet(net *chaincfg.Params) bool { return w.netID == net.PrivateKeyID }
go
func (w *WIF) IsForNet(net *chaincfg.Params) bool { return w.netID == net.PrivateKeyID }
[ "func", "(", "w", "*", "WIF", ")", "IsForNet", "(", "net", "*", "chaincfg", ".", "Params", ")", "bool", "{", "return", "w", ".", "netID", "==", "net", ".", "PrivateKeyID", "\n", "}" ]
// IsForNet returns whether or not the decoded WIF structure is associated // with the passed bitcoin network.
[ "IsForNet", "returns", "whether", "or", "not", "the", "decoded", "WIF", "structure", "is", "associated", "with", "the", "passed", "bitcoin", "network", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/wif.go#L61-L63
27,592
btcsuite/btcutil
wif.go
SerializePubKey
func (w *WIF) SerializePubKey() []byte { pk := (*btcec.PublicKey)(&w.PrivKey.PublicKey) if w.CompressPubKey { return pk.SerializeCompressed() } return pk.SerializeUncompressed() }
go
func (w *WIF) SerializePubKey() []byte { pk := (*btcec.PublicKey)(&w.PrivKey.PublicKey) if w.CompressPubKey { return pk.SerializeCompressed() } return pk.SerializeUncompressed() }
[ "func", "(", "w", "*", "WIF", ")", "SerializePubKey", "(", ")", "[", "]", "byte", "{", "pk", ":=", "(", "*", "btcec", ".", "PublicKey", ")", "(", "&", "w", ".", "PrivKey", ".", "PublicKey", ")", "\n", "if", "w", ".", "CompressPubKey", "{", "retur...
// SerializePubKey serializes the associated public key of the imported or // exported private key in either a compressed or uncompressed format. The // serialization format chosen depends on the value of w.CompressPubKey.
[ "SerializePubKey", "serializes", "the", "associated", "public", "key", "of", "the", "imported", "or", "exported", "private", "key", "in", "either", "a", "compressed", "or", "uncompressed", "format", ".", "The", "serialization", "format", "chosen", "depends", "on",...
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/wif.go#L153-L159
27,593
btcsuite/btcutil
bech32/bech32.go
Decode
func Decode(bech string) (string, []byte, error) { // The maximum allowed length for a bech32 string is 90. It must also // be at least 8 characters, since it needs a non-empty HRP, a // separator, and a 6 character checksum. if len(bech) < 8 || len(bech) > 90 { return "", nil, fmt.Errorf("invalid bech32 string l...
go
func Decode(bech string) (string, []byte, error) { // The maximum allowed length for a bech32 string is 90. It must also // be at least 8 characters, since it needs a non-empty HRP, a // separator, and a 6 character checksum. if len(bech) < 8 || len(bech) > 90 { return "", nil, fmt.Errorf("invalid bech32 string l...
[ "func", "Decode", "(", "bech", "string", ")", "(", "string", ",", "[", "]", "byte", ",", "error", ")", "{", "// The maximum allowed length for a bech32 string is 90. It must also", "// be at least 8 characters, since it needs a non-empty HRP, a", "// separator, and a 6 character ...
// Decode decodes a bech32 encoded string, returning the human-readable // part and the data part excluding the checksum.
[ "Decode", "decodes", "a", "bech32", "encoded", "string", "returning", "the", "human", "-", "readable", "part", "and", "the", "data", "part", "excluding", "the", "checksum", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/bech32/bech32.go#L18-L80
27,594
btcsuite/btcutil
bech32/bech32.go
ConvertBits
func ConvertBits(data []byte, fromBits, toBits uint8, pad bool) ([]byte, error) { if fromBits < 1 || fromBits > 8 || toBits < 1 || toBits > 8 { return nil, fmt.Errorf("only bit groups between 1 and 8 allowed") } // The final bytes, each byte encoding toBits bits. var regrouped []byte // Keep track of the next ...
go
func ConvertBits(data []byte, fromBits, toBits uint8, pad bool) ([]byte, error) { if fromBits < 1 || fromBits > 8 || toBits < 1 || toBits > 8 { return nil, fmt.Errorf("only bit groups between 1 and 8 allowed") } // The final bytes, each byte encoding toBits bits. var regrouped []byte // Keep track of the next ...
[ "func", "ConvertBits", "(", "data", "[", "]", "byte", ",", "fromBits", ",", "toBits", "uint8", ",", "pad", "bool", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "fromBits", "<", "1", "||", "fromBits", ">", "8", "||", "toBits", "<", "1...
// ConvertBits converts a byte slice where each byte is encoding fromBits bits, // to a byte slice where each byte is encoding toBits bits.
[ "ConvertBits", "converts", "a", "byte", "slice", "where", "each", "byte", "is", "encoding", "fromBits", "bits", "to", "a", "byte", "slice", "where", "each", "byte", "is", "encoding", "toBits", "bits", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/bech32/bech32.go#L131-L196
27,595
btcsuite/btcutil
tx.go
Hash
func (t *Tx) Hash() *chainhash.Hash { // Return the cached hash if it has already been generated. if t.txHash != nil { return t.txHash } // Cache the hash and return it. hash := t.msgTx.TxHash() t.txHash = &hash return &hash }
go
func (t *Tx) Hash() *chainhash.Hash { // Return the cached hash if it has already been generated. if t.txHash != nil { return t.txHash } // Cache the hash and return it. hash := t.msgTx.TxHash() t.txHash = &hash return &hash }
[ "func", "(", "t", "*", "Tx", ")", "Hash", "(", ")", "*", "chainhash", ".", "Hash", "{", "// Return the cached hash if it has already been generated.", "if", "t", ".", "txHash", "!=", "nil", "{", "return", "t", ".", "txHash", "\n", "}", "\n\n", "// Cache the ...
// Hash returns the hash of the transaction. This is equivalent to // calling TxHash on the underlying wire.MsgTx, however it caches the // result so subsequent calls are more efficient.
[ "Hash", "returns", "the", "hash", "of", "the", "transaction", ".", "This", "is", "equivalent", "to", "calling", "TxHash", "on", "the", "underlying", "wire", ".", "MsgTx", "however", "it", "caches", "the", "result", "so", "subsequent", "calls", "are", "more",...
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/tx.go#L41-L51
27,596
btcsuite/btcutil
tx.go
HasWitness
func (t *Tx) HasWitness() bool { if t.txHashWitness != nil { return *t.txHasWitness } hasWitness := t.msgTx.HasWitness() t.txHasWitness = &hasWitness return hasWitness }
go
func (t *Tx) HasWitness() bool { if t.txHashWitness != nil { return *t.txHasWitness } hasWitness := t.msgTx.HasWitness() t.txHasWitness = &hasWitness return hasWitness }
[ "func", "(", "t", "*", "Tx", ")", "HasWitness", "(", ")", "bool", "{", "if", "t", ".", "txHashWitness", "!=", "nil", "{", "return", "*", "t", ".", "txHasWitness", "\n", "}", "\n\n", "hasWitness", ":=", "t", ".", "msgTx", ".", "HasWitness", "(", ")"...
// HasWitness returns false if none of the inputs within the transaction // contain witness data, true false otherwise. This equivalent to calling // HasWitness on the underlying wire.MsgTx, however it caches the result so // subsequent calls are more efficient.
[ "HasWitness", "returns", "false", "if", "none", "of", "the", "inputs", "within", "the", "transaction", "contain", "witness", "data", "true", "false", "otherwise", ".", "This", "equivalent", "to", "calling", "HasWitness", "on", "the", "underlying", "wire", ".", ...
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/tx.go#L72-L80
27,597
btcsuite/btcutil
tx.go
NewTx
func NewTx(msgTx *wire.MsgTx) *Tx { return &Tx{ msgTx: msgTx, txIndex: TxIndexUnknown, } }
go
func NewTx(msgTx *wire.MsgTx) *Tx { return &Tx{ msgTx: msgTx, txIndex: TxIndexUnknown, } }
[ "func", "NewTx", "(", "msgTx", "*", "wire", ".", "MsgTx", ")", "*", "Tx", "{", "return", "&", "Tx", "{", "msgTx", ":", "msgTx", ",", "txIndex", ":", "TxIndexUnknown", ",", "}", "\n", "}" ]
// NewTx returns a new instance of a bitcoin transaction given an underlying // wire.MsgTx. See Tx.
[ "NewTx", "returns", "a", "new", "instance", "of", "a", "bitcoin", "transaction", "given", "an", "underlying", "wire", ".", "MsgTx", ".", "See", "Tx", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/tx.go#L95-L100
27,598
btcsuite/btcutil
tx.go
NewTxFromBytes
func NewTxFromBytes(serializedTx []byte) (*Tx, error) { br := bytes.NewReader(serializedTx) return NewTxFromReader(br) }
go
func NewTxFromBytes(serializedTx []byte) (*Tx, error) { br := bytes.NewReader(serializedTx) return NewTxFromReader(br) }
[ "func", "NewTxFromBytes", "(", "serializedTx", "[", "]", "byte", ")", "(", "*", "Tx", ",", "error", ")", "{", "br", ":=", "bytes", ".", "NewReader", "(", "serializedTx", ")", "\n", "return", "NewTxFromReader", "(", "br", ")", "\n", "}" ]
// NewTxFromBytes returns a new instance of a bitcoin transaction given the // serialized bytes. See Tx.
[ "NewTxFromBytes", "returns", "a", "new", "instance", "of", "a", "bitcoin", "transaction", "given", "the", "serialized", "bytes", ".", "See", "Tx", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/tx.go#L104-L107
27,599
btcsuite/btcutil
tx.go
NewTxFromReader
func NewTxFromReader(r io.Reader) (*Tx, error) { // Deserialize the bytes into a MsgTx. var msgTx wire.MsgTx err := msgTx.Deserialize(r) if err != nil { return nil, err } t := Tx{ msgTx: &msgTx, txIndex: TxIndexUnknown, } return &t, nil }
go
func NewTxFromReader(r io.Reader) (*Tx, error) { // Deserialize the bytes into a MsgTx. var msgTx wire.MsgTx err := msgTx.Deserialize(r) if err != nil { return nil, err } t := Tx{ msgTx: &msgTx, txIndex: TxIndexUnknown, } return &t, nil }
[ "func", "NewTxFromReader", "(", "r", "io", ".", "Reader", ")", "(", "*", "Tx", ",", "error", ")", "{", "// Deserialize the bytes into a MsgTx.", "var", "msgTx", "wire", ".", "MsgTx", "\n", "err", ":=", "msgTx", ".", "Deserialize", "(", "r", ")", "\n", "i...
// NewTxFromReader returns a new instance of a bitcoin transaction given a // Reader to deserialize the transaction. See Tx.
[ "NewTxFromReader", "returns", "a", "new", "instance", "of", "a", "bitcoin", "transaction", "given", "a", "Reader", "to", "deserialize", "the", "transaction", ".", "See", "Tx", "." ]
9e5f4b9a998d263e3ce9c56664a7816001ac8000
https://github.com/btcsuite/btcutil/blob/9e5f4b9a998d263e3ce9c56664a7816001ac8000/tx.go#L111-L124