Skip to content

Commit 7f78357

Browse files
committed
-added address type prefixes
1 parent 4fb49f1 commit 7f78357

File tree

5 files changed

+30
-5
lines changed

5 files changed

+30
-5
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: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ function get_colour_response(response) {
419419
wallet_id = response["wallet_id"]
420420
colour = response["colour"]
421421
if (wallet_id == g_wallet_id) {
422-
colour_textfield.innerHTML = "Colour: " + colour;
422+
colour_textfield.innerHTML = "Colour: colour_desc://" + colour;
423423
}
424424
}
425425

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

488488
try {
489489
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+
}
490497
if (puzzle_hash.startsWith("0x") || puzzle_hash.startsWith("0X")) {
491498
puzzle_hash = puzzle_hash.substring(2);
492499
}
@@ -588,7 +595,8 @@ function get_innerpuzzlehash_response(response) {
588595
/*
589596
Called when response is received for get_new_puzzle_hash request
590597
*/
591-
puzzle_holder.value = response["innerpuz"];
598+
puzzle_hash = "colour_addr://"
599+
puzzle_holder.value = puzzle_hash.concat(response["innerpuz"]);
592600
QRCode.toCanvas(canvas, response["innerpuz"], function (error) {
593601
if (error) console.error(error)
594602
})

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: 15 additions & 1 deletion
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
})

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>/

0 commit comments

Comments
 (0)