Add full node display to electron
This commit is contained in:
parent
495d462b89
commit
b3040a3623
|
@ -28,15 +28,6 @@ def main():
|
|||
"""
|
||||
|
||||
parser = argparse.ArgumentParser(description="Chia key generator script.")
|
||||
parser.add_argument(
|
||||
"-f",
|
||||
"--farmer",
|
||||
type=str2bool,
|
||||
nargs="?",
|
||||
const=True,
|
||||
default=True,
|
||||
help="Regenerate farmer key",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-a",
|
||||
"--harvester",
|
||||
|
@ -89,20 +80,7 @@ def main():
|
|||
BLSPublicKey(bytes(wallet_sk.public_child(0).get_public_key()))
|
||||
)
|
||||
key_config["wallet_sk"] = bytes(wallet_sk).hex()
|
||||
with open(key_config_filename, "w") as f:
|
||||
safe_dump(key_config, f)
|
||||
if args.farmer:
|
||||
# Replaces the farmer's private key. The farmer target allows spending
|
||||
# of the fees.
|
||||
farmer_sk = PrivateKey.from_seed(token_bytes(32))
|
||||
if wallet_target is None:
|
||||
farmer_target = create_puzzlehash_for_pk(
|
||||
BLSPublicKey(bytes(farmer_sk.get_public_key()))
|
||||
)
|
||||
else:
|
||||
farmer_target = wallet_target
|
||||
key_config["farmer_sk"] = bytes(farmer_sk).hex()
|
||||
key_config["farmer_target"] = farmer_target.hex()
|
||||
key_config["wallet_target"] = wallet_target.hex()
|
||||
with open(key_config_filename, "w") as f:
|
||||
safe_dump(key_config, f)
|
||||
if args.harvester:
|
||||
|
|
|
@ -8,5 +8,6 @@ _run_bg_cmd python -m src.server.start_timelord
|
|||
_run_bg_cmd python -m src.timelord_launcher
|
||||
_run_bg_cmd python -m src.server.start_farmer
|
||||
_run_bg_cmd python -m src.server.start_full_node --port=8444 --connect_to_farmer=True --connect_to_timelord=True --rpc_port=8555
|
||||
_run_bg_cmd python -m src.server.start_wallet
|
||||
|
||||
wait
|
||||
|
|
|
@ -175,7 +175,7 @@ class Farmer:
|
|||
if estimate_secs < self.config["pool_share_threshold"]:
|
||||
request1 = harvester_protocol.RequestPartialProof(
|
||||
response.quality_string,
|
||||
bytes.fromhex(self.key_config["farmer_target"]),
|
||||
bytes.fromhex(self.key_config["wallet_target"]),
|
||||
)
|
||||
yield OutboundMessage(
|
||||
NodeType.HARVESTER,
|
||||
|
@ -194,7 +194,7 @@ class Farmer:
|
|||
challenge_hash,
|
||||
coinbase,
|
||||
signature,
|
||||
bytes.fromhex(self.key_config["farmer_target"]),
|
||||
bytes.fromhex(self.key_config["wallet_target"]),
|
||||
response.proof,
|
||||
)
|
||||
|
||||
|
@ -244,7 +244,7 @@ class Farmer:
|
|||
share, to tell the pool where to pay the farmer.
|
||||
"""
|
||||
|
||||
farmer_target = bytes.fromhex(self.key_config["farmer_target"])
|
||||
farmer_target = bytes.fromhex(self.key_config["wallet_target"])
|
||||
plot_pubkey = self.harvester_responses_proofs[
|
||||
response.quality_string
|
||||
].plot_pubkey
|
||||
|
|
|
@ -937,6 +937,17 @@ class FullNode:
|
|||
and block.proof_of_time.number_of_iterations
|
||||
== respond_compact_proof_of_time.proof.number_of_iterations
|
||||
):
|
||||
assert respond_compact_proof_of_time.proof.is_valid(
|
||||
self.constants["DISCRIMINANT_SIZE_BITS"]
|
||||
)
|
||||
block_new = FullBlock(
|
||||
block.proof_of_space,
|
||||
respond_compact_proof_of_time.proof,
|
||||
block.header,
|
||||
block.transactions_generator,
|
||||
block.transactions_filter,
|
||||
)
|
||||
await self.store.add_block(block_new)
|
||||
yield OutboundMessage(
|
||||
NodeType.FULL_NODE,
|
||||
Message(
|
||||
|
|
|
@ -2030,4 +2030,87 @@ table td {
|
|||
/* Handle on hover */
|
||||
#table_container::-webkit-scrollbar-thumb:hover {
|
||||
background: #007bff;
|
||||
}
|
||||
|
||||
|
||||
.navlink {
|
||||
color: white;
|
||||
}
|
||||
.navlink-selected {
|
||||
color: green !important;
|
||||
}
|
||||
.navlink-container {
|
||||
font-size: 150% !important;
|
||||
padding: 5px !important;
|
||||
}
|
||||
|
||||
#connected_to_node_textfield {
|
||||
margin-left: 15px;
|
||||
}
|
||||
|
||||
.full-node-status {
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
.close-btn {
|
||||
padding: 4px !important;
|
||||
}
|
||||
|
||||
#new-ip-address, #new-port {
|
||||
margin-left: 15px !important;
|
||||
margin-right: 15px !important;
|
||||
}
|
||||
|
||||
#new-ip-address-label {
|
||||
padding-top: 15px !important;
|
||||
}
|
||||
|
||||
#new-port-label {
|
||||
padding-top: 15px !important;
|
||||
}
|
||||
|
||||
#create-conn-button {
|
||||
margin-left: 15px;
|
||||
padding: 4px !important;
|
||||
}
|
||||
.create-connection {
|
||||
border-top: 1px solid #e0e3eb;
|
||||
padding-top: 20px;
|
||||
margin-top: 25px;
|
||||
}
|
||||
|
||||
.create-connection input {
|
||||
padding: 25px 15px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.create-connection .input-group-prepend button {
|
||||
padding: 13px 20px;
|
||||
border-top-right-radius: 5px !important;
|
||||
border-bottom-right-radius: 5px !important;
|
||||
}
|
||||
|
||||
.create-connection input {
|
||||
border: 1px solid #e0e3eb;
|
||||
}
|
||||
|
||||
.create-connection h4 {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.create-connection .input-group {
|
||||
padding-top: 30px;
|
||||
}
|
||||
#dark .create-connection input,
|
||||
#dark .create-connection input:focus {
|
||||
border: 1px solid #2a2e39;
|
||||
background: #2a2e39;
|
||||
box-shadow: none;
|
||||
color: #ffffff;
|
||||
}
|
||||
#dark .create-connection {
|
||||
border-top: 1px solid #2a2e39;
|
||||
}
|
||||
#stop-node-button {
|
||||
padding: 7px !important;
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>Chia Wallet</title>
|
||||
<link rel="stylesheet" href="assets/css/style.css">
|
||||
</head>
|
||||
|
||||
<body id="dark">
|
||||
<header class="dark-bb">
|
||||
<nav class="navbar navbar-expand-lg">
|
||||
<a class="navbar-brand" href="wallet-dark.html?wallet_id=1"><img src="assets/img/chia_logo.svg" alt="logo"></a>
|
||||
<a class="navlink" href="wallet-dark.html?wallet_id=1"><div class="navlink-container">Wallet</div></a>
|
||||
<a class="navlink-selected" href="full-node.html"><div class="navlink-container">Full Node</div></a>
|
||||
<a class="navlink" href="farmer.html"><div class="navlink-container">Farmer</div></a>
|
||||
<a class="navlink" href="timelord.html"><div class="navlink-container">Timelord</div></a>
|
||||
</nav>
|
||||
</header>
|
||||
<div class="wallet ptb70">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-lg-12">
|
||||
<div class="nav flex-column nav-pills status" role="tablist" aria-orientation="vertical">
|
||||
<h3 class="full-node-status">Block</h3>
|
||||
Block details
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
require('./renderer-block.js')
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -12,11 +12,11 @@
|
|||
<body id="dark">
|
||||
<header class="dark-bb">
|
||||
<nav class="navbar navbar-expand-lg">
|
||||
<a class="navbar-brand" href="exchange-dark.html"><img src="assets/img/chia_logo.svg" alt="logo"></a>
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#headerMenu"
|
||||
aria-controls="headerMenu" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<i class="icon ion-md-menu"></i>
|
||||
</button>
|
||||
<a class="navbar-brand" href="wallet-dark.html?wallet_id=1"><img src="assets/img/chia_logo.svg" alt="logo"></a>
|
||||
<a class="navlink-selected" href="wallet-dark.html?wallet_id=1"><div class="navlink-container">Wallet</div></a>
|
||||
<a class="navlink" href="full-node.html"><div class="navlink-container">Full Node</div></a>
|
||||
<a class="navlink" href="farmer.html"><div class="navlink-container">Farmer</div></a>
|
||||
<a class="navlink" href="timelord.html"><div class="navlink-container">Timelord</div></a
|
||||
</nav>
|
||||
</header>
|
||||
<div class="wallet ptb70">
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>Chia Wallet</title>
|
||||
<link rel="stylesheet" href="assets/css/style.css">
|
||||
</head>
|
||||
|
||||
<body id="dark">
|
||||
<header class="dark-bb">
|
||||
<nav class="navbar navbar-expand-lg">
|
||||
<a class="navbar-brand" href="wallet-dark.html?wallet_id=1"><img src="assets/img/chia_logo.svg" alt="logo"></a>
|
||||
<a class="navlink" href="wallet-dark.html?wallet_id=1"><div class="navlink-container">Wallet</div></a>
|
||||
<a class="navlink" href="full-node.html"><div class="navlink-container">Full Node</div></a>
|
||||
<a class="navlink-selected" href="farmer.html"><div class="navlink-container">Farmer</div></a>
|
||||
<a class="navlink" href="timelord.html"><div class="navlink-container">Timelord</div></a>
|
||||
</nav>
|
||||
</header>
|
||||
<div class="wallet ptb70">
|
||||
<div style="color: white; font-size:200%; margin: 50px;">Coming soon.<div>
|
||||
</div>
|
||||
<script>
|
||||
require('./renderer-full-node.js')
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -0,0 +1,115 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>Chia Wallet</title>
|
||||
<link rel="stylesheet" href="assets/css/style.css">
|
||||
</head>
|
||||
|
||||
<body id="dark">
|
||||
<header class="dark-bb">
|
||||
<nav class="navbar navbar-expand-lg">
|
||||
<a class="navbar-brand" href="wallet-dark.html?wallet_id=1"><img src="assets/img/chia_logo.svg" alt="logo"></a>
|
||||
<a class="navlink" href="wallet-dark.html?wallet_id=1"><div class="navlink-container">Wallet</div></a>
|
||||
<a class="navlink-selected" href="full-node.html"><div class="navlink-container">Full Node</div></a>
|
||||
<a class="navlink" href="farmer.html"><div class="navlink-container">Farmer</div></a>
|
||||
<a class="navlink" href="timelord.html"><div class="navlink-container">Timelord</div></a>
|
||||
</nav>
|
||||
</header>
|
||||
<div class="wallet ptb70">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-lg-4">
|
||||
<div class="nav flex-column nav-pills status" role="tablist" aria-orientation="vertical">
|
||||
<h3 class="full-node-status">Full Node Status</h3>
|
||||
<p class="error" id="connected_to_node_textfield"></p>
|
||||
<div class="nav-link d-flex justify-content-between align-items-center" data-toggle="pill"
|
||||
role="tab" aria-selected="true">
|
||||
<div class="d-flex justify-content-between" id="status_offset">
|
||||
<div>
|
||||
<p>Syncing: </p>
|
||||
<p>LCA Block Height: </p>
|
||||
<p>Max Tip Block Height: </p>
|
||||
<p>LCA time</p>
|
||||
<p>Connected: </p>
|
||||
<p>Difficulty: </p>
|
||||
<p>Iterations per second: </p>
|
||||
<p>Min iterations per block: </p>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-right" id="syncing_textfield"></p>
|
||||
<p class="text-right" id="block_height_textfield"></p>
|
||||
<p class="text-right" id="max_block_height_textfield"></p>
|
||||
<p class="text-right" id="lca_time_textfield"></p>
|
||||
<p class="text-right" id="connection_textfield"></p>
|
||||
<p class="text-right" id="difficulty_textfield"></p>
|
||||
<p class="text-right" id="ips_textfield"></p>
|
||||
<p class="text-right" id="min_iters_textfield"></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12 col-lg-8">
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane fade show active" id="coinBTC" role="tabpanel">
|
||||
<h2 class="wallet-title">Connections</h2>
|
||||
<div class="table-responsive">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Node id</th>
|
||||
<th scope="col">Type</th>
|
||||
<th scope="col">Ip</th>
|
||||
<th scope="col">Port</th>
|
||||
<th scope="col">Connected</th>
|
||||
<th scope="col">Last message</th>
|
||||
</tr>
|
||||
<tbody id="connections_list">
|
||||
</tbody>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<h2 class="wallet-title">Create Connection</h2>
|
||||
<div class="create-connection">
|
||||
<div class="input-group" style="padding-top:0px">
|
||||
<p id="new-ip-address-label">Ip/domain:</p>
|
||||
<input type="text" class="form-control" id="new-ip-address" value="">
|
||||
<p id="new-port-label">Port:</p>
|
||||
<input type="text" class="form-control" id="new-port" value="">
|
||||
<button class="btn btn-primary" id="create-conn-button">Create</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="create-connection">
|
||||
<h2 class="wallet-title">Latest Blocks</h2>
|
||||
<table class="table table-sm table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Block hash</th>
|
||||
<th scope="col" style="width: 100px;">Height</th>
|
||||
<th scope="col" style-"width: 200px;">Time finalized</th>
|
||||
</tr>
|
||||
<tbody id="latest-blocks-tbody">
|
||||
</tbody>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
<div class="create-connection">
|
||||
<button class="btn btn-warning" id="stop-node-button">Stop node</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
require('./renderer-full-node.js')
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -0,0 +1,85 @@
|
|||
const http = require('http')
|
||||
|
||||
class FullNodeRpcClient {
|
||||
constructor(host, port) {
|
||||
this._host = host;
|
||||
this._port = port;
|
||||
}
|
||||
|
||||
async get_blockchain_state() {
|
||||
let state = await this.make_request("get_blockchain_state", {});
|
||||
let tips_parsed = [];
|
||||
for (let tip of state.tips) {
|
||||
tips_parsed.push(JSON.parse(tip));
|
||||
}
|
||||
state.tips = tips_parsed;
|
||||
state.lca = JSON.parse(state.lca);
|
||||
return state;
|
||||
}
|
||||
|
||||
async get_header(header_hash) {
|
||||
return JSON.parse(await this.make_request("get_header", {
|
||||
"header_hash": header_hash,
|
||||
}));
|
||||
}
|
||||
|
||||
async get_block(header_hash) {
|
||||
return await this.make_request("get_block", {
|
||||
"header_hash": header_hash,
|
||||
});
|
||||
}
|
||||
|
||||
async get_connections() {
|
||||
return await this.make_request("get_connections", {});
|
||||
}
|
||||
async close_connection(node_id) {
|
||||
return await this.make_request("close_connection", {
|
||||
"node_id": node_id,
|
||||
});
|
||||
}
|
||||
async open_connection(host, port) {
|
||||
return await this.make_request("open_connection", {
|
||||
"host": host,
|
||||
"port": port,
|
||||
});
|
||||
}
|
||||
async stop_node() {
|
||||
return await this.make_request("stop_node", {});
|
||||
}
|
||||
|
||||
make_request(path, data) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const str_data = JSON.stringify(data)
|
||||
|
||||
const options = {
|
||||
hostname: this._host,
|
||||
port: this._port,
|
||||
path: '/' + path,
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Content-Length': str_data.length
|
||||
}
|
||||
}
|
||||
const req = http.request(options, res => {
|
||||
if (res.statusCode != 200) {
|
||||
reject(res.statusCode + " " + res.statusMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
res.on('data', d => {
|
||||
resolve(JSON.parse(d));
|
||||
})
|
||||
})
|
||||
|
||||
req.on('error', error => {
|
||||
reject(error);
|
||||
})
|
||||
|
||||
req.write(str_data)
|
||||
req.end();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = FullNodeRpcClient;
|
|
@ -4,8 +4,9 @@ const BrowserWindow = electron.BrowserWindow
|
|||
const path = require('path')
|
||||
const WebSocket = require('ws');
|
||||
const local_test = true
|
||||
const ipcMain = require('electron').ipcMain;
|
||||
|
||||
var ui_html = "wallet-dark.html"
|
||||
var wallet_ui_html = "wallet-dark.html"
|
||||
|
||||
/*************************************************************
|
||||
* py process
|
||||
|
@ -97,7 +98,7 @@ const createWindow = () => {
|
|||
|
||||
query = "?testing="+local_test + "&wallet_id=1"
|
||||
mainWindow.loadURL(require('url').format({
|
||||
pathname: path.join(__dirname, ui_html),
|
||||
pathname: path.join(__dirname, wallet_ui_html),
|
||||
protocol: 'file:',
|
||||
slashes: true
|
||||
}) + query
|
||||
|
@ -122,3 +123,13 @@ app.on('activate', () => {
|
|||
createWindow()
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
ipcMain.on('load-page', (event, arg) => {
|
||||
mainWindow.loadURL(require('url').format({
|
||||
pathname: path.join(__dirname, arg),
|
||||
protocol: 'file:',
|
||||
slashes: true
|
||||
}) + query
|
||||
);
|
||||
});
|
||||
|
|
|
@ -0,0 +1,254 @@
|
|||
let FullNodeRpcClient = require('./full_node_rpc_client')
|
||||
let syncing_textfield = document.querySelector('#syncing_textfield');
|
||||
let block_height_textfield = document.querySelector('#block_height_textfield');
|
||||
let max_block_height_textfield = document.querySelector('#max_block_height_textfield');
|
||||
let lca_time_textfield = document.querySelector('#lca_time_textfield');
|
||||
let connection_textfield = document.querySelector('#connection_textfield');
|
||||
let connected_to_node_textfield = document.querySelector('#connected_to_node_textfield');
|
||||
let difficulty_textfield = document.querySelector('#difficulty_textfield');
|
||||
let ips_textfield = document.querySelector('#ips_textfield');
|
||||
let min_iters_textfield = document.querySelector('#min_iters_textfield');
|
||||
let connections_list_tbody = document.querySelector('#connections_list');
|
||||
let create_conn_button = document.querySelector("#create-conn-button");
|
||||
let new_ip_field = document.querySelector("#new-ip-address");
|
||||
let new_port_field = document.querySelector("#new-port");
|
||||
let stop_node_button = document.querySelector("#stop-node-button");
|
||||
let latest_blocks_tbody = document.querySelector('#latest-blocks-tbody');
|
||||
|
||||
let host = "127.0.0.1";
|
||||
let port = 8555;
|
||||
let rpc_client = new FullNodeRpcClient(host, port);
|
||||
const connection_types = {
|
||||
1: "Full Node",
|
||||
2: "Harvester",
|
||||
3: "Farmer",
|
||||
4: "Timelord",
|
||||
5: "Introducer",
|
||||
6: "Wallet",
|
||||
}
|
||||
const NUM_LATEST_BLOCKS = 10;
|
||||
|
||||
class FullNodeView {
|
||||
constructor() {
|
||||
this.state = {
|
||||
tip_prev_hashes: new Set(),
|
||||
getting_info: false,
|
||||
connections: {},
|
||||
displayed_connections: new Set(),
|
||||
max_height: 0,
|
||||
lca_height: 0,
|
||||
lca_timestamp: 1585023165,
|
||||
syncing: false,
|
||||
difficulty: 0,
|
||||
ips: 0,
|
||||
min_iters: 0,
|
||||
latest_blocks: [],
|
||||
}
|
||||
this.update_view(true);
|
||||
this.initialize_handlers();
|
||||
this.interval = setInterval(() => this.get_info(), 2000);
|
||||
}
|
||||
|
||||
initialize_handlers() {
|
||||
create_conn_button.onclick = async () => {
|
||||
try {
|
||||
let old_host = new_ip_field.value;
|
||||
let old_port = new_port_field.value;
|
||||
new_ip_field.value = "";
|
||||
new_port_field.value = "";
|
||||
await rpc_client.open_connection(old_host, old_port);
|
||||
} catch (error) {
|
||||
alert(error);
|
||||
}
|
||||
}
|
||||
stop_node_button.onclick = async () => {
|
||||
try {
|
||||
await rpc_client.stop_node();
|
||||
} catch (error) {
|
||||
alert(error);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
node_connected() {
|
||||
connected_to_node_textfield.innerHTML = "Connected to node at port " + port;
|
||||
connected_to_node_textfield.style.color = "green";
|
||||
create_conn_button.disabled = false;
|
||||
stop_node_button.disabled = false;
|
||||
}
|
||||
|
||||
node_not_connected() {
|
||||
connected_to_node_textfield.innerHTML = "Not connected to node";
|
||||
connected_to_node_textfield.style.color = "red";
|
||||
this.state.connections = {};
|
||||
create_conn_button.disabled = true;
|
||||
stop_node_button.disabled = true;
|
||||
this.update_view(true);
|
||||
}
|
||||
|
||||
stop() {
|
||||
clearInterval(this.interval);
|
||||
}
|
||||
|
||||
areEqualSets(set, subset) {
|
||||
for (let elem of subset) {
|
||||
if (!set.has(elem)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (let elem of set) {
|
||||
if (!subset.has(elem)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
async get_latest_blocks(tips) {
|
||||
let max_height = 0;
|
||||
let blocks = [];
|
||||
let hashes = new Set();
|
||||
for (let tip of tips) {
|
||||
if (tip.data.height > max_height) max_height = tip.data.height;
|
||||
}
|
||||
for (let tip of tips) {
|
||||
let curr = tip;
|
||||
while (curr.data.height > (max_height - NUM_LATEST_BLOCKS)) {
|
||||
if (hashes.has(curr.data.prev_header_hash)) {
|
||||
break;
|
||||
}
|
||||
let prev_header = await rpc_client.get_header(curr.data.prev_header_hash);
|
||||
blocks.push({
|
||||
"header_hash": curr.data.prev_header_hash,
|
||||
"header": prev_header,
|
||||
});
|
||||
hashes.add(curr.data.prev_header_hash);
|
||||
curr = prev_header;
|
||||
}
|
||||
}
|
||||
blocks.sort((b1, b2) => b1.header.data.timestamp > b2.header.timestamp);
|
||||
return blocks;
|
||||
}
|
||||
|
||||
create_table_cell(text) {
|
||||
let cell = document.createElement("td");
|
||||
let cellText = document.createTextNode(text);
|
||||
cell.appendChild(cellText);
|
||||
return cell;
|
||||
}
|
||||
|
||||
unix_to_short_date(unix_timestamp) {
|
||||
let d = new Date(unix_timestamp * 1000)
|
||||
return d.toLocaleDateString('en-US', {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric',
|
||||
}) + " " + d.toLocaleTimeString();
|
||||
}
|
||||
|
||||
async update_view(redisplay_blocks) {
|
||||
syncing_textfield.innerHTML = this.state.syncing ? "Yes" : "No";
|
||||
block_height_textfield.innerHTML = this.state.lca_height;
|
||||
max_block_height_textfield.innerHTML = this.state.max_height;
|
||||
lca_time_textfield.innerHTML = this.unix_to_short_date(this.state.lca_timestamp);
|
||||
connection_textfield.innerHTML = Object.keys(this.state.connections).length + " connections";
|
||||
difficulty_textfield.innerHTML = this.state.difficulty;
|
||||
ips_textfield.innerHTML = this.state.ips;
|
||||
min_iters_textfield.innerHTML = this.state.min_iters;
|
||||
|
||||
if (!this.areEqualSets(new Set(Object.keys(this.state.connections)), this.state.displayed_connections)) {
|
||||
// console.log("Updating connections");
|
||||
connections_list_tbody.innerHTML = "";
|
||||
for (let node_id of Object.keys(this.state.connections)) {
|
||||
let connection = this.state.connections[node_id];
|
||||
let node_id_short = node_id.substring(2, 6) + "..." + node_id.substring(62);
|
||||
let row = document.createElement("tr");
|
||||
row.appendChild(this.create_table_cell(node_id_short));
|
||||
row.appendChild(this.create_table_cell(connection_types[connection.type]));
|
||||
row.appendChild(this.create_table_cell(connection.peer_host));
|
||||
row.appendChild(this.create_table_cell(connection.peer_server_port));
|
||||
row.appendChild(this.create_table_cell(this.unix_to_short_date(connection.creation_time)));
|
||||
row.appendChild(this.create_table_cell(this.unix_to_short_date(connection.last_message_time)));
|
||||
let action_cell = document.createElement("td");
|
||||
let btn = document.createElement("button");
|
||||
btn.innerHTML = "Close";
|
||||
btn.classList.add("btn");
|
||||
btn.classList.add("btn-primary");
|
||||
btn.classList.add("close-btn");
|
||||
btn.onclick = async () => {
|
||||
await rpc_client.close_connection(node_id);
|
||||
};
|
||||
action_cell.appendChild(btn);
|
||||
action_cell.onclick =
|
||||
row.appendChild(action_cell);
|
||||
connections_list_tbody.appendChild(row);
|
||||
}
|
||||
this.state.displayed_connections = new Set(Object.keys(this.state.connections));
|
||||
}
|
||||
if (redisplay_blocks) {
|
||||
latest_blocks_tbody.innerHTML = "";
|
||||
for (let block of this.state.latest_blocks) {
|
||||
console.log("BLOCK");
|
||||
console.log(block);
|
||||
let row = document.createElement("tr");
|
||||
row.appendChild(this.create_table_cell(block.header_hash));
|
||||
row.appendChild(this.create_table_cell(block.header.data.height));
|
||||
row.appendChild(this.create_table_cell(this.unix_to_short_date(block.header.data.timestamp)));
|
||||
latest_blocks_tbody.appendChild(row);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async get_info() {
|
||||
if ((max_block_height_textfield === undefined) || (max_block_height_textfield === null)) {
|
||||
// Stop the interval if we changed tabs.
|
||||
console.log("Stop view")
|
||||
this.stop();
|
||||
return;
|
||||
}
|
||||
if (this.state.getting_info) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
let connections_obj = {};
|
||||
let connections = await rpc_client.get_connections();
|
||||
for (let c of connections) {
|
||||
connections_obj[c.node_id] = c;
|
||||
}
|
||||
this.state.connections = connections_obj;
|
||||
this.node_connected();
|
||||
let blockchain_state = await rpc_client.get_blockchain_state();
|
||||
let max_height = 0;
|
||||
let tip_prev_hashes = new Set();
|
||||
for (let tip of blockchain_state.tips) {
|
||||
if (tip.data.height > max_height) max_height = tip.data.height;
|
||||
tip_prev_hashes.add(tip.data.prev_header_hash);
|
||||
}
|
||||
let redisplay_blocks = false;
|
||||
if (!this.areEqualSets(tip_prev_hashes, this.state.tip_prev_hashes)) {
|
||||
redisplay_blocks = true;
|
||||
console.log("UPDATING BLOCKS");
|
||||
this.state.latest_blocks = await this.get_latest_blocks(blockchain_state.tips);
|
||||
this.state.tip_prev_hashes = tip_prev_hashes;
|
||||
}
|
||||
|
||||
this.state.max_height = max_height;
|
||||
this.state.lca_height = blockchain_state.lca.data.height;
|
||||
this.state.lca_timestamp = blockchain_state.lca.data.timestamp;
|
||||
this.state.syncing = blockchain_state.sync_mode;
|
||||
this.state.difficulty = blockchain_state.difficulty;
|
||||
this.state.ips = blockchain_state.ips;
|
||||
this.state.min_iters = blockchain_state.min_iters;
|
||||
|
||||
await this.update_view(redisplay_blocks);
|
||||
} catch (error) {
|
||||
console.error("Error getting info from node", error);
|
||||
this.node_not_connected();
|
||||
}
|
||||
this.state.getting_info = false;
|
||||
};
|
||||
}
|
||||
|
||||
if (!(max_block_height_textfield === undefined) && !(max_block_height_textfield === null)) {
|
||||
window.full_node_view = new FullNodeView();
|
||||
}
|
|
@ -8,6 +8,7 @@ const WebSocket = require('ws');
|
|||
let chia_formatter = require('./chia');
|
||||
|
||||
// HTML
|
||||
let top_link = document.querySelector('#top_link')
|
||||
let send = document.querySelector('#send')
|
||||
let farm_button = document.querySelector('#farm_block')
|
||||
let new_address = document.querySelector('#new_address')
|
||||
|
@ -114,7 +115,7 @@ function set_callbacks(socket) {
|
|||
var command = message["command"];
|
||||
var data = message["data"];
|
||||
|
||||
console.log("Received command: " + command);
|
||||
// console.log("Received command: " + command);
|
||||
if (data) {
|
||||
//console.log("Received message data: " + JSON.stringify(data));
|
||||
}
|
||||
|
@ -225,7 +226,7 @@ function send_transaction_response(response) {
|
|||
console.log(JSON.stringify(response));
|
||||
success = response["success"];
|
||||
if (!success) {
|
||||
dialogs.alert("You don\'t have enough chia for this transactions", ok => {
|
||||
dialogs.alert("You don\'t have enough chia for this transaction.", ok => {
|
||||
})
|
||||
return
|
||||
}
|
||||
|
|
|
@ -12,11 +12,7 @@
|
|||
<body id="dark">
|
||||
<header class="dark-bb">
|
||||
<nav class="navbar navbar-expand-lg">
|
||||
<a class="navbar-brand" href="exchange-dark.html"><img src="../assets/img/chia_logo.svg" alt="logo"></a>
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#headerMenu"
|
||||
aria-controls="headerMenu" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<i class="icon ion-md-menu"></i>
|
||||
</button>
|
||||
<a class="navbar-brand" href="wallet-dark.html"><img src="../assets/img/chia_logo.svg" alt="logo"></a>
|
||||
</nav>
|
||||
</header>
|
||||
<div class="wallet ptb70">
|
||||
|
|
|
@ -12,11 +12,11 @@
|
|||
<body id="dark">
|
||||
<header class="dark-bb">
|
||||
<nav class="navbar navbar-expand-lg">
|
||||
<a class="navbar-brand" href="exchange-dark.html"><img src="../assets/img/chia_logo.svg" alt="logo"></a>
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#headerMenu"
|
||||
aria-controls="headerMenu" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<i class="icon ion-md-menu"></i>
|
||||
</button>
|
||||
<a class="navbar-brand" href="wallet-dark.html?wallet_id=1"><img src="assets/img/chia_logo.svg" alt="logo"></a>
|
||||
<a class="navlink-selected" href="wallet-dark.html?wallet_id=1"><div class="navlink-container">Wallet</div></a>
|
||||
<a class="navlink" href="full-node.html"><div class="navlink-container">Full Node</div></a>
|
||||
<a class="navlink" href="farmer.html"><div class="navlink-container">Farmer</div></a>
|
||||
<a class="navlink" href="timelord.html"><div class="navlink-container">Timelord</div></a
|
||||
</nav>
|
||||
</header>
|
||||
<div class="wallet ptb70">
|
||||
|
|
|
@ -12,11 +12,11 @@
|
|||
<body id="dark">
|
||||
<header class="dark-bb">
|
||||
<nav class="navbar navbar-expand-lg">
|
||||
<a class="navbar-brand" href="exchange-dark.html"><img src="../assets/img/chia_logo.svg" alt="logo"></a>
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#headerMenu"
|
||||
aria-controls="headerMenu" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<i class="icon ion-md-menu"></i>
|
||||
</button>
|
||||
<a class="navbar-brand" href="wallet-dark.html?wallet_id=1"><img src="assets/img/chia_logo.svg" alt="logo"></a>
|
||||
<a class="navlink-selected" href="wallet-dark.html?wallet_id=1"><div class="navlink-container">Wallet</div></a>
|
||||
<a class="navlink" href="full-node.html"><div class="navlink-container">Full Node</div></a>
|
||||
<a class="navlink" href="farmer.html"><div class="navlink-container">Farmer</div></a>
|
||||
<a class="navlink" href="timelord.html"><div class="navlink-container">Timelord</div></a
|
||||
</nav>
|
||||
</header>
|
||||
<div class="wallet ptb70">
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>Chia Wallet</title>
|
||||
<link rel="stylesheet" href="assets/css/style.css">
|
||||
</head>
|
||||
|
||||
<body id="dark">
|
||||
<header class="dark-bb">
|
||||
<nav class="navbar navbar-expand-lg">
|
||||
<a class="navbar-brand" href="wallet-dark.html?wallet_id=1"><img src="assets/img/chia_logo.svg" alt="logo"></a>
|
||||
<a class="navlink" href="wallet-dark.html?wallet_id=1"><div class="navlink-container">Wallet</div></a>
|
||||
<a class="navlink" href="full-node.html"><div class="navlink-container">Full Node</div></a>
|
||||
<a class="navlink" href="farmer.html"><div class="navlink-container">Farmer</div></a>
|
||||
<a class="navlink-selected" href="timelord.html"><div class="navlink-container">Timelord</div></a>
|
||||
</nav>
|
||||
</header>
|
||||
<div class="wallet ptb70">
|
||||
<div style="color: white; font-size:200%; margin: 50px;">Coming soon.<div>
|
||||
</div>
|
||||
<script>
|
||||
require('./renderer-full-node.js')
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -12,11 +12,11 @@
|
|||
<body id="dark">
|
||||
<header class="dark-bb">
|
||||
<nav class="navbar navbar-expand-lg">
|
||||
<a class="navbar-brand" href="exchange-dark.html"><img src="assets/img/chia_logo.svg" alt="logo"></a>
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#headerMenu"
|
||||
aria-controls="headerMenu" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<i class="icon ion-md-menu"></i>
|
||||
</button>
|
||||
<a class="navbar-brand" href="wallet-dark.html?wallet_id=1"><img src="assets/img/chia_logo.svg" alt="logo"></a>
|
||||
<a class="navlink-selected" href="wallet-dark.html?wallet_id=1"><div class="navlink-container">Wallet</div></a>
|
||||
<a class="navlink" href="full-node.html"><div class="navlink-container">Full Node</div></a>
|
||||
<a class="navlink" href="farmer.html"><div class="navlink-container">Farmer</div></a>
|
||||
<a class="navlink" href="timelord.html"><div class="navlink-container">Timelord</div></a>
|
||||
</nav>
|
||||
</header>
|
||||
<div class="wallet ptb70">
|
||||
|
@ -28,7 +28,7 @@
|
|||
role="tab" aria-selected="true">
|
||||
<div class="d-flex" id="status_offset">
|
||||
<div>
|
||||
<h3>Status</h3>
|
||||
<h3>Wallet Status</h3>
|
||||
<p>Syncing: </p>
|
||||
<p>Block Height: </p>
|
||||
<p>Connected: </p>
|
||||
|
|
|
@ -44,9 +44,9 @@ plot_sks: List[PrivateKey] = [
|
|||
]
|
||||
plot_pks: List[PublicKey] = [sk.get_public_key() for sk in plot_sks]
|
||||
|
||||
farmer_sk: PrivateKey = PrivateKey.from_seed(b"coinbase")
|
||||
coinbase_target = std_hash(bytes(farmer_sk.get_public_key()))
|
||||
fee_target = std_hash(bytes(farmer_sk.get_public_key()))
|
||||
wallet_sk: PrivateKey = PrivateKey.from_seed(b"coinbase")
|
||||
coinbase_target = std_hash(bytes(wallet_sk.get_public_key()))
|
||||
fee_target = std_hash(bytes(wallet_sk.get_public_key()))
|
||||
n_wesolowski = uint8(0)
|
||||
|
||||
|
||||
|
@ -58,7 +58,7 @@ class BlockTools:
|
|||
def __init__(self):
|
||||
self.plot_config: Dict = {"plots": {}}
|
||||
self.pool_sk = pool_sk
|
||||
self.farmer_sk = farmer_sk
|
||||
self.wallet_sk = wallet_sk
|
||||
|
||||
plot_seeds: List[bytes32] = [
|
||||
ProofOfSpace.calculate_plot_seed(pool_pk, plot_pk) for plot_pk in plot_pks
|
||||
|
|
|
@ -199,14 +199,14 @@ async def setup_farmer(port, dic={}):
|
|||
pool_target = create_puzzlehash_for_pk(
|
||||
BLSPublicKey(bytes(pool_sk.get_public_key()))
|
||||
)
|
||||
farmer_sk = bt.farmer_sk
|
||||
farmer_target = create_puzzlehash_for_pk(
|
||||
BLSPublicKey(bytes(farmer_sk.get_public_key()))
|
||||
wallet_sk = bt.wallet_sk
|
||||
wallet_target = create_puzzlehash_for_pk(
|
||||
BLSPublicKey(bytes(wallet_sk.get_public_key()))
|
||||
)
|
||||
|
||||
key_config = {
|
||||
"farmer_sk": bytes(farmer_sk).hex(),
|
||||
"farmer_target": farmer_target.hex(),
|
||||
"wallet_sk": bytes(wallet_sk).hex(),
|
||||
"wallet_target": wallet_target.hex(),
|
||||
"pool_sks": [bytes(pool_sk).hex()],
|
||||
"pool_target": pool_target.hex(),
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue