Documentation
¶
Index ¶
- func Address(publicKey *bsvec.PublicKey) (*bsvutil.LegacyAddressPubKeyHash, error)
- func AddressFromPrivateKey(privateKey string) (string, error)
- func HexDecode(str string) []byte
- func PrivateKey(privKey string) (ecdsaPrivKey *bsvec.PrivateKey)
- func SignMessage(privKey string, message string) string
- func ValidA58(a58 []byte) (bool, error)
- func VerifyMessage(address, signature, data string) error
- type A25
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Address ¶
func Address(publicKey *bsvec.PublicKey) (*bsvutil.LegacyAddressPubKeyHash, error)
Address gets a bsvutil.LegacyAddressPubKeyHash
func AddressFromPrivateKey ¶
AddressFromPrivateKey takes a private key string and returns a Bitcoin address
func HexDecode ¶
HexDecode returns a decoded hex string without handling errors todo: why ignore the error? (@mrz)
func PrivateKey ¶
func PrivateKey(privKey string) (ecdsaPrivKey *bsvec.PrivateKey)
PrivateKey turns a private key string into an bsvec.PrivateKey
func SignMessage ¶
SignMessage signs a string with the provided private key using Bitcoin Signed Message encoding
func ValidA58 ¶
ValidA58 validates a base58 encoded bitcoin address. An address is valid if it can be decoded into a 25 byte address, the version number is 0, and the checksum validates. Return value ok will be true for valid addresses. If ok is false, the address is invalid and the error value may indicate why.
Example ¶
ExampleValidA58 example using ValidA58()
valid, err := ValidA58([]byte("1KCEAmVS6FFggtc7W9as7sEENvjt7DqMi2"))
if err != nil {
fmt.Printf("error occurred: %s", err.Error())
return
} else if !valid {
fmt.Printf("address is not valid: %s", "1KCEAmVS6FFggtc7W9as7sEENvjt7DqMi2")
return
} else {
fmt.Printf("address is valid!")
}
Output: address is valid!
func VerifyMessage ¶
VerifyMessage verifies a string and address against the provided signature and assumes Bitcoin Signed Message encoding
Types ¶
type A25 ¶
type A25 [25]byte
A25 is a type for a 25 byte (not base58 encoded) bitcoin address.
func (*A25) ComputeChecksum ¶
ComputeChecksum returns a four byte checksum computed from the first 21 bytes of the address. The embedded checksum is not updated.
func (*A25) EmbeddedChecksum ¶
EmbeddedChecksum returns the 4 checksum bytes of a A25 address