Skip to content
Permalink
Browse files

Making pywaves more dynamic without breaking old functionality

  • Loading branch information
bnagtega
bnagtega committed Jun 30, 2019
1 parent 091bb6c commit e73f0de15c5e9fd3016d9e1008f5bda967eeb131
Showing with 10 additions and 9 deletions.
  1. +2 −0 __init__.py
  2. +8 −9 address.py
@@ -12,6 +12,8 @@
from __future__ import absolute_import, division, print_function, unicode_literals

DEFAULT_TX_FEE = 100000
DEFAULT_BASE_FEE = DEFAULT_TX_FEE
DEFAULT_SMART_FEE = 400000
DEFAULT_ASSET_FEE = 100000000
DEFAULT_MATCHER_FEE = 300000
DEFAULT_LEASE_FEE = 100000
@@ -431,8 +431,8 @@ def sendWaves(self, recipient, amount, attachment='', txFee=pywaves.DEFAULT_TX_F

return pywaves.wrapper('/transactions/broadcast', data)

def massTransferWaves(self, transfers, attachment='', timestamp=0):
txFee = 100000 + (math.ceil((len(transfers) + 1) / 2 - 0.5)) * 100000
def massTransferWaves(self, transfers, attachment='', timestamp=0,baseFee=pywaves.DEFAULT_BASE_FEE):
txFee = baseFee + (math.ceil((len(transfers) + 1) / 2 - 0.5)) * baseFee
totalAmount = 0

for i in range(0, len(transfers)):
@@ -550,11 +550,11 @@ def sendAsset(self, recipient, asset, amount, attachment='', feeAsset='', txFee=

return pywaves.wrapper('/assets/broadcast/transfer', data)

def massTransferAssets(self, transfers, asset, attachment='', timestamp=0):
txFee = 100000 + (math.ceil((len(transfers) + 1) / 2 - 0.5)) * 100000
def massTransferAssets(self, transfers, asset, attachment='', timestamp=0,baseFee=pywaves.DEFAULT_BASE_FEE,smartFee=pywaves.DEFAULT_SMART_FEE):
txFee = baseFee + (math.ceil((len(transfers) + 1) / 2 - 0.5)) * baseFee

if (asset.isSmart()):
txFee += 400000
txFee += smartFee

totalAmount = 0

@@ -603,7 +603,7 @@ def massTransferAssets(self, transfers, asset, attachment='', timestamp=0):

return pywaves.wrapper('/transactions/broadcast', data)

def dataTransaction(self, data, timestamp=0):
def dataTransaction(self, data, timestamp=0, baseFee=pywaves.DEFAULT_BASE_FEE, minimalFee=500000):
if not self.privateKey:
logging.error('Private key required')
else:
@@ -642,8 +642,8 @@ def dataTransaction(self, data, timestamp=0):
dataBinary += struct.pack(">H", len(d['value']))
dataBinary += crypto.str2bytes(d['value'])
# check: https://stackoverflow.com/questions/2356501/how-do-you-round-up-a-number-in-python
txFee = (int(((len(crypto.str2bytes(json.dumps(data))) + 2 + 64 )) / 1000.0) + 1 ) * 100000
txFee = max(txFee, 500000)
txFee = (int(((len(crypto.str2bytes(json.dumps(data))) + 2 + 64 )) / 1000.0) + 1 ) * baseFee
txFee = max(txFee, minimalFee)
dataObject['fee'] = txFee
sData = b'\x0c' + \
b'\1' + \
@@ -1080,7 +1080,6 @@ def issueSmartAsset(self, name, description, quantity, scriptSource, decimals=0,
"proofs": [ signature ],
"script": 'base64:' + script
})
print(data)
req = pywaves.wrapper('/transactions/broadcast', data)
if pywaves.OFFLINE:
return req

0 comments on commit e73f0de

Please sign in to comment.
You can’t perform that action at this time.