MCPcopy Create free account
hub / github.com/btcsuite/btcd / Address

Method Address

txscript/pkscript.go:159–170  ·  view source on GitHub ↗

Address encodes the script into an address for the given chain.

(chainParams *chaincfg.Params)

Source from the content-addressed store, hash-verified

157
158// Address encodes the script into an address for the given chain.
159func (s PkScript) Address(chainParams *chaincfg.Params) (address.Address, error) {
160 _, addrs, _, err := ExtractPkScriptAddrs(s.Script(), chainParams)
161 if err != nil {
162 return nil, fmt.Errorf("unable to parse address: %v", err)
163 }
164
165 if len(addrs) == 0 {
166 return nil, fmt.Errorf("script does not have an associated address")
167 }
168
169 return addrs[0], nil
170}
171
172// String returns a hex-encoded string representation of the script.
173func (s PkScript) String() string {

Callers 1

rescanBlockFunction · 0.45

Calls 2

ScriptMethod · 0.95
ExtractPkScriptAddrsFunction · 0.85

Tested by

no test coverage detected