def lease(self, recipient, amount, txFee=pywaves.DEFAULT_LEASE_FEE, timestamp=0):
if not self.privateKey:
logging.error('Private key required')
elif amount <= 0:
logging.error('Amount must be > 0')
elif not pywaves.OFFLINE and self.balance() < amount + txFee:
logging.error('Insufficient Waves balance')
else:
if timestamp == 0:
timestamp = int(time.time() * 1000)
sData = b'\x08' + \
base58.b58decode(self.publicKey) + \
base58.b58decode(recipient.address) + \
struct.pack(">Q", amount) + \
struct.pack(">Q", txFee) + \
struct.pack(">Q", timestamp)
signature = crypto.sign(self.privateKey, sData)
data = json.dumps({
"senderPublicKey": self.publicKey,
"recipient": recipient.address,
"amount": amount,
"fee": txFee,
"timestamp": timestamp,
"signature": signature
})
req = pywaves.wrapper('/leasing/broadcast/lease', data)
if pywaves.OFFLINE:
return req
else:
return req['id']
评论列表
文章目录