예제 #1
0
    def constructTx(self, ref_block_num=None, ref_block_prefix=None):
        """ Construct the actual transaction and store it in the class's dict
            store

        """
        ops = list()
        if self.steem.is_connected() and self.steem.rpc.get_use_appbase():
            # appbase disabled by now
            # broadcasting does not work at the moment
            appbase = not self._use_condenser_api
        else:
            appbase = False
        for op in self.ops:
            # otherwise, we simply wrap ops into Operations
            ops.extend(
                [Operation(op, appbase=appbase, prefix=self.steem.prefix)])

        # We no wrap everything into an actual transaction
        expiration = formatTimeFromNow(self.expiration
                                       or self.steem.expiration)
        if ref_block_num is None or ref_block_prefix is None:
            ref_block_num, ref_block_prefix = transactions.getBlockParams(
                self.steem.rpc)
        self.tx = Signed_Transaction(ref_block_prefix=ref_block_prefix,
                                     expiration=expiration,
                                     operations=ops,
                                     ref_block_num=ref_block_num,
                                     custom_chains=self.steem.custom_chains,
                                     prefix=self.steem.prefix)

        super(TransactionBuilder, self).update(self.tx.json())
        self._unset_require_reconstruction()
예제 #2
0
 def list_operations(self):
     """List all ops"""
     if self.blockchain.is_connected() and self.blockchain.rpc.get_use_appbase():
         # appbase disabled by now
         appbase = not self._use_condenser_api
     else:
         appbase = False
     return [Operation(o, appbase=appbase, prefix=self.blockchain.prefix) for o in self.ops]
예제 #3
0
 def list_operations(self):
     """List all ops"""
     if self.steem.is_connected() and self.steem.rpc.get_use_appbase():
         # appbase disabled by now
         appbase = False
     else:
         appbase = False
     return [Operation(o, appbase=appbase) for o in self.ops]
 def doit(self, printWire=False, ops=None):
     if ops is None:
         ops = [Operation(self.op)]
     tx = Signed_Transaction(ref_block_num=self.ref_block_num,
                             ref_block_prefix=self.ref_block_prefix,
                             expiration=self.expiration,
                             operations=ops)
     tx = tx.sign([self.wif], chain=self.prefix)
     tx.verify([PrivateKey(self.wif, prefix=u"STM").pubkey], self.prefix)
     txWire = hexlify(py23_bytes(tx)).decode("ascii")
예제 #5
0
    def constructTx(self, ref_block_num=None, ref_block_prefix=None):
        """ Construct the actual transaction and store it in the class's dict
            store

        """
        ops = list()
        if self.blockchain.is_connected(
        ) and self.blockchain.rpc.get_use_appbase():
            # appbase disabled by now
            # broadcasting does not work at the moment
            appbase = not self._use_condenser_api
        else:
            appbase = False
        for op in self.ops:
            # otherwise, we simply wrap ops into Operations
            ops.extend([
                Operation(op, appbase=appbase, prefix=self.blockchain.prefix)
            ])

        # calculation expiration time from last block time not system time
        # it fixes transaction expiration error when pushing transactions
        # when blocks are moved forward with debug_produce_block*
        if self.blockchain.is_connected():
            now = formatTimeString(
                self.blockchain.get_dynamic_global_properties(
                    use_stored_data=False).get('time')).replace(tzinfo=None)
            expiration = now + timedelta(
                seconds=int(self.expiration or self.blockchain.expiration))
            expiration = expiration.replace(microsecond=0).isoformat()
        else:
            expiration = formatTimeFromNow(self.expiration
                                           or self.blockchain.expiration)

        # We now wrap everything into an actual transaction
        if ref_block_num is None or ref_block_prefix is None:
            ref_block_num, ref_block_prefix = self.get_block_params()
        if self._use_ledger:
            self.ledgertx = Ledger_Transaction(
                ref_block_prefix=ref_block_prefix,
                expiration=expiration,
                operations=ops,
                ref_block_num=ref_block_num,
                custom_chains=self.blockchain.custom_chains,
                prefix=self.blockchain.prefix)

        self.tx = Signed_Transaction(
            ref_block_prefix=ref_block_prefix,
            expiration=expiration,
            operations=ops,
            ref_block_num=ref_block_num,
            custom_chains=self.blockchain.custom_chains,
            prefix=self.blockchain.prefix)

        super(TransactionBuilder, self).update(self.tx.json())
        self._unset_require_reconstruction()
 def doit(self, printWire=False, ops=None):
     ops = [Operation(ops)]
     tx = Signed_Transaction(ref_block_num=self.ref_block_num,
                             ref_block_prefix=self.ref_block_prefix,
                             expiration=self.expiration,
                             operations=ops)
     start = timer()
     tx = tx.sign([self.wif], chain=self.prefix)
     end1 = timer()
     tx.verify([PrivateKey(self.wif, prefix=u"STM").pubkey], self.prefix)
     end2 = timer()
     return end2 - end1, end1 - start
예제 #7
0
    def test_Transfer(self):
        transferJson = {
            'from': 'test',
            'to': 'test1',
            'amount': "1.000 STEEM",
            'memo': 'foobar'
        }
        t = Transfer(transferJson)
        self.assertEqual(transferJson, json.loads(str(t)))
        self.assertEqual(transferJson, t.json())
        self.assertEqual(transferJson, t.toJson())
        self.assertEqual(transferJson, t.__json__())

        transferJson = {
            'from': 'test',
            'to': 'test1',
            'amount': ['3000', 3, '@@000000037'],
            'memo': 'foobar'
        }
        t = Transfer(transferJson)
        self.assertEqual(transferJson, json.loads(str(t)))
        self.assertEqual(transferJson, t.json())
        self.assertEqual(transferJson, t.toJson())
        self.assertEqual(transferJson, t.__json__())

        o = Operation(Transfer(transferJson))
        self.assertEqual(o.json()[1], transferJson)
        tx = {
            'ref_block_num': 0,
            'ref_block_prefix': 0,
            'expiration': '2018-04-07T09:30:53',
            'operations': [o],
            'extensions': [],
            'signatures': []
        }
        s = Signed_Transaction(tx)
        s.sign(wifkeys=[wif], chain="STEEMAPPBASE")
        self.assertEqual(s.json()["operations"][0][1], transferJson)
예제 #8
0
파일: rc.py 프로젝트: symbiotes/beem
 def get_tx_size(self, op):
     """Returns the tx size of an operation"""
     ops = [Operation(op)]
     prefix = u"STEEM"
     wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"
     ref_block_num = 34294
     ref_block_prefix = 3707022213
     expiration = "2016-04-06T08:29:27"
     tx = Signed_Transaction(ref_block_num=ref_block_num,
                             ref_block_prefix=ref_block_prefix,
                             expiration=expiration,
                             operations=ops)
     tx = tx.sign([wif], chain=prefix)
     txWire = hexlify(py23_bytes(tx)).decode("ascii")
     tx_size = len(txWire)
     return tx_size
 def doit(self, printWire=False, ops=None):
     if ops is None:
         ops = [Operation(self.op)]
     tx = Ledger_Transaction(ref_block_num=ref_block_num,
                             ref_block_prefix=ref_block_prefix,
                             expiration=expiration,
                             operations=ops)
     txWire = hexlify(py23_bytes(tx)).decode("ascii")
     txApdu = tx.build_apdu(path, chain=prefix)
     if printWire:
         print()
         print(txWire)
         print()
     if len(self.cm) > 0:
         self.assertEqual(self.cm, txWire)
     if len(self.apdu) > 0:
         self.assertEqual(len(self.apdu), len(txApdu))
         for i in range(len(txApdu)):
             self.assertEqual(self.apdu[i], hexlify(txApdu[i]))
예제 #10
0
    def constructTx(self):
        """ Construct the actual transaction and store it in the class's dict
            store

        """
        ops = list()
        for op in self.ops:
            # otherwise, we simply wrap ops into Operations
            ops.extend([Operation(op)])

        # We no wrap everything into an actual transaction
        # ops = transactions.addRequiredFees(self.steem.rpc, ops)
        expiration = formatTimeFromNow(self.expiration
                                       or self.steem.expiration)
        ref_block_num, ref_block_prefix = transactions.getBlockParams(
            self.steem.rpc)
        self.tx = Signed_Transaction(ref_block_prefix=ref_block_prefix,
                                     expiration=expiration,
                                     operations=ops,
                                     ref_block_num=ref_block_num)

        super(TransactionBuilder, self).update(self.tx.json())
        self._unset_require_reconstruction()
예제 #11
0
 def list_operations(self):
     """List all ops"""
     return [Operation(o) for o in self.ops]
예제 #12
0
 def test_Operation(self):
     a = {"amount": '1000', "precision": 3, "nai": '@@000000013'}
     j = ["transfer", {'from': 'a', 'to': 'b', 'amount': a, 'memo': 'c'}]
     o = Operation(j)
     self.assertEqual(o.json()[1], j[1])
예제 #13
0
 def test_Operation(self):
     a = ['1000', 3, '@@000000013']
     j = ["transfer", {'from': 'a', 'to': 'b', 'amount': a, 'memo': 'c'}]
     o = Operation(j)
     self.assertEqual(o.json()[1], j[1])