Skip to content

Commit 575550d

Browse files
committed
Update to include comma separated pay file. Include dynamic fee for large multipay tx. More verbose logging
1 parent ca88fa1 commit 575550d

File tree

2 files changed

+50
-18
lines changed

2 files changed

+50
-18
lines changed

.github/.DS_Store

6 KB
Binary file not shown.

SentinelMultiPay.py

Lines changed: 50 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import scrtxxs
44
import requests
5+
import argparse
56
import sys
67
from os import path, mkdir
78
from urllib.parse import urlparse
@@ -111,9 +112,9 @@ def SendDVPNs(self, addr_amts, wallet_balance: int):
111112
return False
112113

113114
tx_params = TxParams(
114-
gas=300000,
115+
gas=0,
115116
gas_multiplier=1.15,
116-
fee_amount=30000,
117+
fee_amount=30000*int(len(addr_amts.values())/4),
117118
denom="udvpn"
118119
)
119120

@@ -153,38 +154,69 @@ def SendDVPNs(self, addr_amts, wallet_balance: int):
153154
print("debug_error_string", rpc_error.debug_error_string())
154155
self.logfile.write("[sp]: RPC ERROR. ")
155156
return False
157+
except:
158+
print("ERROR Broadcasting")
159+
return False
160+
161+
#print(tx.get("log"))
156162

157163
if tx.get("log", None) is None:
158164
tx_response = self.sdk.nodes.wait_for_tx(tx["hash"])
159165
tx_height = tx_response.get("txResponse", {}).get("height", 0) if isinstance(tx_response, dict) else tx_response.tx_response.height
160166

161-
message = f"Succefully sent {amt}udvpn at height: {tx_height} distributed by {addr_amts}" if tx.get("log", None) is None else tx["log"]
167+
message = f"Succefully sent {amt}udvpn at height: {tx_height} distributed by {addr_amts}, tx: {tx.get('hash', None)}" if tx.get("log", None) is None else tx["log"]
162168
self.logfile.write(f"[sp]: {message}\n")
163169
return True
164-
170+
else:
171+
self.logfile.write(tx.get("log"))
165172

166173
if __name__ == "__main__":
167-
print(f"Leeloo Dallas Multipay - A DVPN multipay transactor - by freQniK - version: 5th Element {VERSION}\n\n")
168-
print("You will be presented with a loop to enter Sentinel wallet addresses and amt. When finished, enter 'done'")
169-
mp = MultiPay(scrtxxs.HotWalletPW, scrtxxs.WalletName, scrtxxs.WalletSeed)
174+
SendDict = {}
175+
176+
parser = argparse.ArgumentParser(description=f"Leeloo Dallas Multipay - A DVPN multipay transactor - by freQniK - version: 5th Element {VERSION}")
177+
178+
parser.add_argument('--file', help="absolute path of comma separated payout file. e.g.: (address,dvpn)", metavar="file")
179+
args = parser.parse_args()
170180

181+
mp = MultiPay(scrtxxs.HotWalletPW, scrtxxs.WalletName, scrtxxs.WalletSeed)
171182
balance = mp.get_balance(mp.sdk._account.address)
172183
wallet_balance = float(int(balance.get("dvpn", 0)) / SATOSHI)
173184

174-
print(f"Balance: {wallet_balance} dvpn")
175-
176-
SendDict = {}
185+
if args.file:
186+
with open(args.file, "r") as payoutfile:
187+
payoutdata = payoutfile.readlines()
188+
189+
for payout in payoutdata:
190+
addr,amt = payout.split(',')
191+
SendDict[addr] = str(int(float(amt) * SATOSHI))
192+
193+
else:
194+
print("You will be presented with a loop to enter Sentinel wallet addresses and amt. When finished, enter 'done'")
177195

178-
while True:
179-
addr = input("Enter wallet address: ")
180-
if addr.upper() == "DONE":
181-
break
182-
amt = input("Enter dvpn amt to send to wallet: ")
183-
184-
SendDict[addr] = str(int(float(amt) * SATOSHI))
185-
196+
while True:
197+
addr = input("Enter wallet address: ")
198+
if addr.upper() == "DONE":
199+
break
200+
amt = input("Enter dvpn amt to send to wallet: ")
201+
202+
SendDict[addr] = str(int(float(amt) * SATOSHI))
203+
186204
print("The following addresses will receive these repsective amounts: ")
187205
print(SendDict)
206+
total = 0
207+
208+
for amt in SendDict.values():
209+
total += float(amt)
210+
211+
totalDVPN = round(float((int(total) / SATOSHI)),4)
212+
213+
print(f"\nBalance: {wallet_balance} dvpn")
214+
print(f"Payout : {totalDVPN} dvpn")
215+
216+
if totalDVPN >= wallet_balance*SATOSHI:
217+
print("Total exceeds wallet balance... Quitting")
218+
sys.exit(1)
219+
188220
answer = input("Would you like to continue (Y/n): ")
189221
if answer.upper() == "Y":
190222
if mp.SendDVPNs(SendDict, int(wallet_balance * SATOSHI)):

0 commit comments

Comments
 (0)