Exemple #1
0
    def test_transfer_2of2_offline(self):
        # Send a 2 of 2 transaction from beem5 which needs beem4's cosign to send
        # funds but sign the transaction with beem5's key and then serialize the transaction
        # and deserialize the transaction.  After that, sign with beem4's key.
        steem = self.bts
        steem.nobroadcast = False
        steem.wallet.unlock("123")
        steem.wallet.removeAccount("beem4")

        tx = TransactionBuilder(steem_instance=steem)
        tx.appendOps(
            Transfer(
                **{
                    "from": 'beem5',
                    "to": 'beem',
                    "amount": '0.01 SBD',
                    "memo": '2 of 2 serialized/deserialized transaction'
                }))

        tx.appendSigner("beem5", "active")
        tx.addSigningInformation("beem5", "active")
        tx.sign()
        tx.clearWifs()
        self.assertEqual(len(tx['signatures']), 1)
        steem.wallet.removeAccount("beem5")
        steem.wallet.addPrivateKey(self.active_private_key_of_beem4)
        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_beem5)
Exemple #2
0
    def test_transfer_2of2_serialized_deserialized(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")
        tx_json = tx.json()
        del tx
        new_tx = TransactionBuilder(tx=tx_json, steem_instance=steem)
        self.assertEqual(len(new_tx['signatures']), 1)
        steem.wallet.addPrivateKey(self.active_private_key_of_steemfiles)
        new_tx.appendMissingSignatures()
        new_tx.sign(reconstruct_tx=False)
        self.assertEqual(len(new_tx['signatures']), 2)
        new_tx.broadcast()
        steem.nobroadcast = True
Exemple #3
0
    def test_transfer_2of2_serialized_deserialized(self):
        # Send a 2 of 2 transaction from beem5 which needs beem4's cosign to send
        # funds but sign the transaction with beem5's key and then serialize the transaction
        # and deserialize the transaction.  After that, sign with beem4's key.
        steem = self.bts
        steem.nobroadcast = False
        steem.wallet.unlock("123")
        # steem.wallet.removeAccount("beem4")
        steem.wallet.removePrivateKeyFromPublicKey(str(PublicKey(self.active_private_key_of_beem4, prefix=core_unit)))

        tx = TransactionBuilder(use_condenser_api=True, steem_instance=steem)
        tx.appendOps(Transfer(**{"from": 'beem5',
                                 "to": 'beem1',
                                 "amount": Amount("0.01 STEEM", steem_instance=steem),
                                 "memo": '2 of 2 serialized/deserialized transaction'}))

        tx.appendSigner("beem5", "active")
        tx.addSigningInformation("beem5", "active")
        tx.sign()
        tx.clearWifs()
        self.assertEqual(len(tx['signatures']), 1)
        # steem.wallet.removeAccount("beem5")
        steem.wallet.removePrivateKeyFromPublicKey(str(PublicKey(self.active_private_key_of_beem5, prefix=core_unit)))
        tx_json = tx.json()
        del tx
        new_tx = TransactionBuilder(tx=tx_json, steem_instance=steem)
        self.assertEqual(len(new_tx['signatures']), 1)
        steem.wallet.addPrivateKey(self.active_private_key_of_beem4)
        new_tx.appendMissingSignatures()
        new_tx.sign(reconstruct_tx=False)
        self.assertEqual(len(new_tx['signatures']), 2)
        new_tx.broadcast()
        steem.nobroadcast = True
Exemple #4
0
    def test_transfer_2of2_wif(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 = Steem(node=["wss://testnet.steem.vc"],
                      num_retries=10,
                      keys=[self.active_private_key_of_elf])

        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)
        tx_json = tx.json()
        del steem
        del tx

        steem = Steem(node=["wss://testnet.steem.vc"],
                      num_retries=10,
                      keys=[self.active_private_key_of_steemfiles])
        new_tx = TransactionBuilder(tx=tx_json, steem_instance=steem)
        new_tx.appendMissingSignatures()
        new_tx.sign(reconstruct_tx=False)
        self.assertEqual(len(new_tx['signatures']), 2)
        new_tx.broadcast()
    def test_transfer_2of2_wif(self):
        nodelist = NodeList()
        # Send a 2 of 2 transaction from elf which needs beem4'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 beem4's key.
        steem = Steem(
            node=self.nodes,
            num_retries=10,
            keys=[self.active_private_key_of_beem5],
            expiration=360,
        )

        tx = TransactionBuilder(use_condenser_api=True, steem_instance=steem)
        tx.appendOps(
            Transfer(
                **{
                    "from": 'beem5',
                    "to": 'beem',
                    "amount": Amount("0.01 STEEM", steem_instance=steem),
                    "memo": '2 of 2 serialized/deserialized transaction'
                }))

        tx.appendSigner("beem5", "active")
        tx.addSigningInformation("beem5", "active")
        tx.sign()
        tx.clearWifs()
        self.assertEqual(len(tx['signatures']), 1)
        tx_json = tx.json()
        del steem
        del tx

        steem = Steem(
            node=self.nodes,
            num_retries=10,
            keys=[self.active_private_key_of_beem4],
            expiration=360,
        )
        new_tx = TransactionBuilder(tx=tx_json, steem_instance=steem)
        new_tx.appendMissingSignatures()
        new_tx.sign(reconstruct_tx=False)
        self.assertEqual(len(new_tx['signatures']), 2)
        new_tx.broadcast()