-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathnet.gd
59 lines (44 loc) · 2.05 KB
/
net.gd
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
extends Node
# Enable this for debug printing in net.gd and fast_withdraw.gd
var print_debug_net : bool = false
# TODO rename this and move it on the server as well?
# Server signals
signal fast_withdraw_requested(peer : int, amount: float, destination: String)
signal fast_withdraw_invoice_paid(peer : int, txid: String, amount: float, destination: String)
# Client signals
signal fast_withdraw_invoice(amount: float, destination: String)
signal fast_withdraw_complete(txid: String, amount: float, destination: String)
# TODO add params: SC #, MC fee, MC destination
@rpc("any_peer", "call_remote", "reliable")
func request_fast_withdraw(amount : float, destination : String) -> void:
if print_debug_net:
print("Received fast withdrawal request")
print("Amount: ", amount)
print("Destination: ", destination)
print("Peer: ", multiplayer.get_remote_sender_id())
fast_withdraw_requested.emit(multiplayer.get_remote_sender_id(), amount, destination)
@rpc("authority", "call_remote", "reliable")
func receive_fast_withdraw_invoice(amount : float, destination : String) -> void:
if print_debug_net:
print("Received fast withdrawal invoice")
print("Amount: ", amount)
print("Destination: ", destination)
print("Peer: ", multiplayer.get_remote_sender_id())
fast_withdraw_invoice.emit(amount, destination)
@rpc("any_peer", "call_remote", "reliable")
func invoice_paid(txid: String, amount : float, destination : String) -> void:
if print_debug_net:
print("Paid fast withdrawal invoice")
print("Amount: ", amount)
print("Destination: ", destination)
print("Txid: ", txid)
print("Peer: ", multiplayer.get_remote_sender_id())
fast_withdraw_invoice_paid.emit(multiplayer.get_remote_sender_id(), txid, amount, destination)
@rpc("authority", "call_remote", "reliable")
func withdraw_complete(txid: String, amount : float, destination : String) -> void:
if print_debug_net:
print("Fast withdraw completed!")
print("Amount: ", amount)
print("Destination: ", destination)
print("Txid: ", txid)
fast_withdraw_complete.emit(txid, amount, destination)