net = pickle.load(file_net) net.BlockChain = bc net.init_net([addrSeed]) file_net.close() else: net = FunctionNetwork.node(bc, ip=ip, port=port, is_seed=0, full_node=1, addr_seed_node=addrSeed) auth = Authorization.Authorization(bc, trie) print("\ndesea crear una identidad y registrarla? s/n") s = input() if s == "s": wallet = Wallet.Wallet() Wallet.create_identity_from_interface(wallet) net.send_id(wallet.my_identity) index = -2 if (net.ip, net.port) in trusted_parties: index = trusted_parties.index((net.ip, net.port)) def verification_blocks(net, auth, bc): i = 0 print("verifiying block") while 1: sleep(3) if kill: exit(0)
import cPickle as pickle import time import urllib2 PRIVATE_KEY = '9bd15515d2c34f582eddd4975d03bb73f50761d7ef628a2d0f6f66551dcd642bd7dc30747400185f' PUBLIC_KEY = '2f2ef8959a68c1912fe51b6cbee0fc973798854b' MKRT = 'LTC/BTC' if __name__ == '__main__': C = Cryptsy.Cryptsy(PUBLIC_KEY, PRIVATE_KEY) M = Markets.Markets(MKRT) T = Trades.Trades() V = visuals.Visuals() Q = QLearner.QLearner() W = Wallet.Wallet() States = [] Trade_Data = [] i = 0 while (i < 1000): try: m_dict = C.getMarkets() m_id, price = M.get_market(m_dict) m_trades = C.marketTrades(m_id) trade_data = T.get_data(m_trades) price_EMA = T.EMA(trade_data[:, 1]) wallet = W.get_wallet()
import Block, Chain, Transaction, Wallet a = Wallet.Wallet() b = Wallet.Wallet() c = Wallet.Wallet() a.send(b.publicKey, 10000) print()
def changeGui(self): self.hide() self.lite = CoinLiteGui(self.wallet, self) self.lite.main() def loadConfiguration(self): self.configuration = ConfigurationDialog(self) def close(self): QtGui.QMainWindow.close(self) class CoinGui: def __init__(self, wallet, app=None): self.wallet = wallet if app is None: self.app = QtGui.QApplication(sys.argv) def main(self): coinWindow = CoinWindow(self.wallet) coinWindow.app = self.app coinWindow.updateWallet() coinWindow.show() self.app.exec_() if __name__ == '__main__': app = QtGui.QApplication(sys.argv) wallet = Wallet() coinGui = CoinGui(wallet) coinGui.main()
def __init__(self, name=None, salary=0, day_of_salary='1900.01.01'): self.name = name self.wallet = Wallet(salary) self.calendar = Calendar(day_of_salary) self.history = History()
def HexCoin(self): #generate some walets Coinbase = wlt.Wallet() walletA = wlt.Wallet() walletB = wlt.Wallet() #send 100 coins to walleta genesisTransaction = txn.Transaction(Coinbase.PEMPublicKey.decode(), walletA.PEMPublicKey.decode(), 10000, 0, None) genesisTransaction.GenerateTransactionSignature(Coinbase.PrivateKey) #give the transaction a manual hash genesisTransaction.TransactionHash = "0" genesisTransaction.TransactionOutputs.append( outs.TransactionOutput(genesisTransaction.Recipient, genesisTransaction.Value, genesisTransaction.TransactionHash, 0)) self.UTXOs[genesisTransaction.TransactionOutputs[0].Id] = { "Transaction": genesisTransaction.TransactionOutputs[0] } print("create and mine genesis block") genesis = bl.Block("0") genesis.AddTransaction(genesisTransaction, self) self.AddBlock(genesis) #block 1 block1 = bl.Block(genesis.BlockHash) print("balance of wallet a = " + str(walletA.getBalance(self))) print("sending 40 from wallet a to b") block1.AddTransaction( walletA.SendFunds(walletB.PEMPublicKey.decode(), 40, self), self) self.AddBlock(block1) print("balance of wallet a = " + str(walletA.getBalance(self))) print("balance of wallet b = " + str(walletB.getBalance(self))) #block 1 block2 = bl.Block(block1.BlockHash) print("balance of wallet a = " + str(walletA.getBalance(self))) print("spending more coins than in wallet") block2.AddTransaction( walletA.SendFunds(walletB.PEMPublicKey.decode(), 5, self), self) self.AddBlock(block2) print("balance of wallet a = " + str(walletA.getBalance(self))) print("balance of wallet b = " + str(walletB.getBalance(self))) #block 1 block3 = bl.Block(block2.BlockHash) print("balance of wallet a = " + str(walletB.getBalance(self))) print("sending 40 from wallet a to b") block3.AddTransaction( walletB.SendFunds(walletA.PEMPublicKey.decode(), 23.5, self), self) self.AddBlock(block3) print("balance of wallet a = " + str(walletA.getBalance(self))) print("balance of wallet b = " + str(walletB.getBalance(self))) #clears spent Utxos and keeps the chain clean #self.CleanUpUtxo() self.CheckChainValid(genesisTransaction) #block 4 tests creating a new coin block4 = bl.Block(block3.BlockHash) print("balance of wallet a = " + str(walletA.getBalance(self))) print("Creating a new coin") CoinTxn = walletA.CreateNewCoin(self, "HephCoin", "Heph", 100000) block4.AddTransaction(CoinTxn, self) self.AddBlock(block4) print("balance of wallet a = " + str(walletA.getBalance(self))) print("coin balance of wallet a = " + str(walletA.GetTokenBalance(self, self.AlternativeCoins[0]))) #block 5 sends tokens from one wallet to another block5 = bl.Block(block4.BlockHash) print("coin balance of wallet a = " + str(walletA.GetTokenBalance(self, self.AlternativeCoins[0]))) print("coin balance of wallet b = " + str(walletB.GetTokenBalance(self, self.AlternativeCoins[0]))) print("sending 500.5050505 Tokens from wallet a to b") TokenTransaction = walletA.SendToken(walletB.PEMPublicKey.decode(), 500.5050505, self.AlternativeCoins[0], self) block5.AddTransaction(TokenTransaction, self) self.AddBlock(block5) print("coin balance of wallet a = " + str(walletA.GetTokenBalance(self, self.AlternativeCoins[0]))) print("coin balance of wallet b = " + str(walletB.GetTokenBalance(self, self.AlternativeCoins[0]))) print("coin balance of wallet b = " + str(walletB.GetTokenBalance(self, self.AlternativeCoins[0]))) print( "Testing burning token by using the burn wallet function - This permenantly destroys the UTXOs" ) block6 = bl.Block(block5.BlockHash) BurnTransaction = walletB.BurnToken(0.5050505, self.AlternativeCoins[0], self) block6.AddTransaction(BurnTransaction, self) self.AddBlock(block6) print("spendable balance of wallet b = " + str( walletB.GetSpentableTokenBalance(self, self.AlternativeCoins[0]))) print("freezing some 60 tokens from wallet b") block7 = bl.Block(block6.BlockHash) FreezeTransaction = walletB.FreezeUnfreezeTokens( 60, self.AlternativeCoins[0], True, self) block7.AddTransaction(FreezeTransaction, self) self.AddBlock(block7) print("spentable token balance of wallet b = " + str( walletB.GetSpentableTokenBalance(self, self.AlternativeCoins[0]))) print("coin balance of wallet b = " + str(walletB.GetTokenBalance(self, self.AlternativeCoins[0]))) print("unfreezing 30 tokens") block8 = bl.Block(block7.BlockHash) FreezeTransaction = walletB.FreezeUnfreezeTokens( 22, self.AlternativeCoins[0], False, self) block8.AddTransaction(FreezeTransaction, self) self.AddBlock(block8) print("spentable token balance of wallet b = " + str( walletB.GetSpentableTokenBalance(self, self.AlternativeCoins[0]))) print("coin balance of wallet b = " + str(walletB.GetTokenBalance(self, self.AlternativeCoins[0]))) print("Testing Limit Order") block9 = bl.Block(block8.BlockHash) order = walletB.CreateOrder(self.AlternativeCoins[0], 1, 10, True, self) block9.AddTransaction(order, self) self.AddBlock(block9) print("Buy Order Added") print("Testing Limit Order when matching order on the market") print("Values before Trade") print("coin balance of wallet a = " + str(walletA.GetTokenBalance(self, self.AlternativeCoins[0]))) print("coin balance of wallet b = " + str(walletB.GetTokenBalance(self, self.AlternativeCoins[0]))) print("balance of wallet a = " + str(walletA.getBalance(self))) print("balance of wallet b = " + str(walletB.getBalance(self))) block10 = bl.Block(block9.BlockHash) order = walletA.CreateOrder(self.AlternativeCoins[0], 1, 10, False, self) block10.AddTransaction(order, self) self.AddBlock(block10) self.CleanOrders() print("Balance After Trade") print("coin balance of wallet a = " + str(walletA.GetTokenBalance(self, self.AlternativeCoins[0]))) print("coin balance of wallet b = " + str(walletB.GetTokenBalance(self, self.AlternativeCoins[0]))) print("balance of wallet a = " + str(walletA.getBalance(self))) print("balance of wallet b = " + str(walletB.getBalance(self))) return self.UTXOs, self.OpenOrders