Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
timestamp = int(time.time() * 1000)
transfersData = b''
for i in range(0, len(transfers)):
transfersData += base58.b58decode(transfers[i]['recipient']) + struct.pack(">Q", transfers[i]['amount'])
sData = b'\x0b' + \
b'\1' + \
base58.b58decode(self.publicKey) + \
b'\0' + \
struct.pack(">H", len(transfers)) + \
transfersData + \
struct.pack(">Q", timestamp) + \
struct.pack(">Q", txFee) + \
struct.pack(">H", len(attachment)) + \
crypto.str2bytes(attachment)
signature = crypto.sign(self.privateKey, sData)
data = json.dumps({
"type": 11,
"version": 1,
"assetId": "",
"senderPublicKey": self.publicKey,
"fee": txFee,
"timestamp": timestamp,
"transfers": transfers,
"attachment": base58.b58encode(crypto.str2bytes(attachment)),
"signature": signature,
"proofs": [
signature
]
})
def getOrderHistory(self, assetPair, timestamp=0):
if timestamp == 0:
timestamp = int(time.time() * 1000)
sData = base58.b58decode(self.publicKey) + \
struct.pack(">Q", timestamp)
signature = crypto.sign(self.privateKey, sData)
data = {
"Accept": "application/json",
"Timestamp": str(timestamp),
"Signature": signature
}
req = pywaves.wrapper('/matcher/orderbook/%s/%s/publicKey/%s' % ('WAVES' if assetPair.asset1.assetId=='' else assetPair.asset1.assetId, 'WAVES' if assetPair.asset2.assetId=='' else assetPair.asset2.assetId, self.publicKey), headers=data, host=pywaves.MATCHER)
return req
def _generate(self, publicKey='', privateKey='', seed='', nonce=0):
self.seed = seed
self.nonce = nonce
if not publicKey and not privateKey and not seed:
wordCount = 2048
words = []
for i in range(5):
r = crypto.bytes2str(os.urandom(4))
x = (ord(r[3])) + (ord(r[2]) << 8) + (ord(r[1]) << 16) + (ord(r[0]) << 24)
w1 = x % wordCount
w2 = ((int(x / wordCount) >> 0) + w1) % wordCount
w3 = ((int((int(x / wordCount) >> 0) / wordCount) >> 0) + w2) % wordCount
words.append(wordList[w1])
words.append(wordList[w2])
words.append(wordList[w3])
self.seed = ' '.join(words)
if publicKey:
pubKey = base58.b58decode(publicKey)
privKey = ""
else:
seedHash = crypto.hashChain(struct.pack(">L", nonce) + crypto.str2bytes(self.seed))
accountSeedHash = crypto.sha256(seedHash)
if not privateKey:
privKey = curve.generatePrivateKey(accountSeedHash)
timestamp = int(time.time() * 1000)
sData = b'\4' + version + b'\4'
if version == b'\2':
sData += version
sData += base58.b58decode(publicKey) + \
(b'\1' + base58.b58decode(asset.assetId) if asset else b'\0') + \
(b'\1' + base58.b58decode(feeAsset.assetId) if feeAsset else b'\0') + \
struct.pack(">Q", timestamp) + \
struct.pack(">Q", amount) + \
struct.pack(">Q", txFee) + \
base58.b58decode(recipient.address) + \
struct.pack(">H", len(attachment)) + \
pwcrypto.str2bytes(attachment)
return sData