This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pytest | |
from typing import List, Optional | |
from chia.types.blockchain_format.coin import Coin | |
from chia.types.spend_bundle import SpendBundle | |
from cdv.test import CoinWrapper | |
from cdv.test import setup as setup_test | |
from password.password_driver import ( | |
create_coin_puzzle, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hashlib | |
from chia.types.blockchain_format.program import Program | |
from chia.util.bech32m import encode_puzzle_hash | |
from cdv.util.load_clvm import load_clvm | |
# Load the Chialisp puzzle code | |
PASSWORD_MOD = load_clvm("password.clsp", "password") | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends 'base.html' %} | |
{% block main %} | |
<h1 style="margin: 10px;">Spend a password coin below:</h1> | |
<!-- Spend A Password Coin --> | |
<form method="post"> | |
<div class="form-group" style="margin-top: 10px; margin-bottom: 10px;"> | |
<label for="title">Password</label> | |
<input type="text" name="password" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends 'base.html' %} | |
{% block main %} | |
<h1 style="margin: 10px;">Create a new password coin below:</h1> | |
<!-- Create A New Password Coin --> | |
<form method="post"> | |
<div class="form-group" style="margin-top: 10px; margin-bottom: 10px;"> | |
<label for="title">Password</label> | |
<input type="text" name="password" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends 'base.html' %} | |
{% block main %} | |
<h1 style="margin: 10px;">Welcome to the Chia Password Coin!</h1> | |
{% for balance in balances %} | |
<p> | |
Your wallet has a balance of: | |
<h4>{{ balance }} TXCH</h4> | |
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Chia Password Coin</title> | |
</head> | |
<body style="background-color: #00A36C; font-family: Arial"> | |
<div style="margin:0 auto; width: 100%; max-width: 700px; text-align: center; margin-top: 50px; padding: 30px; background-color: white; border-radius: 10px;"> | |
{% block main %} | |
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.route('/spend', methods=('GET', 'POST')) | |
async def spend(): | |
await setup_blockchain_connection() | |
# If a post request was made | |
if request.method == 'POST': | |
# Get variables from the form | |
password = (await request.form)['password'] | |
address = (await request.form)['address'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.route('/create', methods=('GET', 'POST')) | |
async def create(): | |
await setup_blockchain_connection() | |
# If a post request was made | |
if request.method == 'POST': | |
# Get variables from the form | |
password = (await request.form)['password'] | |
amount = (await request.form)['amount'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.route('/') | |
async def index(): | |
await setup_blockchain_connection() | |
wallets = await wallet_rpc_client.get_wallets() | |
balance = await wallet_rpc_client.get_wallet_balance(wallets[0]["id"]) | |
return await render_template('index.html', balances=[balance['confirmed_wallet_balance'] / 1000000000000]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
full_node_rpc_client = None | |
wallet_rpc_client = None | |
config = load_config(DEFAULT_ROOT_PATH, "config.yaml") | |
wallet_host = "localhost" | |
wallet_rpc_port = config["wallet"]["rpc_port"] | |
node_rpc_port = config["full_node"]["rpc_port"] | |
async def setup_blockchain_connection(): | |
global full_node_rpc_client, wallet_rpc_client |