def createAtomicSwapAccount(self, callback = None):
     _address, _public, _private = Crypto.generateKeys()
     privateBytes = bytearray()
     privateBytes.extend(_address)
     privateBytes.extend(_public)
     privateBytes.extend(_private)
     privateKey = Crypto.generateHash(privateBytes)
     self.createNewMultiSigAccountType(AccountType.ATOMIC_SWAP, privateKey, callback)
Example #2
0
    def extcodehash(self):
        address = self.pop()

        unspentTransactionScript = UXTO.getUnspentTransactionScript(address)
        txOut = unspentTransactionScript.output
        script = txOut.script

        _hash = 0 if script == None else Crypto.generateHash(script, Config.getValue('SHA3_HASHING_ALGORITHM'))
        self.stack.append(_hash)
Example #3
0
 def init(self):
     merkleNodes = []
     for transaction in self.transactions:
         merkleNode = MerkleNode()
         txHash = transaction.hashTxWitness(
         ) if self.includeWitness else transaction.hash()
         merkleNode.hash = Crypto.generateHash(txHash)
         merkleNodes.append(merkleNode)
     self.generateMerkleTree(merkleNodes)
     self.merkleNodes.extend(merkleNodes)
Example #4
0
 def generateMerkleTree(self, prevMerkleNodes):
     if len(prevMerkleNodes) > 1:
         merkleNodes = []
         merkleNode = None
         for prevMerkleNode in prevMerkleNodes:
             if merkleNode == None:
                 merkleNode = MerkleNode()
             if merkleNode.left == None:
                 merkleNode.left = prevMerkleNode
             elif merkleNode.right == None:
                 merkleNode.right = prevMerkleNode
             if merkleNode.left != None and merkleNode.right != None:
                 data = merkleNode.left.hash + merkleNode.right.hash
                 merkleNode.hash = Crypto.generateHash(data)
                 merkleNodes.append(merkleNode)
                 merkleNode = None
         if merkleNode != None:
             merkleNode.hash = Crypto.generateHash(merkleNode.left.hash)
             merkleNodes.append(merkleNode)
         self.generateMerkleTree(merkleNodes)
         self.merkleNodes.extend(merkleNodes)
Example #5
0
 def sha256(self):
     data = self.pop()
     _hash = Crypto.generateHash(data, Config.getValue('SHA2_HASHING_ALGORITHM'))
     self.stack.append(_hash)
 def hashTxWitness(self):
     return Crypto.generateHash(self.serialize())
 def hash(self):
     includeWitness = self.isCoinbase()
     return Crypto.generateHash(self.serialize(includeWitness))