diff --git a/beem/transactionbuilder.py b/beem/transactionbuilder.py index ef36600a8b46c5a32c8e5529775b8abe5a379cdf..fc52398c1f61858d2db59f30772fa6cc89e3788b 100644 --- a/beem/transactionbuilder.py +++ b/beem/transactionbuilder.py @@ -209,6 +209,10 @@ class TransactionBuilder(dict): except: raise InvalidWifError + def clearWifs(self): + """Clear all stored wifs""" + self.wifs = set() + def constructTx(self): """ Construct the actual transaction and store it in the class's dict store diff --git a/beem/utils.py b/beem/utils.py index 2e30b5c64250ed8093763c5c7673fd09d3f782df..c4973d43a9f185d8226f60fc201324f418fc7046 100644 --- a/beem/utils.py +++ b/beem/utils.py @@ -234,10 +234,10 @@ def make_patch(a, b, n=3): def get_node_list(appbase=False): """Returns node list""" if appbase: - return ["https://api.steem.house", "https://api.steemit.com", "wss://steemd.steemitstage.com", + return ["https://api.steem.house", "https://api.steemit.com", "wss://steemd.steemitstage.com", "wss://steemd.steemitdev.com", "wss://appbasetest.timcliff.com"] else: - return ["wss://steemd.privex.io", "wss://steemd.pevo.science", "wss://rpc.steemliberator.com", "wss://rpc.buildteam.io", "wss://gtg.steem.house:8090", + return ["wss://steemd.privex.io", "wss://steemd.pevo.science", "wss://rpc.steemliberator.com", "wss://rpc.buildteam.io", "wss://gtg.steem.house:8090", "wss://rpc.steemviz.com", "wss://seed.bitcoiner.me", "wss://steemd.steemgigs.org", "wss://steemd.minnowsupportproject.org", "https://rpc.buildteam.io", "https://steemd.minnowsupportproject.org", "https://steemd.pevo.science", "https://rpc.steemviz.com", "https://seed.bitcoiner.me", diff --git a/examples/benchmark_nodes.py b/examples/benchmark_nodes.py index 833b8d2605e482561a2eeb3382b5d5ddb23cded0..4e0759dae007cfdbdfb3ce18c10a41e5a4bcadaf 100644 --- a/examples/benchmark_nodes.py +++ b/examples/benchmark_nodes.py @@ -12,17 +12,11 @@ from beem.blockchain import Blockchain from beem.account import Account from beem.block import Block from beem.steem import Steem -from beem.utils import parse_time, formatTimedelta +from beem.utils import parse_time, formatTimedelta, get_node_list from beemgrapheneapi.rpcutils import NumRetriesReached log = logging.getLogger(__name__) logging.basicConfig(level=logging.INFO) -nodes = ["wss://steemd.pevo.science", "wss://gtg.steem.house:8090", "wss://rpc.steemliberator.com", "wss://rpc.buildteam.io", - "wss://rpc.steemviz.com", "wss://seed.bitcoiner.me", "wss://node.steem.ws", "wss://steemd.steemgigs.org", - "wss://steemd.minnowsupportproject.org", "https://api.steemit.com", "https://rpc.buildteam.io", - "https://steemd.minnowsupportproject.org", "https://steemd.pevo.science", "https://rpc.steemviz.com", "https://seed.bitcoiner.me", - "https://rpc.steemliberator.com", "https://steemd.privex.io", "https://gtg.steem.house:8090", "https://api.steem.house", - "https://rpc.curiesteem.com"] if __name__ == "__main__": how_many_minutes = 10 @@ -30,6 +24,8 @@ if __name__ == "__main__": max_batch_size = None threading = False thread_num = 16 + nodes = get_node_list(appbase=True) + nodes.append(get_node_list(appbase=False)) t = PrettyTable(["node", "10 blockchain minutes", "10000 virtual account op", "version"]) t.align = "l" for node in nodes: diff --git a/tests/beem/test_testnet.py b/tests/beem/test_testnet.py index 78d36352ba6a395220207795d3f5e06914742b38..a19caa2bb7e745716a370752af3cb3244edb52a2 100644 --- a/tests/beem/test_testnet.py +++ b/tests/beem/test_testnet.py @@ -122,6 +122,7 @@ class Testcases(unittest.TestCase): ) tx.appendWif(self.active_key) tx.sign() + tx.sign() self.assertEqual(len(tx['signatures']), 1) tx.broadcast() steem.nobroadcast = True @@ -137,8 +138,10 @@ class Testcases(unittest.TestCase): "memo": '2 of 2 simple transaction'})) tx.appendWif(self.active_private_key_of_elf) - tx.appendWif(self.active_private_key_of_steemfiles) tx.sign() + tx.clearWifs() + tx.appendWif(self.active_private_key_of_steemfiles) + tx.sign(reconstruct_tx=False) self.assertEqual(len(tx['signatures']), 2) tx.broadcast() steem.nobroadcast = True @@ -180,6 +183,7 @@ class Testcases(unittest.TestCase): tx.appendSigner("elf", "active") tx.sign() + tx.clearWifs() self.assertEqual(len(tx['signatures']), 1) new_tx = TransactionBuilder(tx=tx.json(), steem_instance=steem) self.assertEqual(len(new_tx['signatures']), 1) @@ -191,6 +195,35 @@ class Testcases(unittest.TestCase): new_tx.broadcast() steem.nobroadcast = True + def test_transfer_2of2_offline(self): + # Send a 2 of 2 transaction from elf which needs steemfiles's cosign to send + # funds but sign the transaction with elf's key and then serialize the transaction + # and deserialize the transaction. After that, sign with steemfiles's key. + steem = self.bts + steem.nobroadcast = False + steem.wallet.unlock("123") + steem.wallet.removeAccount("steemfiles") + + tx = TransactionBuilder(steem_instance=steem) + tx.appendOps(Transfer(**{"from": 'elf', + "to": 'leprechaun', + "amount": '0.01 SBD', + "memo": '2 of 2 serialized/deserialized transaction'})) + + tx.appendSigner("elf", "active") + tx.addSigningInformation("elf", "active") + tx.sign() + tx.clearWifs() + self.assertEqual(len(tx['signatures']), 1) + steem.wallet.removeAccount("elf") + steem.wallet.addPrivateKey(self.active_private_key_of_steemfiles) + tx.appendMissingSignatures() + tx.sign(reconstruct_tx=False) + self.assertEqual(len(tx['signatures']), 2) + tx.broadcast() + steem.nobroadcast = True + steem.wallet.addPrivateKey(self.active_private_key_of_elf) + def test_verifyAuthority(self): stm = self.bts stm.wallet.unlock("123")