Exemplo n.º 1
0
func NewWalletEntryFromKeypair(pub coin.PubKey, sec coin.SecKey) WalletEntry {
	return WalletEntry{
		Public:  pub,
		Secret:  sec,
		Address: coin.AddressFromPubKey(pub),
	}
}
Exemplo n.º 2
0
// Creates a ReadableWalletEntry given a pubkey hex string.  The Secret field
// is left empty.
func ReadableWalletEntryFromPubkey(pub string) ReadableWalletEntry {
	pubkey := coin.MustPubKeyFromHex(pub)
	addr := coin.AddressFromPubKey(pubkey)
	return ReadableWalletEntry{
		Address: addr.String(),
		Public:  pub,
	}
}
Exemplo n.º 3
0
func NewWalletEntry() WalletEntry {
	pub, sec := coin.GenerateKeyPair()
	return WalletEntry{
		Address: coin.AddressFromPubKey(pub),
		Public:  pub,
		Secret:  sec,
	}
}
Exemplo n.º 4
0
func makeUxBodyWithSecret(t *testing.T) (coin.UxBody, coin.SecKey) {
	p, s := coin.GenerateKeyPair()
	return coin.UxBody{
		SrcTransaction: coin.SumSHA256(randBytes(t, 128)),
		Address:        coin.AddressFromPubKey(p),
		Coins:          10e6,
		Hours:          100,
	}, s
}
Exemplo n.º 5
0
//Generate Blockchain configuration for client only Blockchain, not intended to be synced to network
func NewLocalBlockchain() Blockchain {
	pubkey, seckey := coin.GenerateKeyPair() //generate new/random pubkey/private key

	fmt.Printf("NewLocalBlockchain: genesis address seckey= %v \n", seckey.Hex())
	VC := NewBlockchain()
	VC.SecKey = seckey
	VC.Genesis.GenesisAddress = coin.AddressFromPubKey(pubkey)
	VC.Genesis.GenesisTime = uint64(time.Now().Unix())
	VC.InjectGenesisBlock()
	return VC
}
Exemplo n.º 6
0
func createWalletEntry(filename string) (*visor.ReadableWalletEntry, error) {
	pub, sec := coin.GenerateKeyPair()
	addr := coin.AddressFromPubKey(pub)

	w := visor.WalletEntry{
		Address: addr,
		Public:  pub,
		Secret:  sec,
	}

	rw := visor.NewReadableWalletEntry(&w)
	if err := rw.Save(filename); err == nil {
		fmt.Printf("Wrote wallet entry to \"%s\"\n", filename)
		return &rw, nil
	} else {
		fmt.Fprintf(os.Stderr, "Failed to write wallet entry to \"%s\"\n",
			filename)
		return nil, err
	}
}
Exemplo n.º 7
0
func tstring(pub coin.PubKey, sec coin.SecKey) string {

	addr := coin.AddressFromPubKey(pub)

	str1 := fmt.Sprintf("%v ", pub.Hex())
	str2 := fmt.Sprintf("%v ", sec.Hex())
	str3 := fmt.Sprintf("%v", addr.String())

	if PrintPubKey == false {
		str1 = ""
	}
	if PrintSeckey == false {
		str2 = ""
	}
	if PrintAddress == false {
		str3 = ""
	}

	return fmt.Sprintf("%s%s%s", str1, str2, str3)
}
Exemplo n.º 8
0
func makeAddress() coin.Address {
	p, _ := coin.GenerateKeyPair()
	return coin.AddressFromPubKey(p)
}