Пример #1
0
def makekey(args):
    k = Key()
    k.makeNewKey(compressed=True)

    privateKey = k.getPrivateKey()
    privateKey = base58.encodeBase58Check(privateKey, 128)  #PRIVKEY = 128

    address = getAddress(k)

    with open(address, "wb") as f:
        f.write(privateKey + "\n")
    print "Saved as ", address
Пример #2
0
def makekey(args):
	k = Key()
	k.makeNewKey(compressed=True)

	privateKey = k.getPrivateKey()
	privateKey = base58.encodeBase58Check(privateKey, 128) #PRIVKEY = 128

	address = getAddress(k)

	with open(address, "wb") as f:
		f.write(privateKey + "\n")
	print "Saved as ", address
Пример #3
0
	def test_versionMismatch(self):
		"Test what happens if decode finds an incorrect version number"

		for hash160, address in self.testSet:
			wrongAddress = base58.encodeBase58Check(hash160, 1)

			#Make sure it still works if we use the same version number:
			self.assertEqual(base58.decodeBase58Check(wrongAddress, 1), hash160)

			#But it will fail with a different version number:
			self.assertRaises(Exception, base58.decodeBase58Check,
				wrongAddress, 0
				)
Пример #4
0
def getAddress(key):
	publicKeyHash = RIPEMD160(SHA256(key.getPublicKey()))
	return base58.encodeBase58Check(publicKeyHash, 0) #PUBKEY_ADDRESS = 0
Пример #5
0
def getAddress(key):
    publicKeyHash = RIPEMD160(SHA256(key.getPublicKey()))
    return base58.encodeBase58Check(publicKeyHash, 0)  #PUBKEY_ADDRESS = 0
Пример #6
0
	def getPrivateKey(self, address):
		return base58.encodeBase58Check(address, 128)
Пример #7
0
	def test_encodeBase58Check(self):
		"Test the encodeBase58Check function"

		for hash160, address in self.testSet:
			self.assertEqual(base58.encodeBase58Check(hash160, 0), address)
Пример #8
0
from amiko.utils import base58
from amiko.utils.crypto import Key, RIPEMD160, SHA256
from amiko.utils import bitcointransaction
from amiko.utils.bitcoinutils import sendToMultiSigPubKey
from amiko.utils.bitcoinutils import makeSpendMultiSigTransaction, signMultiSigTransaction, applyMultiSigSignatures



s = settings.Settings("../../amikopay.conf")
d = bitcoind.Bitcoind(s)

#(these addresses are mine - thanks for donating :-P)
keyHash1 = binascii.unhexlify("fd5627c5eff58991dec54877272e82f758ea8b65")
keyHash2 = binascii.unhexlify("ab22c699d3e72f2c1e4896508bf9d8d7910104d0")

address1 = base58.encodeBase58Check(keyHash1, 0)
address2 = base58.encodeBase58Check(keyHash2, 0)
print address1
print address2

#Note: this will fail, unless you change the above addresses to some of your own
privKey1 = base58.decodeBase58Check(d.getPrivateKey(address1), 128)
privKey2 = base58.decodeBase58Check(d.getPrivateKey(address2), 128)

key1 = Key()
key1.setPrivateKey(privKey1)
key2 = Key()
key2.setPrivateKey(privKey2)

print key1.getPublicKey().encode("hex")
print key2.getPublicKey().encode("hex")
Пример #9
0
	def getPrivateKey(self, address):
		return base58.encodeBase58Check(address, 128)