@@ -474,11 +474,13 @@ class HTTP extends Server {
474
474
throw new Error ( 'Invalid hash.' ) ;
475
475
476
476
const ns = await this . chain . db . getNameState ( hash ) ;
477
+ const height = this . chain . tip . height ;
478
+ const network = this . network ;
477
479
478
480
if ( ! ns )
479
481
return res . json ( 404 ) ;
480
482
481
- return res . json ( 200 , { name : ns . name . toString ( 'binary' ) } ) ;
483
+ return res . json ( 200 , ns . getJSON ( height , network ) ) ;
482
484
} ) ;
483
485
484
486
this . get ( '/resource/name/:name' , async ( req , res ) => {
@@ -496,7 +498,7 @@ class HTTP extends Server {
496
498
497
499
const resource = Resource . decode ( ns . data ) ;
498
500
499
- return res . json ( 200 , resource . toJSON ( ) ) ;
501
+ return res . json ( 200 , resource . getJSON ( name ) ) ;
500
502
} ) ;
501
503
502
504
this . get ( '/proof/name/:name' , async ( req , res ) => {
@@ -506,18 +508,18 @@ class HTTP extends Server {
506
508
if ( ! name || ! rules . verifyName ( name ) )
507
509
throw new Error ( 'Invalid name.' ) ;
508
510
509
- const hash = this . chain . tip . hash ;
511
+ const tip = this . chain . tip . hash ;
510
512
const height = this . chain . tip . height ;
511
513
const root = this . chain . tip . treeRoot ;
512
- const key = rules . hashName ( name ) ;
513
- const proof = await this . chain . db . prove ( root , key ) ;
514
+ const nameHash = rules . hashName ( name ) ;
515
+ const proof = await this . chain . db . prove ( root , nameHash ) ;
514
516
515
517
return res . json ( 200 , {
516
- hash : hash . toString ( 'hex' ) ,
518
+ hash : tip . toString ( 'hex' ) ,
517
519
height : height ,
518
520
root : root . toString ( 'hex' ) ,
519
521
name : name ,
520
- key : key . toString ( 'hex' ) ,
522
+ key : nameHash . toString ( 'hex' ) ,
521
523
proof : proof . toJSON ( )
522
524
} ) ;
523
525
} ) ;
0 commit comments