Exemple #1
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)
}
Exemple #2
0
func TestNewWalletFromReadable(t *testing.T) {
	w := NewSimpleWallet().(*SimpleWallet)
	we := NewWalletEntry()
	w.Entries[we.Address] = we
	we2 := NewWalletEntry()
	w.Entries[we2.Address] = we2
	rw := NewReadableWallet(w)
	w2 := NewSimpleWalletFromReadable(rw).(*SimpleWallet)
	for a, e := range w2.Entries {
		assert.Equal(t, a, e.Address)
		assert.Equal(t, e, w.Entries[a])
	}
	assert.Equal(t, len(w.Entries), len(w2.Entries))
	sec := coin.SecKey{}
	oldSec := rw.Entries[0].Secret
	rw.Entries[0].Secret = sec.Hex()
	assert.Panics(t, func() { NewSimpleWalletFromReadable(rw) })
	pub := coin.PubKey{}
	rw.Entries[0].Secret = oldSec
	rw.Entries[0].Public = pub.Hex()
	assert.Panics(t, func() { NewSimpleWalletFromReadable(rw) })
}