Documentation ¶
Index ¶
- Variables
- func AppDataDir(appName string, roaming bool) string
- func Decode(val []byte, obj interface{}) error
- func Encode(s interface{}) ([]byte, error)
- func FileCopy(src, dst string) (int64, error)
- func FileExists(filePath string) (bool, error)
- func GetNetParams(name string) *params.Params
- func GetUserDataDir() string
- func MakeDirAll(path string) error
- func OpenBrowser(url string) error
- type WIF
Constants ¶
This section is empty.
Variables ¶
var ErrChecksumMismatch = errors.New("checksum mismatch")
ErrChecksumMismatch describes an error where decoding failed due to a bad checksum.
var ErrMalformedPrivateKey = errors.New("malformed private key")
ErrMalformedPrivateKey describes an error where a WIF-encoded private key cannot be decoded due to being improperly formatted. This may occur if the byte length is incorrect or an unexpected magic number was encountered.
Functions ¶
func AppDataDir ¶
AppDataDir returns an operating system specific directory to be used for storing application data for an application.
The appName parameter is the name of the application the data directory is being requested for. This function will prepend a period to the appName for POSIX style operating systems since that is standard practice. An empty appName or one with a single dot is treated as requesting the current directory so only "." will be returned. Further, the first character of appName will be made lowercase for POSIX style operating systems and uppercase for Mac and Windows since that is standard practice.
The roaming parameter only applies to Windows where it specifies the roaming application data profile (%APPDATA%) should be used instead of the local one (%LOCALAPPDATA%) that is used by default.
Example results:
dir := AppDataDir("myapp", false) POSIX (Linux/BSD): ~/.myapp Mac OS: $HOME/Library/Application Support/Myapp Windows: %LOCALAPPDATA%\Myapp Plan 9: $home/myapp
func FileExists ¶
FileExists reports whether the named file or directory exists.
Types ¶
type WIF ¶
type WIF struct { // PrivKey is the private key being imported or exported. PrivKey *secp256k1.PrivateKey // CompressPubKey specifies whether the address controlled by the // imported or exported private key was created by hashing a // compressed (33-byte) serialized public key, rather than an // uncompressed (65-byte) one. CompressPubKey bool // contains filtered or unexported fields }
WIF contains the individual components described by the Wallet Import Format (WIF). A WIF string is typically used to represent a private key and its associated address in a way that may be easily copied and imported into or exported from wallet software. WIF strings may be decoded into this structure by calling DecodeWIF or created with a user-provided private key by calling NewWIF.
func DecodeWIFV09 ¶
DecodeWIFV09 creates a new qitmeer-wallet V0.9 WIF structure by decoding the string encoding of the import format.
The WIF string must be a base58-encoded string of the following byte sequence:
- 1 byte to identify the network, must be 0x80 for mainnet or 0xef for either testnet3 or the regression test network
- 32 bytes of a binary-encoded, big-endian, zero-padded private key
- Optional 1 byte (equal to 0x01) if the address being imported or exported was created by taking the RIPEMD160 after SHA256 hash of a serialized compressed (33-byte) public key
- 4 bytes of checksum, must equal the first four bytes of the double SHA256 of every byte before the checksum in this sequence
If the base58-decoded byte sequence does not match this, DecodeWIF will return a non-nil error. ErrMalformedPrivateKey is returned when the WIF is of an impossible length or the expected compressed pubkey magic number does not equal the expected value of 0x01. ErrChecksumMismatch is returned if the expected WIF checksum does not match the calculated checksum.
func NewWIF ¶
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.
func (*WIF) IsForNet ¶
IsForNet returns whether or not the decoded WIF structure is associated with the passed bitcoin network.
func (*WIF) SerializePubKey ¶
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.