Skip to content

Commit

Permalink
Added quotes scrolling on the bottom. Added Fast Withdrawal updates. …
Browse files Browse the repository at this point in the history
…Wallet creation now saves seed info in starters folder as well as starting info for each provided chain. Eliminated some resolution options
  • Loading branch information
Marc Platt authored and Marc Platt committed Jul 24, 2024
1 parent 1b9667a commit 5b294b1
Show file tree
Hide file tree
Showing 18 changed files with 545 additions and 229 deletions.
Binary file modified .DS_Store
Binary file not shown.
22 changes: 17 additions & 5 deletions assets/data/quotes.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
"quote": "Inflation is taxation without legislation.",
"author": "Milton Friedman"
},
{
"quote": "Used to the conditions of a capitalistic environment, the average American takes it for granted that every year business makes something new and better accessible to him. Looking backward upon the years of his own life, he realizes that many implements that were totally unknown in the days of his youth and many others which at that time could be enjoyed only by a small minority are now standard equipment of almost every household.",
"author": "Ludwig Von Mises"
},
{
"quote": "Poorly paid labor is inefficient labor, the world over.",
"author": "Henry George"
Expand All @@ -34,5 +30,21 @@
{
"quote": "Ambition is common to all men; and those, who are unable to rise to distinction, are at least willing to reduce others to their own standard.",
"author": "William Godwin"
}
},
{
"quote": "Organizations are permanently and randomly subject to decline and decay - no matter their institutional framework.",
"author": "Albert Hirschman"
},
{
"quote": "Monopolies don't innovate. The motto of any monopoly is: 'We don't care, because we don't have to'",
"author": "Marc Andreessen"
},
{
"quote": "It is self-deception to think that the status quo is going to be satisfactory for everyone forever. It's already not satisfactory for a lot of people",
"author": "David Deutsch"
},
{
"quote": "Ambition is common to all men; and those, who are unable to rise to distinction, are at least willing to reduce others to their own standard",
"author": "William Godwin"
},
]
119 changes: 62 additions & 57 deletions source/application/application.tscn

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions source/application/mnemonic.gd
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ func setup_grid():
for child in get_children():
child.queue_free()

var font = load("res://assets/fonts/Satoshi-Bold.otf")
var font = load(header_font_path)
var small_font = font.duplicate()
var default_size = 16 # Set this to your desired default font size
var default_size = 14 # Set this to your desired default font size
var small_size = int(default_size * 0.7) # Adjust this factor to get the desired size

# Set up the grid
Expand Down
110 changes: 93 additions & 17 deletions source/application/wallet_creator.gd
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,14 @@ func _on_return_button_pressed():
clear_all_output()

func save_wallet_data():
var file = FileAccess.open("res://wallet_master_seeds.txt", FileAccess.WRITE)
var json_string = JSON.stringify(current_wallet_data)
file.store_line(json_string)
var seed_data = {
"seed_hex": current_wallet_data["seed"],
"seed_binary": current_wallet_data["bip39_bin"],
"mnemonic": current_wallet_data["mnemonic"]
}
var file = FileAccess.open("res://starters/wallet_master_seed.txt", FileAccess.WRITE)
var json_string = JSON.stringify(seed_data)
file.store_string(json_string)
file.close()

func _create_wallet(input: String):
Expand Down Expand Up @@ -380,6 +385,12 @@ func _on_background_gui_input(event):

func _on_popup_yes_pressed():
save_wallet_data()

var Bitcoin = BitcoinWallet.new()
var sidechain_slots = get_sidechain_info()
var sidechain_data = Bitcoin.generate_sidechain_starters(current_wallet_data["seed"], current_wallet_data["mnemonic"], sidechain_slots)
save_sidechain_info(sidechain_data)

_on_popup_close_pressed()

func _on_popup_close_pressed() -> void:
Expand All @@ -400,12 +411,42 @@ func _toggle_output_visibility(is_visible: bool):

var bip39_info_label = bip39_panel.get_node("BIP39Info")
if bip39_info_label:
bip39_info_label.visible = is_visible
if is_visible:
# Restore the full content
update_bip39_panel(current_wallet_data)
else:
# Keep only headers visible
var headers_text = """[table=2]
[cell][color=white][b][u]BIP39 Hex:[/u][/b][/color][/cell] [cell][/cell]
[cell][color=white][b][u]BIP39 Bin:
[/u][/b][/color][/cell] [cell][/cell]
[cell][color=white][b][u]BIP39 Checksum:[/u][/b][/color][/cell] [cell][/cell]
[cell][color=white][b][u]BIP39 Checksum Hex:[/u][/b][/color][/cell] [cell][/cell]
[/table]"""
bip39_info_label.text = headers_text

# Toggle visibility for Launch panel info
var launch_info_label = launch_panel.get_node("VBoxContainer/LaunchInfo")
if launch_info_label:
launch_info_label.visible = is_visible
if is_visible:
# Restore the full content
update_launch_panel(current_wallet_data)
else:
# Keep only headers visible
var headers_text = """[table=2]
[cell][color=white][b][u]HD Key Data:
[/u][/b][/color][/cell] [cell][/cell]
[cell][color=white][b][u]Master Key:
[/u][/b][/color][/cell] [cell][/cell]
[cell][color=white][b][u]Chain Code:
[/u][/b][/color][/cell] [cell][/cell]
[/table]"""
launch_info_label.text = headers_text

func _on_load_button_pressed():
var wallet = BitcoinWallet.new()
Expand All @@ -427,21 +468,56 @@ func _on_load_button_pressed():
return
print("Wallet generated successfully:")

# Write wallet info to file
var file = FileAccess.open("res://wallet_master_seeds.txt", FileAccess.WRITE)
if file:
var json_string = JSON.stringify(result)
file.store_line(json_string)
file.close()
if tabs:
tabs.current_tab = 1
print("Wallet information saved to wallet_master_seeds.txt")
else:
print("Error: Unable to write to wallet_master_seeds.txt")
# Save master wallet data in the new format
var seed_data = {
"mnemonic": result["mnemonic"],
"seed_binary": result["bip39_bin"],
"seed_hex": result["seed"]
}
var file = FileAccess.open("res://starters/wallet_master_seed.txt", FileAccess.WRITE)
var json_string = JSON.stringify(seed_data)
file.store_string(json_string)
file.close()

# Generate and save sidechain starters
var sidechain_slots = get_sidechain_info()
var sidechain_data = wallet.generate_sidechain_starters(result["seed"], result["mnemonic"], sidechain_slots)
save_sidechain_info(sidechain_data)

if tabs:
tabs.current_tab = 1
print("Wallet and sidechain information saved.")

func _on_fast_button_pressed():
entropy_in.text = ""
var wallet_generator = BitcoinWallet.new()
var entropy = wallet_generator.fast_create()
entropy_in.text = entropy
_on_entropy_in_changed(entropy)

func get_sidechain_info():
var sidechain_info = []
var file = FileAccess.open("res://chain_providers.cfg", FileAccess.READ)
if file:
var current_section = ""
while !file.eof_reached():
var line = file.get_line().strip_edges()
if line.begins_with("[") and line.ends_with("]"):
current_section = line.substr(1, line.length() - 2)
elif line.begins_with("slot=") and current_section != "drivechain":
var slot = line.split("=")[1].to_int()
if slot != -1:
sidechain_info.append(slot)
return sidechain_info

func save_sidechain_info(sidechain_data):
for key in sidechain_data.keys():
if key.begins_with("sidechain_"):
var slot = key.split("_")[1]
var filename = "res://starters/sidechain_%s_starter.txt" % slot
var file = FileAccess.open(filename, FileAccess.WRITE)
if file:
file.store_string(JSON.stringify(sidechain_data[key]))
file.close()
else:
print("Failed to save sidechain starter information for slot ", slot)
133 changes: 133 additions & 0 deletions source/fast_withdrawal/fast_withdraw-new.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
extends Control

const SERVER_LOCALHOST : String = "127.0.0.1"
const SERVER_L2L_GA : String = "172.105.148.135"
const PORT : int = 8382

var invoice_address : String = ""
var connected_to_server : bool = false
var selected_chain : String = ""

signal fast_withdraw_server_connection_status_changed

func _ready() -> void:
$LabelConnectionStatus.visible = false

selected_chain = $"/root/Net".FAST_WITHDRAW_CHAIN_TESTCHAIN

multiplayer.connected_to_server.connect(_on_connected_to_withdrawal_server)
multiplayer.connection_failed.connect(_on_failed_connect_to_withdrawal_server)
multiplayer.server_disconnected.connect(_on_disconnected_from_withdrawal_server)

$"/root/Net".fast_withdraw_invoice.connect(_on_fast_withdraw_invoice)
$"/root/Net".fast_withdraw_complete.connect(_on_fast_withdraw_complete)


func _on_connected_to_withdrawal_server() -> void:
if $"/root/Net".print_debug_net:
print("Connected to fast withdraw server")

$LabelConnectionStatus.text = "Connected"

connected_to_server = true
fast_withdraw_server_connection_status_changed.emit()


func _on_disconnected_from_withdrawal_server() -> void:
if $"/root/Net".print_debug_net:
print("Disonnected from fast withdraw server")

$LabelConnectionStatus.text = "Disconnected"
$LabelInvoice.text = ""
connected_to_server = false
fast_withdraw_server_connection_status_changed.emit()


func _on_failed_connect_to_withdrawal_server() -> void:
if $"/root/Net".print_debug_net:
print("Failed to connect to fast withdraw server")

$LabelConnectionStatus.text = "Not Connected"

connected_to_server = false
fast_withdraw_server_connection_status_changed.emit()


func connect_to_withdrawal_server() -> void:
# Create fast withdraw client
var peer = ENetMultiplayerPeer.new()
if $CheckButtonLocalhost.is_pressed():
if $"/root/Net".print_debug_net:
print("Using fast withdraw server: localhost")

var error = peer.create_client(SERVER_LOCALHOST, PORT)
if error and $"/root/Net".print_debug_net:
print_debug("Error: ", error)
else:
if $"/root/Net".print_debug_net:
print("Using fast withdraw server: L2L-GA")
var error = peer.create_client(SERVER_L2L_GA, PORT)
if error and $"/root/Net".print_debug_net:
print_debug("Error: ", error)

$LabelConnectionStatus.text = "Connecting..."

multiplayer.multiplayer_peer = peer


func _on_fast_withdraw_invoice(amount : float, destination: String) -> void:
if $"/root/Net".print_debug_net:
print("Received fast withdraw invoice!")
print("Amount: ", amount)
print("Destination: ", destination)

var invoice_text = "Fast withdraw request received! Invoice created:\n"
invoice_text += str("Send ", amount, " L2 coins to ", destination, "\n")
invoice_text += "Once you have paid enter the L2 txid and hit invoice paid"

invoice_address = destination

$LabelInvoice.text = invoice_text


func _on_fast_withdraw_complete(txid: String, amount : float, destination: String) -> void:
if $"/root/Net".print_debug_net:
print("Fast withdraw complete!")
print("TxID: ", txid)
print("Amount: ", amount)
print("Destination: ", destination)

var output : String = "Withdraw complete!\n"
output += "Mainchain payout txid:\n" + txid + "\n"
output += "Amount: " + str(amount) + "\n"
output += "Destination: " + destination + "\n"
$LabelComplete.text = output

if multiplayer.multiplayer_peer:
multiplayer.multiplayer_peer.close()


func _on_button_copy_address_pressed() -> void:
DisplayServer.clipboard_set(invoice_address)


func _on_button_invoice_paid_pressed() -> void:
# Tell the server we paid
var txid : String = $LineEditTXID.text
$"/root/Net".invoice_paid.rpc_id(1, selected_chain, txid, $SpinBoxAmount.value, $LineEditMainchainAddress.text)


func _on_button_request_invoice_pressed() -> void:
# Establish connection with fast withdraw server
connect_to_withdrawal_server()
$LabelConnectionStatus.visible = true

await fast_withdraw_server_connection_status_changed

# Send fast withdraw request only to server
$"/root/Net".request_fast_withdraw.rpc_id(1, $SpinBoxAmount.value, selected_chain, $LineEditMainchainAddress.text)


func _on_chain_selection_button_item_selected(index):
var selection_index = $ChainSelectionButton.get_selected()
selected_chain = $ChainSelectionButton.get_item_text(selection_index)
Loading

0 comments on commit 5b294b1

Please sign in to comment.