@@ -1303,6 +1303,21 @@ class HTTP extends Server {
1303
1303
this . to ( 'w:*' , event , wallet . id , json ) ;
1304
1304
} ;
1305
1305
1306
+ const handleCovenant = ( event , wallet , ns , details ) => {
1307
+ const name = `w:${ wallet . id } ` ;
1308
+
1309
+ if ( ! this . channel ( name ) && ! this . channel ( 'w:*' ) )
1310
+ return ;
1311
+
1312
+ const json = details . getJSON ( this . network , this . wdb . height ) ;
1313
+
1314
+ if ( this . channel ( name ) )
1315
+ this . to ( name , event , wallet . id , ns , json ) ;
1316
+
1317
+ if ( this . channel ( 'w:*' ) )
1318
+ this . to ( 'w:*' , event , wallet . id , ns , json ) ;
1319
+ } ;
1320
+
1306
1321
this . wdb . on ( 'tx' , ( wallet , tx , details ) => {
1307
1322
handleTX ( 'tx' , wallet , tx , details ) ;
1308
1323
} ) ;
@@ -1351,6 +1366,16 @@ class HTTP extends Server {
1351
1366
if ( this . channel ( 'w:*' ) )
1352
1367
this . to ( 'w:*' , 'address' , wallet . id , json ) ;
1353
1368
} ) ;
1369
+
1370
+ // set up listener for each covenant type
1371
+ for ( const type of Object . values ( rules . typesByVal ) )
1372
+ if ( type !== 'NONE' ) {
1373
+ const action = type . toLowerCase ( ) ;
1374
+ const channel = `${ action } covenant` ;
1375
+ this . wdb . on ( channel , ( wallet , data , details ) => {
1376
+ handleCovenant ( channel , wallet , data , details ) ;
1377
+ } ) ;
1378
+ }
1354
1379
}
1355
1380
1356
1381
/**
0 commit comments