@@ -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 }
0 commit comments