Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def burnAsset(self, Asset, quantity, txFee=pywaves.DEFAULT_TX_FEE):
timestamp = int(time.time() * 1000)
sData = '\6' + \
crypto.bytes2str(base58.b58decode(self.publicKey)) + \
crypto.bytes2str(base58.b58decode(Asset.assetId)) + \
crypto.bytes2str(struct.pack(">Q", quantity)) + \
crypto.bytes2str(struct.pack(">Q", txFee)) + \
crypto.bytes2str(struct.pack(">Q", timestamp))
signature = crypto.sign(self.privateKey, crypto.str2bytes(sData))
data = json.dumps({
"senderPublicKey": self.publicKey,
"assetId": Asset.assetId,
"quantity": quantity,
"timestamp": timestamp,
"fee": txFee,
"signature": signature
})
req = pywaves.wrapper('/assets/broadcast/burn', data)
if pywaves.OFFLINE:
return req
else:
return req.get('id', 'ERROR')
txFee = max(txFee, 500000)
dataObject['fee'] = txFee
sData = b'\x0c' + \
b'\1' + \
base58.b58decode(self.publicKey) + \
struct.pack(">H", len(data)) + \
dataBinary + \
struct.pack(">Q", timestamp) + \
struct.pack(">Q", txFee)
dataObject['proofs'] = [ crypto.sign(self.privateKey, sData) ]
for entry in dataObject['data']:
if entry['type'] == 'binary':
base64Encoded = base64.b64encode(crypto.str2bytes(entry['value']))
entry['value'] = 'base64:' + crypto.bytes2str(base64Encoded)
dataObjectJSON = json.dumps(dataObject)
return pywaves.wrapper('/transactions/broadcast', dataObjectJSON)
def burnAsset(self, Asset, quantity, txFee=pywaves.DEFAULT_TX_FEE):
timestamp = int(time.time() * 1000)
sData = '\6' + \
crypto.bytes2str(base58.b58decode(self.publicKey)) + \
crypto.bytes2str(base58.b58decode(Asset.assetId)) + \
crypto.bytes2str(struct.pack(">Q", quantity)) + \
crypto.bytes2str(struct.pack(">Q", txFee)) + \
crypto.bytes2str(struct.pack(">Q", timestamp))
signature = crypto.sign(self.privateKey, crypto.str2bytes(sData))
data = json.dumps({
"senderPublicKey": self.publicKey,
"assetId": Asset.assetId,
"quantity": quantity,
"timestamp": timestamp,
"fee": txFee,
"signature": signature
})
req = pywaves.wrapper('/assets/broadcast/burn', data)
if pywaves.OFFLINE:
return req