Documentation ¶
Index ¶
- Constants
- Variables
- func AddressCheck(addr string, symbol string) (bool, error)
- func AddressDecode(address string, addresstype AddressType) ([]byte, error)
- func AddressEncode(hash []byte, addresstype AddressType) string
- func Base58Decode(input string, alphabet *Base58Alphabet) ([]byte, error)
- func Base58Encode(input []byte, alphabet *Base58Alphabet) string
- func CRC32(s []byte) []byte
- type AddressType
- type Base58Alphabet
- type CorruptInputError
- type Encoding
- func (enc *Encoding) Base64Decode(s string) ([]byte, error)
- func (enc *Encoding) Base64Encode(src []byte) string
- func (enc *Encoding) Decode(dst, src []byte) (n int, err error)
- func (enc *Encoding) DecodedLen(n int) int
- func (enc *Encoding) Encode(dst, src []byte)
- func (enc *Encoding) EncodedLen(n int) int
Constants ¶
const ( StdPadding rune = '=' // Standard padding character NoPadding rune = -1 // No padding )
const ( EOSPublicKeyPrefix = "PUB_" EOSPublicKeyK1Prefix = "PUB_K1_" EOSPublicKeyR1Prefix = "PUB_R1_" EOSPublicKeyPrefixCompat = "EOS" )
Variables ¶
var ( ErrorInvalidHashLength = errors.New("Invalid hash length!") ErrorInvalidAddress = errors.New("Invalid address!") )
var ( //BTC stuff BTC_mainnetAddressP2PKH = AddressType{"base58", btcAlphabet, "doubleSHA256", "h160", 20, []byte{0x00}, nil} BTC_mainnetAddressP2SH = AddressType{"base58", btcAlphabet, "doubleSHA256", "h160", 20, []byte{0x05}, nil} BTC_mainnetAddressBech32V0 = AddressType{"bech32", btcBech32Alphabet, "bc", "h160", 20, nil, nil} BTC_mainnetPrivateWIF = AddressType{"base58", btcAlphabet, "doubleSHA256", "", 32, []byte{0x80}, nil} BTC_mainnetPrivateWIFCompressed = AddressType{"base58", btcAlphabet, "doubleSHA256", "", 32, []byte{0x80}, []byte{0x01}} BTC_mainnetPublicBIP32 = AddressType{"base58", btcAlphabet, "doubleSHA256", "", 74, []byte{0x04, 0x88, 0xB2, 0x1E}, nil} BTC_mainnetPrivateBIP32 = AddressType{"base58", btcAlphabet, "doubleSHA256", "", 74, []byte{0x04, 0x88, 0xAD, 0xE4}, nil} BTC_testnetAddressP2PKH = AddressType{"base58", btcAlphabet, "doubleSHA256", "h160", 20, []byte{0x6F}, nil} BTC_testnetAddressP2SH = AddressType{"base58", btcAlphabet, "doubleSHA256", "h160", 20, []byte{0xC4}, nil} BTC_testnetAddressBech32V0 = AddressType{"bech32", btcBech32Alphabet, "tb", "h160", 20, nil, nil} BTC_testnetPrivateWIF = AddressType{"base58", btcAlphabet, "doubleSHA256", "", 32, []byte{0xEF}, nil} BTC_testnetPrivateWIFCompressed = AddressType{"base58", btcAlphabet, "doubleSHA256", "", 32, []byte{0xEF}, []byte{0x01}} BTC_testnetPublicBIP32 = AddressType{"base58", btcAlphabet, "doubleSHA256", "", 74, []byte{0x04, 0x35, 0x87, 0xCF}, nil} BTC_testnetPrivateBIP32 = AddressType{"base58", btcAlphabet, "doubleSHA256", "", 74, []byte{0x04, 0x35, 0x83, 0x94}, nil} //XMR stuff XMR_mainnetPublicAddress = AddressType{"XMR", xmrAlphabet, "keccak256", "", 64, []byte{0x12}, nil} XMR_mainnetPublicSubAddress = AddressType{"XMR", xmrAlphabet, "keccak256", "", 64, []byte{0x2A}, nil} XMR_mainnetPublicIntegratedAddress = AddressType{"XMR", xmrAlphabet, "keccak256", "payID", 72, []byte{0x13}, nil} XMR_testnetPublicAddress = AddressType{"XMR", xmrAlphabet, "keccak256", "", 64, []byte{0x35}, nil} XMR_testnetPublicSubAddress = AddressType{"XMR", xmrAlphabet, "keccak256", "", 64, []byte{0x3f}, nil} XMR_testnetPublicIntegratedAddress = AddressType{"XMR", xmrAlphabet, "keccak256", "payID", 72, []byte{0x36}, nil} //DOGE stuff //DOGE_singleSignAddressP2PKH = AddressType{"base58", btcAlphabet, "doubleSHA256", "h160", 20, []byte{0x16}, nil} DOGE_multiSignAddressP2PKH = AddressType{"base58", btcAlphabet, "doubleSHA256", "h160", 20, []byte{0x16}, nil} //ONT stuff ONT_Address = AddressType{"base58", ontAlphabet, "doubleSHA256", "h160", 20, []byte{0x16}, nil} //XRP stuff XRP_Address = AddressType{"base58", xrpAlphabet, "doubleSHA256", "h160", 20, []byte{0x00}, nil} //BTM stuff BTM_mainnetAddressBech32V0 = AddressType{"bech32", btcBech32Alphabet, "bm", "h160", 20, nil, nil} BTM_testnetAddressBech32V0 = AddressType{"bech32", btcBech32Alphabet, "tm", "h160", 20, nil, nil} //ZEC stuff ZEC_mainnet_t_AddressP2PKH = AddressType{"base58", zecAlphabet, "doubleSHA256", "h160", 20, []byte{0x1C, 0xB8}, nil} ZEC_mainnet_t_AddressP2SH = AddressType{"base58", zecAlphabet, "doubleSHA256", "h160", 20, []byte{0x1C, 0xBD}, nil} ZEC_testnet_t_AddressP2PKH = AddressType{"base58", zecAlphabet, "doubleSHA256", "h160", 20, []byte{0x1D, 0x25}, nil} ZEC_testnet_t_AddressP2SH = AddressType{"base58", zecAlphabet, "doubleSHA256", "h160", 20, []byte{0x1C, 0xBA}, nil} //LTC stuff LTC_mainnetAddressP2PKH = AddressType{"base58", ltcAlphabet, "doubleSHA256", "h160", 20, []byte{0x30}, nil} LTC_mainnetAddressP2SH = AddressType{"base58", ltcAlphabet, "doubleSHA256", "h160", 20, []byte{0x05}, nil} LTC_mainnetAddressP2SH2 = AddressType{"base58", ltcAlphabet, "doubleSHA256", "h160", 20, []byte{0x32}, nil} LTC_mainnetAddressBech32V0 = AddressType{"bech32", ltcBech32Alphabet, "ltc", "h160", 20, nil, nil} LTC_mainnetPrivateWIF = AddressType{"base58", ltcAlphabet, "doubleSHA256", "", 32, []byte{0xB0}, nil} LTC_mainnetPrivateWIFCompressed = AddressType{"base58", ltcAlphabet, "doubleSHA256", "", 32, []byte{0xB0}, []byte{0x01}} LTC_mainnetPublicBIP32 = AddressType{"base58", btcAlphabet, "doubleSHA256", "", 74, []byte{0x04, 0x88, 0xB2, 0x1E}, nil} LTC_mainnetPrivateBIP32 = AddressType{"base58", btcAlphabet, "doubleSHA256", "", 74, []byte{0x04, 0x88, 0xAD, 0xE4}, nil} LTC_testnetAddressP2PKH = AddressType{"base58", ltcAlphabet, "doubleSHA256", "h160", 20, []byte{0x6F}, nil} LTC_testnetAddressP2SH = AddressType{"base58", ltcAlphabet, "doubleSHA256", "h160", 20, []byte{0xC4}, nil} LTC_testnetAddressP2SH2 = AddressType{"base58", ltcAlphabet, "doubleSHA256", "h160", 20, []byte{0x3A}, nil} LTC_testnetAddressBech32V0 = AddressType{"bech32", ltcBech32Alphabet, "tltc", "h160", 20, nil, nil} LTC_testnetPrivateWIF = AddressType{"base58", ltcAlphabet, "doubleSHA256", "", 32, []byte{0xEF}, nil} LTC_testnetPrivateWIFCompressed = AddressType{"base58", ltcAlphabet, "doubleSHA256", "", 32, []byte{0xEF}, []byte{0x01}} LTC_testnetPublicBIP32 = AddressType{"base58", btcAlphabet, "doubleSHA256", "", 74, []byte{0x04, 0x35, 0x87, 0xCF}, nil} LTC_testnetPrivateBIP32 = AddressType{"base58", btcAlphabet, "doubleSHA256", "", 74, []byte{0x04, 0x35, 0x83, 0x94}, nil} //BCH stuff BCH_mainnetAddressLegacy = AddressType{"base58", bchLegacyAlphabet, "doubleSHA256", "h160", 20, []byte{0x00}, nil} BCH_mainnetAddressCash = AddressType{"base32PolyMod", bchCashAlphabet, "bitcoincash", "h160", 21, nil, nil} //XTZ stuff XTZ_mainnetAddress_tz1 = AddressType{"base58", xtzAlphabet, "doubleSHA256", "blake2b160", 20, []byte{0x06, 0xA1, 0x9F}, nil} XTZ_mainnetAddress_tz2 = AddressType{"base58", xtzAlphabet, "doubleSHA256", "blake2b160", 20, []byte{0x06, 0xA1, 0xA1}, nil} XTZ_mainnetAddress_tz3 = AddressType{"base58", xtzAlphabet, "doubleSHA256", "blake2b160", 20, []byte{0x06, 0xA1, 0xA4}, nil} XTZ_mainnetPublic_edpk = AddressType{"base58", xtzAlphabet, "doubleSHA256", "", 32, []byte{0x0D, 0x0F, 0x25, 0xD9}, nil} XTZ_mainnetPrivate_edsk = AddressType{"base58", xtzAlphabet, "doubleSHA256", "", 64, []byte{0x0D, 0x0F, 0x3A, 0x07}, nil} XTZ_mainnetPrivate_edsk2 = AddressType{"base58", xtzAlphabet, "doubleSHA256", "", 32, []byte{0x2B, 0xF6, 0x4E, 0x07}, nil} XTZ_mainnetPrivate_spsk = AddressType{"base58", xtzAlphabet, "doubleSHA256", "", 32, []byte{0x11, 0xA2, 0xE0, 0xC9}, nil} XTZ_mainnetPrivate_p2sk = AddressType{"base58", xtzAlphabet, "doubleSHA256", "blake2b160", 32, []byte{0x10, 0x51, 0xEE, 0xBD}, nil} //HC stuff HC_mainnetPublicAddress = AddressType{"base58", hcAlphabet, "doubleBlake256", "h160", 20, []byte{0x09, 0x7F}, nil} //ETH stuff ETH_mainnetPublicAddress = AddressType{"eip55", "", "", "keccak256", 32, nil, nil} //QTUM stuff QTUM_mainnetAddressP2PKH = AddressType{"base58", qtumAlphabet, "doubleSHA256", "h160", 20, []byte{0x3A}, nil} QTUM_mainnetAddressP2SH = AddressType{"base58", qtumAlphabet, "doubleSHA256", "h160", 20, []byte{0x32}, nil} QTUM_mainnetPrivateWIF = AddressType{"base58", qtumAlphabet, "doubleSHA256", "", 32, []byte{0x80}, nil} QTUM_mainnetPrivateWIFCompressed = AddressType{"base58", qtumAlphabet, "doubleSHA256", "", 32, []byte{0x80}, []byte{0x01}} QTUM_mainnetPublicBIP32 = AddressType{"base58", qtumAlphabet, "doubleSHA256", "", 74, []byte{0x04, 0x88, 0xB2, 0x1E}, nil} QTUM_mainnetPrivateBIP32 = AddressType{"base58", qtumAlphabet, "doubleSHA256", "", 74, []byte{0x04, 0x88, 0xAD, 0xE4}, nil} QTUM_testnetAddressP2PKH = AddressType{"base58", qtumAlphabet, "doubleSHA256", "h160", 20, []byte{0x78}, nil} QTUM_testnetAddressP2SH = AddressType{"base58", qtumAlphabet, "doubleSHA256", "h160", 20, []byte{0x6E}, nil} QTUM_testnetPrivateWIF = AddressType{"base58", qtumAlphabet, "doubleSHA256", "", 32, []byte{0xEF}, nil} QTUM_testnetPrivateWIFCompressed = AddressType{"base58", qtumAlphabet, "doubleSHA256", "", 32, []byte{0xEF}, []byte{0x01}} QTUM_testnetPublicBIP32 = AddressType{"base58", qtumAlphabet, "doubleSHA256", "", 74, []byte{0x04, 0x35, 0x87, 0xCF}, nil} QTUM_testnetPrivateBIP32 = AddressType{"base58", qtumAlphabet, "doubleSHA256", "", 74, []byte{0x04, 0x35, 0x83, 0x94}, nil} //DCRD stuff DCRD_mainnetAddressP2PKH = AddressType{"base58", dcrdAlphabet, "doubleBlake256", "ripemd160", 20, []byte{0x07, 0x3f}, nil} //PubKeyHashAddrID, stars with Ds DCRD_mainnetAddressP2PK = AddressType{"base58", dcrdAlphabet, "doubleBlake256", "ripemd160", 20, []byte{0x13, 0x86}, nil} //PubKeyAddrID,stars with Dk DCRD_mainnetAddressPKHEdwards = AddressType{"base58", dcrdAlphabet, "doubleBlake256", "ripemd160", 20, []byte{0x07, 0x1f}, nil} //PKHEdwardsAddrID,starts with De DCRD_mainnetAddressPKHSchnorr = AddressType{"base58", dcrdAlphabet, "doubleBlake256", "ripemd160", 20, []byte{0x07, 0x01}, nil} //PKHSchnorrAddrID,starts with DS DCRD_mainnetAddressP2SH = AddressType{"base58", dcrdAlphabet, "doubleBlake256", "ripemd160", 20, []byte{0x07, 0x1a}, nil} //ScriptHashAddrID,starts with Dc DCRD_mainnetAddressPrivate = AddressType{"base58", dcrdAlphabet, "doubleBlake256", "ripemd160", 20, []byte{0x22, 0xde}, nil} // PrivateKeyID, starts with Pm DCRD_testnetAddressP2PKH = AddressType{"base58", dcrdAlphabet, "doubleBlake256", "ripemd160", 20, []byte{0x0f, 0x21}, nil} //PubKeyHashAddrID,starts with Ts DCRD_testnetAddressP2PK = AddressType{"base58", dcrdAlphabet, "doubleBlake256", "ripemd160", 20, []byte{0x28, 0xf7}, nil} //PubKeyAddrID, starts with Tk DCRD_testnetAddressPKHEdwards = AddressType{"base58", dcrdAlphabet, "doubleBlake256", "ripemd160", 20, []byte{0x0f, 0x01}, nil} //PKHEdwardsAddrID,starts with Te DCRD_testnetAddressP2PKHSchnorr = AddressType{"base58", dcrdAlphabet, "doubleBlake256", "ripemd160", 20, []byte{0x0e, 0xe3}, nil} //PKHSchnorrAddrID,starts with TS DCRD_testnetAddressP2SH = AddressType{"base58", dcrdAlphabet, "doubleBlake256", "ripemd160", 20, []byte{0x0e, 0xfc}, nil} //ScriptHashAddrID,starts with Tc DCRD_testnetAddressPrivate = AddressType{"base58", dcrdAlphabet, "doubleBlake256", "ripemd160", 20, []byte{0x23, 0x0e}, nil} //PrivateKeyID,starts with Pt DCRD_simnetAddressP2PKH = AddressType{"base58", dcrdAlphabet, "doubleBlake256", "ripemd160", 20, []byte{0x0e, 0x91}, nil} //PubKeyHashAddrID,starts with Ss DCRD_simnetAddressP2PK = AddressType{"base58", dcrdAlphabet, "doubleBlake256", "ripemd160", 20, []byte{0x27, 0x6f}, nil} //PubKeyAddrID,starts with Sk DCRD_simnetAddressPKHEdwards = AddressType{"base58", dcrdAlphabet, "doubleBlake256", "ripemd160", 20, []byte{0x0e, 0x71}, nil} //PKHEdwardsAddrID,starts with Se DCRD_simnetAddressPKHSchnorr = AddressType{"base58", dcrdAlphabet, "doubleBlake256", "ripemd160", 20, []byte{0x0e, 0x53}, nil} //PKHSchnorrAddrID,starts with SS DCRD_simnetAddressP2SH = AddressType{"base58", dcrdAlphabet, "doubleBlake256", "ripemd160", 20, []byte{0x0e, 0x6c}, nil} //ScriptHashAddrID,starts with Sc DCRD_simnetAddressPrivate = AddressType{"base58", dcrdAlphabet, "doubleBlake256", "ripemd160", 20, []byte{0x23, 0x07}, nil} //PrivateKeyID, starts with Ps //Nebulas stuff NAS_AccountAddress = AddressType{"base58", nasAlphabet, "sha3_256", "sha3_256_ripemd160", 20, []byte{0x19, 0x57}, nil} NAS_SmartContractAddress = AddressType{"base58", nasAlphabet, "sha3_256", "sha3_256_ripemd160", 20, []byte{0x19, 0x58}, nil} //TRON stuff TRON_mainnetAddress = AddressType{"base58", tronAlphabet, "doubleSHA256", "keccak256_last_twenty", 20, []byte{0x41}, nil} TRON_testnetAddress = AddressType{"base58", tronAlphabet, "doubleSHA256", "keccak256_last_twenty", 20, []byte{0xa0}, nil} //ICX stuff ICX_walletAddress = AddressType{"ICX", "", "hx", "sha3_256_last_twenty", 20, nil, nil} //VSYS stuff VSYS_mainnetAddress = AddressType{"base58", vsysAlphabet, "blake2b_and_keccak256_first_twenty", "blake2b_and_keccak256_first_twenty", 20, []byte{0x05, 0x4D}, nil} VSYS_testnetAddress = AddressType{"base58", vsysAlphabet, "blake2b_and_keccak256_first_twenty", "blake2b_and_keccak256_first_twenty", 20, []byte{0x05, 0x54}, nil} EOS_mainnetPublic = AddressType{"eos", btcAlphabet, "ripemd160", "", 33, []byte(EOSPublicKeyPrefixCompat), nil} EOS_mainnetPrivateWIF = AddressType{"base58", btcAlphabet, "doubleSHA256", "", 32, []byte{0x80}, nil} EOS_mainnetPrivateWIFCompressed = AddressType{"base58", btcAlphabet, "doubleSHA256", "", 32, []byte{0x80}, []byte{0x01}} )
var (
ErrorInvalidBase58String = errors.New("invalid base58 string")
)
Errors
var (
ErrorSymbolType = errors.New("Invalid symbol type!!!")
)
Functions ¶
func AddressCheck ¶
@function:check the address valid or not @paramter[in]address denotes the input address to be checked @paramter[in]symbol denotes chain marking. @paramter[out] the first return value is true or false. true: address valid, false:address not valid;
the second return value is nil or others. nil: operation success, others:operation fail.
notice:
func AddressDecode ¶
func AddressDecode(address string, addresstype AddressType) ([]byte, error)
func AddressEncode ¶
func AddressEncode(hash []byte, addresstype AddressType) string
func Base58Decode ¶
func Base58Decode(input string, alphabet *Base58Alphabet) ([]byte, error)
Decode docode with custom alphabet
func Base58Encode ¶
func Base58Encode(input []byte, alphabet *Base58Alphabet) string
Encode encode with custom alphabet
Types ¶
type AddressType ¶
type AddressType struct {
// contains filtered or unexported fields
}
func (*AddressType) Prefix ¶
func (at *AddressType) Prefix() []byte
type Base58Alphabet ¶
type Base58Alphabet struct {
// contains filtered or unexported fields
}
Alphabet The base58 alphabet object.
func NewBase58Alphabet ¶
func NewBase58Alphabet(alphabet string) *Base58Alphabet
NewAlphabet create a custom alphabet from 58-length string. Note: len(rune(alphabet)) must be 58.
type CorruptInputError ¶
type CorruptInputError int64
func (CorruptInputError) Error ¶
func (e CorruptInputError) Error() string
type Encoding ¶
type Encoding struct {
// contains filtered or unexported fields
}
func NewEncoding ¶
NewEncoding returns a new padded Encoding defined by the given alphabet, which must be a 64-byte string that does not contain the padding character or CR / LF ('\r', '\n'). The resulting Encoding uses the default padding character ('='), which may be changed or disabled via WithPadding.
func (*Encoding) Base64Encode ¶
func (*Encoding) DecodedLen ¶
func (*Encoding) EncodedLen ¶
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package blake256 implements BLAKE-256 and BLAKE-224 hash functions (SHA-3 candidate).
|
Package blake256 implements BLAKE-256 and BLAKE-224 hash functions (SHA-3 candidate). |