Skip to content

Commit

Permalink
Test patching updated fast withdraw code
Browse files Browse the repository at this point in the history
  • Loading branch information
CryptAxe committed Aug 2, 2024
1 parent cc6499e commit 7b887e8
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 153 deletions.
20 changes: 12 additions & 8 deletions net.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,29 @@ 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?
const FAST_WITHDRAW_CHAIN_TESTCHAIN : String = "Testchain"
const FAST_WITHDRAW_CHAIN_THUNDER : String = "Thunder"
const FAST_WITHDRAW_CHAIN_ZSIDE : String = "ZSide"

# 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)
signal fast_withdraw_requested(peer : int, chain_name : String, amount: float, destination: String)
signal fast_withdraw_invoice_paid(peer : int, chain_name : String, 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
# TODO add params: MC fee
@rpc("any_peer", "call_remote", "reliable")
func request_fast_withdraw(amount : float, destination : String) -> void:
func request_fast_withdraw(amount : float, chain_name: String, destination : String) -> void:
if print_debug_net:
print("Received fast withdrawal request")
print("Chain: ", chain_name)
print("Amount: ", amount)
print("Destination: ", destination)
print("Peer: ", multiplayer.get_remote_sender_id())

fast_withdraw_requested.emit(multiplayer.get_remote_sender_id(), amount, destination)
fast_withdraw_requested.emit(multiplayer.get_remote_sender_id(), chain_name, amount, destination)


@rpc("authority", "call_remote", "reliable")
Expand All @@ -37,15 +40,16 @@ func receive_fast_withdraw_invoice(amount : float, destination : String) -> void


@rpc("any_peer", "call_remote", "reliable")
func invoice_paid(txid: String, amount : float, destination : String) -> void:
func invoice_paid(chain_name : String, txid: String, amount : float, destination : String) -> void:
if print_debug_net:
print("Paid fast withdrawal invoice")
print("Chain: ", chain_name)
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)
fast_withdraw_invoice_paid.emit(multiplayer.get_remote_sender_id(), chain_name, txid, amount, destination)


@rpc("authority", "call_remote", "reliable")
Expand Down
243 changes: 98 additions & 145 deletions source/fast_withdrawal/fast_withdraw-new.tscn
Original file line number Diff line number Diff line change
@@ -1,83 +1,121 @@
[gd_scene load_steps=2 format=3 uid="uid://duvvgc45h86gp"]
[gd_scene load_steps=2 format=3 uid="uid://b5wmjp1psgsvr"]

[ext_resource type="Script" path="res://ui/components/fast_withdraw/fast_withdraw.gd" id="1_4itd0"]

[node name="FastWithdraw" type="VBoxContainer"]
[node name="FastWithdraw" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 3
size_flags_vertical = 3
script = ExtResource("1_4itd0")

[node name="Control2" type="Control" parent="."]
custom_minimum_size = Vector2(2.08165e-12, 5)
layout_mode = 2

[node name="HBoxContainer" type="HBoxContainer" parent="."]
layout_mode = 2

[node name="Control" type="Control" parent="HBoxContainer"]
custom_minimum_size = Vector2(10, 2.08165e-12)
layout_mode = 2
[node name="ButtonRequestInvoice" type="Button" parent="."]
layout_mode = 0
offset_left = 156.0
offset_top = 79.0
offset_right = 470.0
offset_bottom = 114.0
text = "Request fast withdrawal test invoice"

[node name="LineEditMainchainAddress" type="LineEdit" parent="HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="LineEditMainchainAddress" type="LineEdit" parent="."]
layout_mode = 0
offset_left = 10.0
offset_top = 12.0
offset_right = 425.0
offset_bottom = 43.0
placeholder_text = "Enter mainchain address"
expand_to_text_length = true

[node name="Control2" type="Control" parent="HBoxContainer"]
custom_minimum_size = Vector2(20, 2.08165e-12)
layout_mode = 2

[node name="Label" type="Label" parent="HBoxContainer"]
layout_mode = 2
text = "Amount to withdraw:
"
[node name="LabelInvoice" type="Label" parent="."]
layout_mode = 0
offset_left = 18.0
offset_top = 135.0
offset_right = 58.0
offset_bottom = 158.0

[node name="ButtonInvoicePaid" type="Button" parent="."]
layout_mode = 0
offset_left = 16.0
offset_top = 298.0
offset_right = 126.0
offset_bottom = 333.0
text = "Invoice Paid"

[node name="Control3" type="Control" parent="HBoxContainer"]
custom_minimum_size = Vector2(20, 2.08165e-12)
layout_mode = 2
[node name="LineEditTXID" type="LineEdit" parent="."]
layout_mode = 0
offset_left = 16.0
offset_top = 259.0
offset_right = 620.0
offset_bottom = 290.0
placeholder_text = "Enter L2 payment txid"

[node name="SpinBoxAmount" type="SpinBox" parent="HBoxContainer"]
layout_mode = 2
[node name="LabelComplete" type="Label" parent="."]
layout_mode = 0
offset_left = 17.0
offset_top = 341.0
offset_right = 548.0
offset_bottom = 364.0

[node name="SpinBoxAmount" type="SpinBox" parent="."]
layout_mode = 0
offset_left = 614.0
offset_top = 14.0
offset_right = 770.0
offset_bottom = 45.0
min_value = 1.0
value = 1.0
suffix = "BTC"

[node name="Control4" type="Control" parent="HBoxContainer"]
custom_minimum_size = Vector2(10, 2.08165e-12)
layout_mode = 2

[node name="Control5" type="Control" parent="HBoxContainer"]
custom_minimum_size = Vector2(2.08165e-12, 5)
layout_mode = 2

[node name="Control" type="Control" parent="."]
custom_minimum_size = Vector2(2.08165e-12, 10)
layout_mode = 2
[node name="Label" type="Label" parent="."]
layout_mode = 0
offset_left = 441.0
offset_top = 17.0
offset_right = 606.0
offset_bottom = 40.0
text = "Amount to withdraw:
"

[node name="Label2" type="Label" parent="."]
layout_mode = 2
text = " Sidechain to withdraw from:
[node name="ButtonCopyAddress" type="Button" parent="."]
layout_mode = 0
offset_left = 390.0
offset_top = 181.0
offset_right = 515.0
offset_bottom = 216.0
text = "Copy Address
"

[node name="Control6" type="Control" parent="."]
custom_minimum_size = Vector2(2.08165e-12, 5)
layout_mode = 2
[node name="CheckButtonLocalhost" type="CheckButton" parent="."]
layout_mode = 0
offset_left = 865.0
offset_top = 4.0
offset_right = 1016.0
offset_bottom = 35.0
text = "Debug server"

[node name="HBoxContainer2" type="HBoxContainer" parent="."]
layout_mode = 2
[node name="LabelConnectionStatus" type="Label" parent="."]
layout_mode = 0
offset_left = 488.0
offset_top = 88.0
offset_right = 604.0
offset_bottom = 111.0
text = "Not Connected"

[node name="Control2" type="Control" parent="HBoxContainer2"]
custom_minimum_size = Vector2(25, 2.08165e-12)
layout_mode = 2
[node name="Label2" type="Label" parent="."]
layout_mode = 0
offset_left = 14.0
offset_top = 51.0
offset_right = 198.0
offset_bottom = 72.0
text = "Sidechain to withdraw from:
"

[node name="ChainSelectionButton" type="OptionButton" parent="HBoxContainer2"]
layout_mode = 2
[node name="ChainSelectionButton" type="OptionButton" parent="."]
layout_mode = 0
offset_left = 16.0
offset_top = 79.0
offset_right = 40.0
offset_bottom = 99.0
item_count = 3
selected = 0
popup/item_0/text = "Testchain"
Expand All @@ -87,94 +125,9 @@ popup/item_1/id = 1
popup/item_2/text = "ZSide"
popup/item_2/id = 2

[node name="Control3" type="Control" parent="HBoxContainer2"]
custom_minimum_size = Vector2(15, 2.08165e-12)
layout_mode = 2

[node name="ButtonRequestInvoice" type="Button" parent="HBoxContainer2"]
layout_mode = 2
text = "Request fast withdrawal test invoice"

[node name="Control4" type="Control" parent="HBoxContainer2"]
custom_minimum_size = Vector2(15, 2.08165e-12)
layout_mode = 2
size_flags_horizontal = 3

[node name="LabelConnectionStatus" type="Label" parent="HBoxContainer2"]
layout_mode = 2
text = "Not Connected"

[node name="Control5" type="Control" parent="HBoxContainer2"]
custom_minimum_size = Vector2(15, 2.08165e-12)
layout_mode = 2

[node name="LabelInvoice" type="Label" parent="."]
layout_mode = 2

[node name="LabelComplete" type="Label" parent="."]
layout_mode = 2

[node name="ButtonCopyAddress" type="Button" parent="."]
custom_minimum_size = Vector2(200, 2.08165e-12)
layout_mode = 2
size_flags_horizontal = 4
text = "Copy Address
"

[node name="Control3" type="Control" parent="."]
custom_minimum_size = Vector2(2.08165e-12, 5)
layout_mode = 2

[node name="Control4" type="Control" parent="."]
custom_minimum_size = Vector2(2.08165e-12, 5)
layout_mode = 2

[node name="HBoxContainer4" type="HBoxContainer" parent="."]
layout_mode = 2

[node name="Control5" type="Control" parent="HBoxContainer4"]
custom_minimum_size = Vector2(15, 2.08165e-12)
layout_mode = 2

[node name="LineEditTXID" type="LineEdit" parent="HBoxContainer4"]
layout_mode = 2
size_flags_horizontal = 3
placeholder_text = "Enter L2 payment txid"
expand_to_text_length = true

[node name="Control6" type="Control" parent="HBoxContainer4"]
custom_minimum_size = Vector2(15, 2.08165e-12)
layout_mode = 2

[node name="Control5" type="Control" parent="."]
custom_minimum_size = Vector2(2.08165e-12, 5)
layout_mode = 2

[node name="HBoxContainer3" type="HBoxContainer" parent="."]
layout_mode = 2

[node name="Control5" type="Control" parent="HBoxContainer3"]
custom_minimum_size = Vector2(15, 2.08165e-12)
layout_mode = 2

[node name="ButtonInvoicePaid" type="Button" parent="HBoxContainer3"]
layout_mode = 2
text = "Invoice Paid"

[node name="Control6" type="Control" parent="HBoxContainer3"]
custom_minimum_size = Vector2(15, 2.08165e-12)
layout_mode = 2
size_flags_horizontal = 3

[node name="CheckButtonLocalhost" type="CheckButton" parent="HBoxContainer3"]
custom_minimum_size = Vector2(200, 2.08165e-12)
layout_mode = 2
text = "Debug server"

[node name="Control7" type="Control" parent="HBoxContainer3"]
custom_minimum_size = Vector2(15, 2.08165e-12)
layout_mode = 2

[connection signal="pressed" from="HBoxContainer2/ButtonRequestInvoice" to="." method="_on_button_request_invoice_pressed"]
[connection signal="pressed" from="ButtonRequestInvoice" to="." method="_on_button_request_invoice_pressed"]
[connection signal="pressed" from="ButtonRequestInvoice" to="." method="_on_button_test_pressed"]
[connection signal="pressed" from="ButtonInvoicePaid" to="." method="_on_button_invoice_paid_pressed"]
[connection signal="pressed" from="ButtonInvoicePaid" to="." method="_on_button_test_complete_pressed"]
[connection signal="pressed" from="ButtonCopyAddress" to="." method="_on_button_copy_address_pressed"]
[connection signal="pressed" from="HBoxContainer3/ButtonInvoicePaid" to="." method="_on_button_invoice_paid_pressed"]
[connection signal="item_selected" from="ChainSelectionButton" to="." method="_on_chain_selection_button_item_selected"]

0 comments on commit 7b887e8

Please sign in to comment.