@@ -73,8 +73,7 @@ var DashGov = ("object" === typeof module && exports) || {};
73
73
// Adapted from
74
74
// github.com/dashpay/dash/tree/develop/src/governance/common.cpp
75
75
76
- // USAGE
77
- // node ./gobject-hash-debugger.js
76
+ let Crypto = globalThis . crypto ;
78
77
79
78
const LITTLE_ENDIAN = true ;
80
79
const VARINT_8_MAX = 252 ;
@@ -459,6 +458,17 @@ var DashGov = ("object" === typeof module && exports) || {};
459
458
return ms ;
460
459
} ;
461
460
461
+ /**
462
+ * @param {Uint8Array } gobjBytes - serialized gobj bytes
463
+ */
464
+ GObj . proposal . doubleSha256 = async function ( gobjBytes ) {
465
+ let hash1 = await Crypto . subtle . digest ( "SHA-256" , gobjBytes ) ;
466
+ let hash2 = await Crypto . subtle . digest ( "SHA-256" , hash1 ) ;
467
+ let gobjHash = new Uint8Array ( hash2 ) ;
468
+
469
+ return gobjHash ;
470
+ } ;
471
+
462
472
/**
463
473
* Note: since we're dealing with estimates that are typically reliable
464
474
* within an hour (and often even within 15 minutes), this may
@@ -526,8 +536,8 @@ var DashGov = ("object" === typeof module && exports) || {};
526
536
527
537
/**
528
538
* @param {Snapshot } snapshot
529
- * @param {Float64 } [ secondsPerBlock]
530
- * @param {Uint53 } offset - how many superblocks in the future
539
+ * @param {Float64 } secondsPerBlock
540
+ * @param {Uint53 } [ offset] - how many superblocks in the future
531
541
* @returns {Estimate } - details about the current governance cycle
532
542
*/
533
543
GObj . estimateNthNextGovCycle = function (
0 commit comments