Address encodes the script into an address for the given chain.
(chainParams *chaincfg.Params)
| 157 | |
| 158 | // Address encodes the script into an address for the given chain. |
| 159 | func (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. |
| 173 | func (s PkScript) String() string { |
no test coverage detected