Skip to content
This repository has been archived by the owner on Jul 3, 2022. It is now read-only.

Commit

Permalink
change keep to operation
Browse files Browse the repository at this point in the history
  • Loading branch information
hclivess committed Apr 7, 2018
1 parent eeb438f commit aeb7c53
Show file tree
Hide file tree
Showing 16 changed files with 107 additions and 84 deletions.
16 changes: 8 additions & 8 deletions anon_dappie.py
Expand Up @@ -67,15 +67,15 @@ def anonymize(tx_count, per_tx, remainder, anon_recipient, identifier, anon_send
for tx in range(tx_count):
#construct tx
openfield = "mixer"
keep = 0
operation = 0
fee = fee_calculate(openfield)

timestamp = '%.2f' % time.time()
transaction = (str(timestamp),
str(address),
str(anon_recipient),
'%.8f' % float(per_tx - fee),
str(keep),
str(operation),
str(openfield)) # this is signed


Expand All @@ -90,19 +90,19 @@ def anonymize(tx_count, per_tx, remainder, anon_recipient, identifier, anon_send
print("The signature is valid, proceeding to save transaction to mempool")

#construct tx
a.execute("INSERT INTO transactions VALUES (?,?,?,?,?,?,?,?)", (str(timestamp), str(address), str(anon_recipient), '%.8f' % float(per_tx - fee), str(signature_enc.decode("utf-8")), str(public_key_hashed), str(keep), str(identifier)))
a.execute("INSERT INTO transactions VALUES (?,?,?,?,?,?,?,?)", (str(timestamp), str(address), str(anon_recipient), '%.8f' % float(per_tx - fee), str(signature_enc.decode("utf-8")), str(public_key_hashed), str(operation), str(identifier)))
anon.commit()
m.execute("INSERT INTO transactions VALUES (?,?,?,?,?,?,?,?)", (str(timestamp), str(address), str(anon_recipient), '%.8f' % float(per_tx - fee), str(signature_enc.decode("utf-8")), str(public_key_hashed), str(keep), str(openfield)))
m.execute("INSERT INTO transactions VALUES (?,?,?,?,?,?,?,?)", (str(timestamp), str(address), str(anon_recipient), '%.8f' % float(per_tx - fee), str(signature_enc.decode("utf-8")), str(public_key_hashed), str(operation), str(openfield)))
mempool.commit()


if (remainder - fee) > 0:
openfield = "mixer"
keep = 0
operation = 0
fee = fee_calculate(openfield)
timestamp = '%.2f' % time.time()
transaction = (str(timestamp), str(address), str(anon_sender), '%.8f' % float(remainder - fee), str(keep), str(openfield)) # this is signed
m.execute("INSERT INTO transactions VALUES (?,?,?,?,?,?,?,?)", (str(timestamp), str(address), str(anon_sender), '%.8f' % float(remainder - fee), str(signature_enc.decode("utf-8")), str(public_key_hashed), str(keep), str(openfield)))
transaction = (str(timestamp), str(address), str(anon_sender), '%.8f' % float(remainder - fee), str(operation), str(openfield)) # this is signed
m.execute("INSERT INTO transactions VALUES (?,?,?,?,?,?,?,?)", (str(timestamp), str(address), str(anon_sender), '%.8f' % float(remainder - fee), str(signature_enc.decode("utf-8")), str(public_key_hashed), str(operation), str(openfield)))
mempool.commit()
return

Expand All @@ -111,7 +111,7 @@ def anonymize(tx_count, per_tx, remainder, anon_recipient, identifier, anon_send
anon = sqlite3.connect('anon.db', timeout=1)
anon.text_factory = str
a = anon.cursor()
a.execute("CREATE TABLE IF NOT EXISTS transactions (timestamp, address, recipient, amount, signature, public_key, keep, openfield)")
a.execute("CREATE TABLE IF NOT EXISTS transactions (timestamp, address, recipient, amount, signature, public_key, operation, openfield)")
anon.commit()
print("Created anon file")

Expand Down
4 changes: 2 additions & 2 deletions commands.py
Expand Up @@ -185,11 +185,11 @@ def txsend(socket, arg1, arg2, arg3, arg4, arg5):
remote_tx_privkey = arg1 #node will dump pubkey+address from this
remote_tx_recipient = arg2
remote_tx_amount = arg3
remote_tx_keep = arg4
remote_tx_operation = arg4
remote_tx_openfield = arg5

#connections.send(s, (remote_tx_timestamp, remote_tx_privkey, remote_tx_recipient, remote_tx_amount, remote_tx_keep, remote_tx_openfield), 10)
connections.send(s, (str(remote_tx_timestamp), str(remote_tx_privkey), str(remote_tx_recipient), str(remote_tx_amount), str(remote_tx_keep), str(remote_tx_openfield)), 10)
connections.send(s, (str(remote_tx_timestamp), str(remote_tx_privkey), str(remote_tx_recipient), str(remote_tx_amount), str(remote_tx_operation), str(remote_tx_openfield)), 10)
#generate transaction

signature = connections.receive(s, 10)
Expand Down
4 changes: 2 additions & 2 deletions commands_new_not_working.py
Expand Up @@ -153,11 +153,11 @@ def txsend(socket, arg1, arg2, arg3, arg4, arg5):
remote_tx_privkey = arg1 #node will dump pubkey+address from this
remote_tx_recipient = arg2
remote_tx_amount = arg3
remote_tx_keep = arg4
remote_tx_operation = arg4
remote_tx_openfield = arg5

#connections.send(s, (remote_tx_timestamp, remote_tx_privkey, remote_tx_recipient, remote_tx_amount, remote_tx_keep, remote_tx_openfield), 10)
connections.send(s, (str(remote_tx_timestamp), str(remote_tx_privkey), str(remote_tx_recipient), str(remote_tx_amount), str(remote_tx_keep), str(remote_tx_openfield)), 10)
connections.send(s, (str(remote_tx_timestamp), str(remote_tx_privkey), str(remote_tx_recipient), str(remote_tx_amount), str(remote_tx_operation), str(remote_tx_openfield)), 10)
#generate transaction

signature = connections.receive(s, 10)
Expand Down
4 changes: 2 additions & 2 deletions demo_txsend.py
Expand Up @@ -19,11 +19,11 @@ def txsend(socket, arg1, arg2, arg3, arg4, arg5):
remote_tx_privkey = arg1 #node will dump pubkey+address from this
remote_tx_recipient = arg2
remote_tx_amount = arg3
remote_tx_keep = arg4
remote_tx_operation = arg4
remote_tx_openfield = arg5

#connections.send(s, (remote_tx_timestamp, remote_tx_privkey, remote_tx_recipient, remote_tx_amount, remote_tx_keep, remote_tx_openfield), 10)
connections.send(s, (str(remote_tx_timestamp), str(remote_tx_privkey), str(remote_tx_recipient), str(remote_tx_amount), str(remote_tx_keep), str(remote_tx_openfield)), 10)
connections.send(s, (str(remote_tx_timestamp), str(remote_tx_privkey), str(remote_tx_recipient), str(remote_tx_amount), str(remote_tx_operation), str(remote_tx_openfield)), 10)
#generate transaction

signature = connections.receive(s, 10)
Expand Down
4 changes: 2 additions & 2 deletions essentials.py
Expand Up @@ -9,7 +9,7 @@ def db_check(app_log):
backup = sqlite3.connect('backup.db', timeout=1)
backup.text_factory = str
b = backup.cursor()
db.execute(b, ("CREATE TABLE IF NOT EXISTS transactions (block_height, timestamp, address, recipient, amount, signature, public_key, block_hash, fee, reward, keep, openfield)"), app_log)
db.execute(b, ("CREATE TABLE IF NOT EXISTS transactions (block_height, timestamp, address, recipient, amount, signature, public_key, block_hash, fee, reward, operation, openfield)"), app_log)
db.commit(backup, app_log)
db.execute(b, ("CREATE TABLE IF NOT EXISTS misc (block_height, difficulty)"), app_log)
db.commit(backup, app_log)
Expand All @@ -22,7 +22,7 @@ def db_check(app_log):
mempool = sqlite3.connect('mempool.db', timeout=1)
mempool.text_factory = str
m = mempool.cursor()
db.execute(m, ("CREATE TABLE IF NOT EXISTS transactions (timestamp, address, recipient, amount, signature, public_key, keep, openfield)"), app_log)
db.execute(m, ("CREATE TABLE IF NOT EXISTS transactions (timestamp, address, recipient, amount, signature, public_key, operation, openfield)"), app_log)
db.commit(mempool, app_log)
app_log.warning("Created mempool file")
mempool.close()
Expand Down
4 changes: 2 additions & 2 deletions exchange.py
Expand Up @@ -115,10 +115,10 @@ def sendtransaction(socket, arg1, arg2, arg3):
remote_tx_privkey = private_key_readable
remote_tx_recipient = arg1
remote_tx_amount = arg2
remote_tx_keep = '0'
remote_tx_operation = '0'
remote_tx_openfield = arg3

connections.send(s, (str(remote_tx_timestamp), str(remote_tx_privkey), str(remote_tx_recipient), str(remote_tx_amount), str(remote_tx_keep), str(remote_tx_openfield)), 10)
connections.send(s, (str(remote_tx_timestamp), str(remote_tx_privkey), str(remote_tx_recipient), str(remote_tx_amount), str(remote_tx_operation), str(remote_tx_openfield)), 10)
tx_id = connections.receive(s, 10)

result = {
Expand Down
4 changes: 2 additions & 2 deletions genesis.py
Expand Up @@ -74,13 +74,13 @@
try:
conn = sqlite3.connect('static/ledger.db')
cursor = conn.cursor()
cursor.execute("CREATE TABLE transactions (block_height INTEGER, timestamp, address, recipient, amount, signature, public_key, block_hash, fee, reward, keep, openfield)")
cursor.execute("CREATE TABLE transactions (block_height INTEGER, timestamp, address, recipient, amount, signature, public_key, block_hash, fee, reward, operation, openfield)")
cursor.execute("INSERT INTO transactions VALUES (?,?,?,?,?,?,?,?,?,?,?,?)", ("1", timestamp, 'genesis', address, '0', str(signature_enc), public_key_hashed, block_hash, 0, 1, 1, 'genesis')) # Insert a row of data
conn.commit() # Save (commit) the changes

mempool = sqlite3.connect('mempool.db')
mem_cur = mempool.cursor()
mem_cur.execute("CREATE TABLE transactions (timestamp, address, recipient, amount, signature, public_key, keep, openfield)")
mem_cur.execute("CREATE TABLE transactions (timestamp, address, recipient, amount, signature, public_key, operation, openfield)")
mempool.commit()
mempool.close()

Expand Down
32 changes: 16 additions & 16 deletions legacy_gui.py
Expand Up @@ -333,7 +333,7 @@ def decrypt_fn(destroy_this):
return key


def send_confirm(amount_input, recipient_input, keep_input, openfield_input):
def send_confirm(amount_input, recipient_input, operation_input, openfield_input):
top10 = Toplevel()
top10.title("Confirm")

Expand Down Expand Up @@ -378,21 +378,21 @@ def send_confirm(amount_input, recipient_input, keep_input, openfield_input):
if encrypt_var.get() == 1:
openfield_input = "enc=" + str(openfield_input)

fee = '%.8f' % float(0.01 + (float(len(openfield_input)) / 100000) + int(keep_var.get())) # 0.01 dust
fee = '%.8f' % float(0.01 + (float(len(openfield_input)) / 100000) + int(operation_var.get())) # 0.01 dust

confirmation_dialog = Text(top10, width=100)
confirmation_dialog.insert(INSERT, ("Amount: {}\nTo: {}\nFee: {}\nKeep Entry: {}\nOpenField:\n\n{}".format(amount_input, recipient_input, fee, keep_input, openfield_input)))
confirmation_dialog.insert(INSERT, ("Amount: {}\nTo: {}\nFee: {}\noperation Entry: {}\nOpenField:\n\n{}".format(amount_input, recipient_input, fee, operation_input, openfield_input)))

confirmation_dialog.grid(row=0, pady=0)

enter = Button(top10, text="Confirm", command=lambda: send(amount_input, recipient_input, keep_input, openfield_input, top10, fee))
enter = Button(top10, text="Confirm", command=lambda: send(amount_input, recipient_input, operation_input, openfield_input, top10, fee))
enter.grid(row=1, column=0, sticky=W + E, padx=15, pady=(5, 5))

done = Button(top10, text="Cancel", command=top10.destroy)
done.grid(row=2, column=0, sticky=W + E, padx=15, pady=(5, 5))


def send(amount_input, recipient_input, keep_input, openfield_input, top10, fee):
def send(amount_input, recipient_input, operation_input, openfield_input, top10, fee):
try:
key
except:
Expand Down Expand Up @@ -432,11 +432,11 @@ def send(amount_input, recipient_input, keep_input, openfield_input, top10, fee)

app_log.warning("Amount: {}".format(amount_input))
app_log.warning("Recipient: {}".format(recipient_input))
app_log.warning("Keep Forever: {}".format(keep_input))
app_log.warning("Operation: {}".format(operation_input))
app_log.warning("OpenField Data: {}".format(openfield_input))

timestamp = '%.2f' % time.time()
transaction = (str(timestamp), str(address), str(recipient_input), '%.8f' % float(amount_input), str(keep_input), str(openfield_input)) # this is signed
transaction = (str(timestamp), str(address), str(recipient_input), '%.8f' % float(amount_input), str(operation_input), str(openfield_input)) # this is signed

h = SHA.new(str(transaction).encode("utf-8"))
signer = PKCS1_v1_5.new(key)
Expand All @@ -455,8 +455,8 @@ def send(amount_input, recipient_input, keep_input, openfield_input, top10, fee)
else:
app_log.warning("Client: The signature is valid, proceeding to save transaction, signature, new txhash and the public key to mempool")

# print(str(timestamp), str(address), str(recipient_input), '%.8f' % float(amount_input),str(signature_enc), str(public_key_hashed), str(keep_input), str(openfield_input))
m.execute("INSERT INTO transactions VALUES (?,?,?,?,?,?,?,?)", (str(timestamp), str(address), str(recipient_input), '%.8f' % float(amount_input), str(signature_enc.decode("utf-8")), str(public_key_hashed.decode("utf-8")), str(keep_input), str(openfield_input)))
# print(str(timestamp), str(address), str(recipient_input), '%.8f' % float(amount_input),str(signature_enc), str(public_key_hashed), str(operation_input), str(openfield_input))
m.execute("INSERT INTO transactions VALUES (?,?,?,?,?,?,?,?)", (str(timestamp), str(address), str(recipient_input), '%.8f' % float(amount_input), str(signature_enc.decode("utf-8")), str(public_key_hashed.decode("utf-8")), str(operation_input), str(openfield_input)))
mempool.commit() # Save (commit) the changes
app_log.warning("Client: Mempool updated with a received transaction")
# refresh() experimentally disabled
Expand Down Expand Up @@ -491,7 +491,7 @@ def qr():

photo = PIL.ImageTk.PhotoImage(im.resize((320, 320)))
label = Label(top, image=photo)
label.image = photo # keep a reference!
label.image = photo # operation a reference!
label.pack()

# msg = Message(top, text="hi")
Expand Down Expand Up @@ -685,7 +685,7 @@ def sign_this():

Label(top, text="Message:", width=20).grid(row=0, pady=0)
input_text = Text(top, height=10)
# label.image = photo # keep a reference!
# label.image = photo # operation a reference!
input_text.grid(row=1, column=0, sticky=N + E, padx=15, pady=(0, 0))

Label(top, text="Public Key:", width=20).grid(row=2, pady=0)
Expand Down Expand Up @@ -894,7 +894,7 @@ def refresh():
else:
openfield_input = str(openfield.get("1.0", END)).strip()

fee = '%.8f' % float(0.01 + (float(len(openfield_input)) / 100000) + int(keep_var.get())) # 0.01 dust
fee = '%.8f' % float(0.01 + (float(len(openfield_input)) / 100000) + int(operation_var.get())) # 0.01 dust

app_log.warning("Fee: {}".format(fee))

Expand Down Expand Up @@ -1010,7 +1010,7 @@ def refresh():

# buttons

send_b = Button(f5, text="Send", command=lambda: send_confirm(str(amount.get()).strip(), recipient.get().strip(), str(keep_var.get()).strip(), (openfield.get("1.0", END)).strip()), height=1, width=10, font=("Tahoma", 8))
send_b = Button(f5, text="Send", command=lambda: send_confirm(str(amount.get()).strip(), recipient.get().strip(), str(operation_var.get()).strip(), (openfield.get("1.0", END)).strip()), height=1, width=10, font=("Tahoma", 8))
send_b.grid(row=7, column=0, sticky=W + E + S, pady=(45, 0), padx=15)

start_b = Button(f5, text="Generate QR Code", command=qr, height=1, width=10, font=("Tahoma", 8))
Expand Down Expand Up @@ -1092,7 +1092,7 @@ def refresh():
sync_msg_label = Label(f5, textvariable=sync_msg_var)
sync_msg_label.grid(row=7, column=0, sticky=N + E, padx=15)

keep_var = IntVar()
operation_var = IntVar()
encode_var = IntVar()
alias_cb_var = IntVar()
# encrypt_var = IntVar()
Expand Down Expand Up @@ -1133,8 +1133,8 @@ def refresh():
alias_cb = Checkbutton(f3, text="Alias", variable=alias_cb_var, command=None)
alias_cb.grid(row=4, column=1, sticky=E)

keep = Checkbutton(f3, text="Keep Entry", variable=keep_var)
keep.grid(row=4, column=1, sticky=E, padx=(0, 90))
operation = Checkbutton(f3, text="operation Entry", variable=operation_var)
operation.grid(row=4, column=1, sticky=E, padx=(0, 90))

encode = Checkbutton(f3, text="Base64", variable=encode_var)
encode.grid(row=4, column=1, sticky=E, padx=(0, 170))
Expand Down

0 comments on commit aeb7c53

Please sign in to comment.