def test_finalizeOps(self): bts = self.bts tx1 = bts.new_tx() tx2 = bts.new_tx() acc = Account("dpaygo", dpay_instance=bts) acc.transfer("dpaygo1", 1, "BEX", append_to=tx1) acc.transfer("dpaygo1", 2, "BEX", append_to=tx2) acc.transfer("dpaygo1", 3, "BEX", append_to=tx1) tx1 = tx1.json() tx2 = tx2.json() ops1 = tx1["operations"] ops2 = tx2["operations"] self.assertEqual(len(ops1), 2) self.assertEqual(len(ops2), 1)
def test_transfer(self): bts = self.bts bts.nobroadcast = False bts.wallet.unlock("123") # bts.prefix ="STX" acc = Account("dpaygo", dpay_instance=bts) tx = acc.transfer("dpaygo1", 1.33, "BBD", memo="Foobar") self.assertEqual(tx["operations"][0][0], "transfer") self.assertEqual(len(tx['signatures']), 1) op = tx["operations"][0][1] self.assertIn("memo", op) self.assertEqual(op["from"], "dpaygo") self.assertEqual(op["to"], "dpaygo1") amount = Amount(op["amount"], dpay_instance=bts) self.assertEqual(float(amount), 1.33) bts.nobroadcast = True
def test_transfer_memo(self): bts = self.bts bts.nobroadcast = False bts.wallet.unlock("123") acc = Account("dpaygo", dpay_instance=bts) tx = acc.transfer("dpaygo1", 1.33, "BBD", memo="#Foobar") self.assertEqual(tx["operations"][0][0], "transfer") op = tx["operations"][0][1] self.assertIn("memo", op) self.assertIn("#", op["memo"]) m = Memo(from_account=op["from"], to_account=op["to"], dpay_instance=bts) memo = m.decrypt(op["memo"]) self.assertEqual(memo, "Foobar") self.assertEqual(op["from"], "dpaygo") self.assertEqual(op["to"], "dpaygo1") amount = Amount(op["amount"], dpay_instance=bts) self.assertEqual(float(amount), 1.33) bts.nobroadcast = True
posting_pubkey = posting_key.get_public_key() memo_pubkey = memo_key.get_public_key() active_privkey = active_key.get_private_key() posting_privkey = posting_key.get_private_key() owner_privkey = owner_key.get_private_key() memo_privkey = memo_key.get_private_key() if useWallet: stm.wallet.addPrivateKey(owner_privkey) stm.wallet.addPrivateKey(active_privkey) stm.wallet.addPrivateKey(memo_privkey) stm.wallet.addPrivateKey(posting_privkey) else: stm = DPay(node=nodelist.get_nodes(normal=False, appbase=False, testnet=True), wif={'active': str(active_privkey), 'posting': str(posting_privkey), 'memo': str(memo_privkey)}) account = Account(username, dpay_instance=stm) account.disallow("dpaygo1", permission='posting') account.allow('dpaygo1', weight=1, permission='posting', account=None) if useWallet: stm.wallet.getAccountFromPrivateKey(str(active_privkey)) # stm.create_account("dpaygo1", creator=account, password=password1) account1 = Account("dpaygo1", dpay_instance=stm) b = Blockchain(dpay_instance=stm) blocknum = b.get_current_block().identifier account.transfer("dpaygo1", 1, "BBD", "test") b1 = Block(blocknum, dpay_instance=stm)