Skip to content

Commit 6bcbf9c

Browse files
authored
Merge pull request #196 from Chia-Network/tx_trade_history
Tx trade history
2 parents cc5da94 + 8251c02 commit 6bcbf9c

17 files changed

+394
-204
lines changed

electron-ui/cc_wallet/cc_wallet.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ <h4>Colour Info</h4>
152152
</div>
153153
<div class="wallet-address">
154154
<h4>Send Coloured Coins</h4>
155-
<p>Receiver Address:</p>
155+
<p>Recipient Address:</p>
156156
<div class="input-group" style="padding-top:0px">
157157
<input type="text" class="form-control" id="receiver_puzzle_hash" value="">
158158
</div>/

electron-ui/cc_wallet/cc_wallet_renderer.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,12 @@ function get_wallet_balance_response(response) {
252252
var confirmed = parseInt(response["confirmed_wallet_balance"])
253253
var unconfirmed = parseInt(response["unconfirmed_wallet_balance"])
254254
var pending = confirmed - unconfirmed
255-
var wallet_id = response["wallet_id"]
256255

256+
var wallet_id = response["wallet_id"]
257+
console.log("wallet_id = " + wallet_id + "confirmed: " + confirmed + "unconfirmed: " + unconfirmed )
257258
chia_confirmed = chia_formatter(confirmed, 'mojo').to('chia').toString()
258259
chia_pending = chia_formatter(pending, 'mojo').to('chia').toString()
260+
chia_pending_abs = chia_formatter(Math.abs(pending), 'mojo').to('chia').toString()
259261

260262
wallet_balance_holder = document.querySelector("#" + "balance_wallet_" + wallet_id )
261263
wallet_pending_holder = document.querySelector("#" + "pending_wallet_" + wallet_id )
@@ -265,7 +267,7 @@ function get_wallet_balance_response(response) {
265267
if (pending > 0) {
266268
pending_textfield.innerHTML = lock + " - " + chia_pending + " CH"
267269
} else {
268-
pending_textfield.innerHTML = lock + " " + chia_pending + " CH"
270+
pending_textfield.innerHTML = lock + " " + chia_pending_abs + " CH"
269271
}
270272
}
271273
if (wallet_balance_holder) {
@@ -275,7 +277,7 @@ function get_wallet_balance_response(response) {
275277
if (pending > 0) {
276278
wallet_pending_holder.innerHTML = lock + " - " + chia_pending + " CH"
277279
} else {
278-
wallet_pending_holder.innerHTML = lock + " " + chia_pending + " CH"
280+
wallet_pending_holder.innerHTML = lock + " " + chia_pending_abs + " CH"
279281
}
280282
}
281283
}
@@ -417,7 +419,7 @@ function get_colour_response(response) {
417419
wallet_id = response["wallet_id"]
418420
colour = response["colour"]
419421
if (wallet_id == g_wallet_id) {
420-
colour_textfield.innerHTML = "Colour: " + colour;
422+
colour_textfield.innerHTML = "Colour: colour_desc://" + colour;
421423
}
422424
}
423425

@@ -485,6 +487,13 @@ send.addEventListener('click', () => {
485487

486488
try {
487489
puzzle_hash = receiver_address.value;
490+
if (puzzle_hash.includes("chia_addr") || puzzle_hash.includes("colour_desc")){
491+
alert("Error: recipient address is not a coloured wallet address. Please enter a coloured wallet address")
492+
return
493+
}
494+
if (puzzle_hash.substring(0,14) == "colour_addr://"){
495+
puzzle_hash = puzzle_hash.substring(14)
496+
}
488497
if (puzzle_hash.startsWith("0x") || puzzle_hash.startsWith("0X")) {
489498
puzzle_hash = puzzle_hash.substring(2);
490499
}
@@ -586,7 +595,8 @@ function get_innerpuzzlehash_response(response) {
586595
/*
587596
Called when response is received for get_new_puzzle_hash request
588597
*/
589-
puzzle_holder.value = response["innerpuz"];
598+
puzzle_hash = "colour_addr://"
599+
puzzle_holder.value = puzzle_hash.concat(response["innerpuz"]);
590600
QRCode.toCanvas(canvas, response["innerpuz"], function (error) {
591601
if (error) console.error(error)
592602
})

electron-ui/cc_wallet/create_cc_wallet.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ function create_wallet_input_colour() {
9090

9191
try {
9292
colour = input_colour_text.value;
93+
if (colour.substring(0,14) == "colour_desc://"){
94+
colour = colour.substring(14)
95+
}
9396
if (colour.startsWith("0x") || colour.startsWith("0X")) {
9497
colour = colour.substring(2);
9598
}

electron-ui/renderer.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@ send.addEventListener('click', () => {
169169

170170
try {
171171
puzzle_hash = receiver_address.value;
172+
if (puzzle_hash.includes("colour")){
173+
dialogs.alert("Error: Cannot send chia to coloured address. Please enter a chia address.")
174+
return
175+
} else if (puzzle_hash.substring(0, 12) == "chia_addr://") {
176+
puzzle_hash = puzzle_hash.substring(12)
177+
}
172178
if (puzzle_hash.startsWith("0x") || puzzle_hash.startsWith("0X")) {
173179
puzzle_hash = puzzle_hash.substring(2);
174180
}
@@ -215,7 +221,13 @@ farm_button.addEventListener('click', () => {
215221
dialogs.alert("Specify puzzle_hash for coinbase reward", ok => {
216222
})
217223
return
224+
} else if (puzzle_hash.includes("colour")){
225+
dialogs.alert("Please enter a chia address for coinbase reward.")
226+
return
227+
} else if (puzzle_hash.substring(0, 12) == "chia_addr://") {
228+
puzzle_hash = puzzle_hash.substring(12)
218229
}
230+
219231
data = {
220232
"puzzle_hash": puzzle_hash,
221233
"wallet_id": g_wallet_id,
@@ -295,7 +307,9 @@ function get_new_puzzlehash_response(response) {
295307
Called when response is received for get_new_puzzle_hash request
296308
*/
297309
let puzzle_holder = document.querySelector("#puzzle_holder");
298-
puzzle_holder.value = response["puzzlehash"];
310+
puzzle_hash = "chia_addr://"
311+
puzzle_hash = puzzle_hash.concat(response["puzzlehash"]);
312+
puzzle_holder.value = puzzle_hash
299313
QRCode.toCanvas(canvas, response["puzzlehash"], function (error) {
300314
if (error) console.error(error)
301315
})
@@ -323,10 +337,12 @@ function get_wallet_balance_response(response) {
323337
var confirmed = parseInt(response["confirmed_wallet_balance"])
324338
var unconfirmed = parseInt(response["unconfirmed_wallet_balance"])
325339
var pending = confirmed - unconfirmed
326-
var wallet_id = response["wallet_id"]
327340

341+
var wallet_id = response["wallet_id"]
342+
console.log("wallet_id = " + wallet_id + "confirmed: " + confirmed + "unconfirmed: " + unconfirmed )
328343
chia_confirmed = chia_formatter(confirmed, 'mojo').to('chia').toString()
329344
chia_pending = chia_formatter(pending, 'mojo').to('chia').toString()
345+
chia_pending_abs = chia_formatter(Math.abs(pending), 'mojo').to('chia').toString()
330346

331347
wallet_balance_holder = document.querySelector("#" + "balance_wallet_" + wallet_id )
332348
wallet_pending_holder = document.querySelector("#" + "pending_wallet_" + wallet_id )
@@ -336,7 +352,7 @@ function get_wallet_balance_response(response) {
336352
if (pending > 0) {
337353
pending_textfield.innerHTML = lock + " - " + chia_pending + " CH"
338354
} else {
339-
pending_textfield.innerHTML = lock + " " + chia_pending + " CH"
355+
pending_textfield.innerHTML = lock + " " + chia_pending_abs + " CH"
340356
}
341357
}
342358
if (wallet_balance_holder) {
@@ -346,7 +362,7 @@ function get_wallet_balance_response(response) {
346362
if (pending > 0) {
347363
wallet_pending_holder.innerHTML = lock + " - " + chia_pending + " CH"
348364
} else {
349-
wallet_pending_holder.innerHTML = lock + " " + chia_pending + " CH"
365+
wallet_pending_holder.innerHTML = lock + " " + chia_pending_abs + " CH"
350366
}
351367
}
352368
}

electron-ui/trade_renderer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ function get_wallet_balance_response(response) {
220220

221221
chia_confirmed = chia_formatter(confirmed, 'mojo').to('chia').toString()
222222
chia_pending = chia_formatter(pending, 'mojo').to('chia').toString()
223+
chia_pending_abs = chia_formatter(Math.abs(pending), 'mojo').to('chia').toString()
223224

224225
wallet_balance_holder = document.querySelector("#" + "balance_wallet_" + wallet_id )
225226
wallet_pending_holder = document.querySelector("#" + "pending_wallet_" + wallet_id )
@@ -231,7 +232,7 @@ function get_wallet_balance_response(response) {
231232
if (pending > 0) {
232233
wallet_pending_holder.innerHTML = lock + " - " + chia_pending + " CH"
233234
} else {
234-
wallet_pending_holder.innerHTML = lock + " " + chia_pending + " CH"
235+
wallet_pending_holder.innerHTML = lock + " " + chia_pending_abs + " CH"
235236
}
236237
}
237238
}

electron-ui/wallet-dark.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ <h3 id="pending_textfield">0 CH</h3>
114114
</li>
115115
</ul>
116116
<div class="wallet-address">
117-
<p>Receiver Address:</p>
117+
<p>Recipient Address:</p>
118118
<div class="input-group" style="padding-top:0px">
119119
<input type="text" class="form-control" id="receiver_puzzle_hash" value="">
120120
</div>/

src/types/spend_bundle.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,15 @@ def not_ephemeral_spends(self):
7373
result.append(rem)
7474

7575
return result
76+
77+
def not_ephemeral_additions(self):
78+
all_removals = self.removals()
79+
all_additions = self.additions()
80+
result: List[Coin] = []
81+
82+
for add in all_additions:
83+
if add in all_removals:
84+
continue
85+
result.append(add)
86+
87+
return result

0 commit comments

Comments
 (0)