-
Notifications
You must be signed in to change notification settings - Fork 5
/
sendADA.py
78 lines (72 loc) · 2.38 KB
/
sendADA.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import cardano_cli_helper as cli
import argparse
from os.path import exists
import time
def main(paymentAddrFile, paymentSkeyFile, recipientAddr, lovelace_amount, network='mainnet'):
if exists(paymentAddrFile):
with open(paymentAddrFile, 'r') as file:
paymentAddr = file.read().strip()
else:
paymentAddr = paymentAddrFile.strip()
if not exists(paymentSkeyFile):
print('ERROR: Payment skey file does not exist.')
return 0
if exists(recipientAddr): # If it doesn't exist assume it's a valid address
with open(recipientAddr, 'r') as file:
recipientAddr = file.read().strip()
lovelace = -1
while lovelace == -1:
lovelace, utxos = cli.getLovelaceBalance(
paymentAddr, network, onlyAda=True
)
time.sleep(5)
ttlSlot = cli.queryTip('slot', network) + 1000
cli.getRawTxSimple(
utxos, paymentAddr, recipientAddr,
lovelace_amount, ttlSlot, network=network
)
cli.signTx([paymentSkeyFile], network=network)
cli.submitSignedTx(network=network)
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument(
'-A', '--payment-addr-file',
default='/home/christos/skepsis_withdraw/payment.addr',
dest='payment_addr_file',
help='Provide location of payment address file.',
type=str
)
parser.add_argument(
'-K', '--payment-skey-file',
default='/home/christos/skepsis_withdraw/payment.skey',
dest='payment_skey_file',
help='Provide location of payment skey file.',
type=str
)
parser.add_argument(
'-D', '--destination',
default='/home/christos/skepsis_withdraw/myYoroi.addr',
dest='destination',
help='Provide location destination address file or string.',
type=str
)
parser.add_argument(
'-L', '--amount-lovelace',
default=1000000,
dest='amount',
help='Provide amount to send in lovelace.',
type=int
)
parser.add_argument(
'-N', '--network',
default='testnet-magic 9',
dest='network',
help='Provide cardano network.',
type=str
)
args = parser.parse_args()
main(args.payment_addr_file,
args.payment_skey_file,
args.destination,
args.amount,
args.network)