|
2 | 2 |
|
3 | 3 | import scrtxxs
|
4 | 4 | import requests
|
| 5 | +import argparse |
5 | 6 | import sys
|
6 | 7 | from os import path, mkdir
|
7 | 8 | from urllib.parse import urlparse
|
@@ -111,9 +112,9 @@ def SendDVPNs(self, addr_amts, wallet_balance: int):
|
111 | 112 | return False
|
112 | 113 |
|
113 | 114 | tx_params = TxParams(
|
114 |
| - gas=300000, |
| 115 | + gas=0, |
115 | 116 | gas_multiplier=1.15,
|
116 |
| - fee_amount=30000, |
| 117 | + fee_amount=30000*int(len(addr_amts.values())/4), |
117 | 118 | denom="udvpn"
|
118 | 119 | )
|
119 | 120 |
|
@@ -153,38 +154,69 @@ def SendDVPNs(self, addr_amts, wallet_balance: int):
|
153 | 154 | print("debug_error_string", rpc_error.debug_error_string())
|
154 | 155 | self.logfile.write("[sp]: RPC ERROR. ")
|
155 | 156 | return False
|
| 157 | + except: |
| 158 | + print("ERROR Broadcasting") |
| 159 | + return False |
| 160 | + |
| 161 | + #print(tx.get("log")) |
156 | 162 |
|
157 | 163 | if tx.get("log", None) is None:
|
158 | 164 | tx_response = self.sdk.nodes.wait_for_tx(tx["hash"])
|
159 | 165 | tx_height = tx_response.get("txResponse", {}).get("height", 0) if isinstance(tx_response, dict) else tx_response.tx_response.height
|
160 | 166 |
|
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"] |
162 | 168 | self.logfile.write(f"[sp]: {message}\n")
|
163 | 169 | return True
|
164 |
| - |
| 170 | + else: |
| 171 | + self.logfile.write(tx.get("log")) |
165 | 172 |
|
166 | 173 | 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() |
170 | 180 |
|
| 181 | + mp = MultiPay(scrtxxs.HotWalletPW, scrtxxs.WalletName, scrtxxs.WalletSeed) |
171 | 182 | balance = mp.get_balance(mp.sdk._account.address)
|
172 | 183 | wallet_balance = float(int(balance.get("dvpn", 0)) / SATOSHI)
|
173 | 184 |
|
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'") |
177 | 195 |
|
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 | + |
186 | 204 | print("The following addresses will receive these repsective amounts: ")
|
187 | 205 | 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 | + |
188 | 220 | answer = input("Would you like to continue (Y/n): ")
|
189 | 221 | if answer.upper() == "Y":
|
190 | 222 | if mp.SendDVPNs(SendDict, int(wallet_balance * SATOSHI)):
|
|
0 commit comments