mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00

* Copy over the CLI wallet from Kasparov. * Fix trivial compilation errors. * Reimplement the balance command. * Extract isUTXOSpendable to a separate function. * Reimplement the send command. * Fix bad transaction ID parsing. * Add a missing newline in a log. * Don't use msgTx in send(). * Fix isUTXOSpendable not checking whether a UTXO is of a coinbase transaction. * Add --devnet, --testnet, etc. to command line flags. * In `create`, only print the public key of the active network. * Use coinbase maturity in isUTXOSpendable. * Add a readme. * Fix formatting in readme.
38 lines
1.1 KiB
Go
38 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/kaspanet/go-secp256k1"
|
|
"github.com/kaspanet/kaspad/util"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
func create(conf *createConfig) error {
|
|
privateKey, err := secp256k1.GeneratePrivateKey()
|
|
if err != nil {
|
|
return errors.Wrap(err, "Failed to generate private key")
|
|
}
|
|
|
|
fmt.Println("This is your private key, granting access to all wallet funds. Keep it safe. Use it only when sending Kaspa.")
|
|
fmt.Printf("Private key (hex):\t%s\n\n", privateKey.SerializePrivateKey())
|
|
|
|
fmt.Println("This is your public address, where money is to be sent.")
|
|
publicKey, err := privateKey.SchnorrPublicKey()
|
|
if err != nil {
|
|
return errors.Wrap(err, "Failed to generate public key")
|
|
}
|
|
publicKeySerialized, err := publicKey.Serialize()
|
|
if err != nil {
|
|
return errors.Wrap(err, "Failed to serialize public key")
|
|
}
|
|
|
|
addr, err := util.NewAddressPubKeyHashFromPublicKey(publicKeySerialized[:], conf.ActiveNetParams.Prefix)
|
|
if err != nil {
|
|
return errors.Wrap(err, "Failed to generate p2pkh address")
|
|
}
|
|
fmt.Printf("Address (%s):\t%s\n", conf.ActiveNetParams.Name, addr)
|
|
|
|
return nil
|
|
}
|