forked from btcpayserver/btcpayserver-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jm.sh
executable file
·107 lines (100 loc) · 2.64 KB
/
jm.sh
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/bash
function display_help () {
cat <<-END
Usage:
------
Tooling to setup your joinmarket yield generator
wallet-tool: Run wallet-tools.py on the wallet
wallet-tool-generate: Generate a new wallet
set-wallet: Set the wallet that the yield generator need to use
bash: Open an interactive bash session in the joinmarket container
receive-payjoin: Receive a payjoin payment
sendpayment: Send a payjoin through coinjoin (password needed)
reset-config: Reset the configuration to its default value
Example:
* jm.sh wallet-tool-generate
* jm.sh set-wallet wallet.jmdat mypassword
* jm.sh wallet-tool
* jm.sh receive-payjoin <amount>
* jm.sh sendpayment <amount> <address>
* jm.sh wallet-tool history
* jm.sh reset-config
* jm.sh bash
See https://github.com/btcpayserver/btcpayserver-docker/tree/master/docs/joinmarket.md for more information.
END
}
while (( "$#" )); do
case "$1" in
bash)
CMD="$1"
shift 1
break;
;;
reset-config)
CMD="$1"
shift 1
break;
;;
wallet-tool)
CMD="$1"
shift 1
break;
;;
set-wallet)
CMD="$1"
shift 1
break;
;;
receive-payjoin)
CMD="$1"
shift 1
break;
;;
sendpayment)
CMD="$1"
shift 1
break;
;;
wallet-tool-generate)
CMD="$1"
shift 1
break;
;;
--) # end argument parsing
shift
break
;;
-*|--*=) # unsupported flags
echo "Error: Unsupported flag $1" >&2
display_help
return
;;
*) # preserve positional arguments
PARAMS="$PARAMS $1"
shift
;;
esac
done
if ! [[ "$CMD" ]]; then
display_help
else
if [[ "$CMD" == "wallet-tool" ]]; then
docker exec joinmarket exec-wrapper.sh unlockwallet wallet-tool.py "$@"
elif [[ "$CMD" == "wallet-tool-generate" ]]; then
docker exec -ti joinmarket exec-wrapper.sh wallet-tool.py generate "$@"
elif [[ "$CMD" == "sendpayment" ]]; then
docker exec -ti joinmarket exec-wrapper.sh unlockwallet nopass sendpayment.py "$@"
elif [[ "$CMD" == "receive-payjoin" ]]; then
docker exec -ti joinmarket exec-wrapper.sh unlockwallet receive-payjoin.py "$@"
elif [[ "$CMD" == "set-wallet" ]]; then
docker exec joinmarket set-wallet.sh "$@"
docker restart joinmarket
elif [[ "$CMD" == "reset-config" ]]; then
docker exec -ti joinmarket bash -c 'rm -f "$CONFIG"'
docker restart joinmarket
elif [[ "$CMD" == "bash" ]]; then
docker exec -ti joinmarket exec-wrapper.sh bash "$@"
else
display_help
fi
fi