Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Wallet ¶
type Wallet struct { PrivateKey *ecdsa.PrivateKey `json:"private_key"` PublicKey *ecdsa.PublicKey `json:"public_key"` }
func NewWallet ¶
NewWallet creates and returns a new wallet with a randomly generated private key using elliptic curve P-256.
func NewWalletFromPrivateKeyHex ¶
NewWalletFromPrivateKeyHex creates a new wallet from a hexadecimal private key string.
func (*Wallet) GetAddress ¶
GetAddress generates a unique address for the wallet by: 1. Taking the public key (without "0x" prefix) 2. Computing its SHA256 hash 3. Converting hash to hex string 4. Taking last 40 chars and prepending ADDRESS_PREFIX
func (*Wallet) GetPrivateKeyHex ¶
GetPrivateKeyHex returns the private key as a hexadecimal string prefixed with "0x"
func (*Wallet) GetPublicKeyHex ¶
GetPublicKeyHex returns the public key as a hexadecimal string prefixed with "0x", concatenating the X and Y coordinates of the public key point on the curve
func (*Wallet) GetSignedTransaction ¶
func (w *Wallet) GetSignedTransaction(unsignedTxn blockchain.Transaction) (*blockchain.Transaction, error)
GetSignedTxn takes an unsigned transaction and returns a signed copy of it. It does this by: 1. Marshaling the transaction to JSON and computing its SHA256 hash 2. Signing the hash with the wallet's private key using ECDSA 3. Creating a new transaction with the same fields plus signature and public key 4. Returns pointer to signed transaction and any error that occurred