Пример #1
0
    def test_transfer_2of2_offline(self):
        # Send a 2 of 2 transaction from bhive5 which needs bhive4's cosign to send
        # funds but sign the transaction with bhive5's key and then serialize the transaction
        # and deserialize the transaction.  After that, sign with bhive4's key.
        hive = self.bts
        hive.nobroadcast = False
        hive.wallet.unlock("123")
        # hive.wallet.removeAccount("bhive4")
        hive.wallet.removePrivateKeyFromPublicKey(str(PublicKey(self.active_private_key_of_bhive4, prefix=core_unit)))

        tx = TransactionBuilder(use_condenser_api=True, hive_instance=hive)
        tx.appendOps(Transfer(**{"from": 'bhive5',
                                 "to": 'bhive',
                                 "amount": Amount("0.01 HIVE", hive_instance=hive),
                                 "memo": '2 of 2 serialized/deserialized transaction'}))

        tx.appendSigner("bhive5", "active")
        tx.addSigningInformation("bhive5", "active")
        tx.sign()
        tx.clearWifs()
        self.assertEqual(len(tx['signatures']), 1)
        # hive.wallet.removeAccount("bhive5")
        hive.wallet.removePrivateKeyFromPublicKey(str(PublicKey(self.active_private_key_of_bhive5, prefix=core_unit)))
        hive.wallet.addPrivateKey(self.active_private_key_of_bhive4)
        tx.appendMissingSignatures()
        tx.sign(reconstruct_tx=False)
        self.assertEqual(len(tx['signatures']), 2)
        tx.broadcast()
        hive.nobroadcast = True
        hive.wallet.addPrivateKey(self.active_private_key_of_bhive5)
Пример #2
0
    def test_transfer_2of2_wif(self):
        nodelist = NodeList()
        # Send a 2 of 2 transaction from elf which needs bhive4'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 bhive4's key.
        hive = Hive(
            node=self.nodes,
            num_retries=10,
            keys=[self.active_private_key_of_bhive5],
            expiration=360,
        )

        tx = TransactionBuilder(use_condenser_api=True, hive_instance=hive)
        tx.appendOps(Transfer(**{"from": 'bhive5',
                                 "to": 'bhive',
                                 "amount": Amount("0.01 HIVE", hive_instance=hive),
                                 "memo": '2 of 2 serialized/deserialized transaction'}))

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

        hive = Hive(
            node=self.nodes,
            num_retries=10,
            keys=[self.active_private_key_of_bhive4],
            expiration=360,
        )
        new_tx = TransactionBuilder(tx=tx_json, hive_instance=hive)
        new_tx.appendMissingSignatures()
        new_tx.sign(reconstruct_tx=False)
        self.assertEqual(len(new_tx['signatures']), 2)
        new_tx.broadcast()