@@ -199,11 +199,18 @@ async function main() {
199
199
// txDraft.outputs.sort(DashTx.sortOutputs);
200
200
let vout = txDraft . outputs . indexOf ( burnOutput ) ;
201
201
202
+ let txProof = DashTx . createRaw ( txDraft ) ;
203
+ txProof . inputs [ 0 ] . script =
204
+ "76a91488d9931ea73d60eaf7e5671efc0552b912911f2a88ac" ;
205
+ txProof . inputs [ 0 ] . sequence = "00000000" ; // Non-final DashTx.NON_FINAL = "00000000"
206
+ //@ts -expect-error
207
+ let txProofHex = await DashTx . serialize ( txProof , null ) ;
208
+ console . log ( `txProof:` , txProof ) ;
209
+ console . log ( txProofHex ) ;
202
210
let txSigned = await dashTx . hashAndSignAll ( txDraft ) ;
203
- console . log ( ) ;
204
- console . log ( `txSigned:` ) ;
205
- console . log ( txSigned ) ;
206
- process . exit ( 1 ) ;
211
+ // console.log();
212
+ // console.log(`txSigned:`);
213
+ // console.log(txSigned);
207
214
208
215
// let txid = await DashTx.utils.rpc(
209
216
// rpcAuthUrl,
@@ -214,26 +221,43 @@ async function main() {
214
221
// const INSTANT_ALP = 0;
215
222
// const CHAIN_ALP = 1;
216
223
217
- let blockchaininfo = await DashTx . utils . rpc ( rpcAuthUrl , "getblockchaininfo" ) ;
218
- let nextBlock = blockchaininfo . blocks + 1 ;
224
+ // let blockchaininfo = await DashTx.utils.rpc(rpcAuthUrl, "getblockchaininfo");
225
+ // let nextBlock = blockchaininfo.blocks + 1;
219
226
220
227
// TODO - AJ is here
228
+ console . log ( `DEBUG funding outpoint` ) ;
221
229
let outpoint = await getFundingOutPointHex ( txSigned . transaction , vout ) ;
230
+ console . log ( outpoint ) ;
222
231
let fundingOutPointHex = `${ outpoint . txid } ${ outpoint . voutHex } ` ;
223
- let identityId = createIdentityId ( fundingOutPointHex ) ;
232
+ console . log ( fundingOutPointHex ) ;
233
+ let identityId = await createIdentityId ( fundingOutPointHex ) ;
234
+ console . log ( identityId ) ;
224
235
225
236
/** @param {any } magicZmqEmitter */
226
237
async function getAssetLockInstantProof ( magicZmqEmitter ) {
227
238
let assetLockInstantProof = {
228
239
// type: INSTANT_ALP,
229
- instant_lock : await magicZmqEmitter . once (
230
- "zmqpubrawtxlocksig" ,
231
- /** @param {any } instantLock */
232
- function ( instantLock ) {
233
- return instantLock . toBase64 ( ) ;
234
- } ,
235
- ) ,
236
- transaction : txSigned . transaction ,
240
+ // ex: 01 v1
241
+ // 01 1 input
242
+ // 1dbbda5861b12d7523f20aa5e0d42f52de3dcd2d5c2fe919ba67b59f050d206e prev txid
243
+ // 00000000 prev vout
244
+ // 58c444dd0957767db2c0adea69fd861792bfa75c7e364d83fe85bebebc2a08b4 txid
245
+ // 36a56617591a6a89237bada6af1f9b46eba47b5d89a8c4e49ff2d0236182307c cycle hash
246
+ // 8967c46529a967b3822e1ba8a173066296d02593f0f59b3a LLMQ BLS Sig
247
+ // 78a30a7eef9c8a120847729e62e4a32954339286b79fe759
248
+ // 0221331cd28d576887a263f45b595d499272f656c3f51769
249
+ // 87c976239cac16f972d796ad82931d532102a4f95eec7d80
250
+ // instant_lock: await magicZmqEmitter.once(
251
+ // "zmqpubrawtxlocksig",
252
+ // /** @param {any } instantLock */
253
+ // function (instantLock) {
254
+ // return instantLock.toBase64();
255
+ // },
256
+ // ),
257
+ // not sure what "previous outpoint" this refers to, as its not the one in the transaction
258
+ instant_lock :
259
+ "01011dbbda5861b12d7523f20aa5e0d42f52de3dcd2d5c2fe919ba67b59f050d206e0000000058c444dd0957767db2c0adea69fd861792bfa75c7e364d83fe85bebebc2a08b436a56617591a6a89237bada6af1f9b46eba47b5d89a8c4e49ff2d0236182307c8967c46529a967b3822e1ba8a173066296d02593f0f59b3a78a30a7eef9c8a120847729e62e4a32954339286b79fe7590221331cd28d576887a263f45b595d499272f656c3f5176987c976239cac16f972d796ad82931d532102a4f95eec7d80" ,
260
+ transaction : txProofHex ,
237
261
output_index : vout ,
238
262
} ;
239
263
return assetLockInstantProof ;
@@ -253,15 +277,19 @@ async function main() {
253
277
}
254
278
255
279
let assetLockProof ;
256
- let weEvenKnowHowToGetIsdlock = false ;
280
+ let weEvenKnowHowToGetIsdlock = true ;
257
281
if ( weEvenKnowHowToGetIsdlock ) {
258
282
assetLockProof = await getAssetLockInstantProof ( null ) ;
259
283
} else {
260
284
assetLockProof = await getAssetLockChainProof ( ) ;
261
285
}
262
286
263
- let idIndex = 0 ; // increment to first unused
264
- let identityKeys = await getIdentityKeys ( walletKey , idIndex ) ;
287
+ // let idIndex = 0; // increment to first unused
288
+ // let identityKeys = await getIdentityKeys(walletKey, idIndex);
289
+ let identityKeys = await getKnownIdentityKeys (
290
+ { privateKey : masterPrivateKey , publicKey : masterPublicKey } ,
291
+ { privateKey : otherPrivateKey , publicKey : otherPublicKey } ,
292
+ ) ;
265
293
let stKeys = await getIdentityTransitionKeys ( identityKeys ) ;
266
294
267
295
// {
@@ -366,9 +394,7 @@ async function main() {
366
394
console . log ( DashTx . utils . bytesToHex ( bc ) ) ;
367
395
console . log ( bytesToBase64 ( bc ) ) ;
368
396
369
- /** @type {Uint8Array } */ //@ts -expect-error
370
- let privBytes = addressKey . privateKey ;
371
- let sigBytes = await KeyUtils . sign ( privBytes , bc ) ;
397
+ let sigBytes = await KeyUtils . sign ( assetLockPrivateKey , bc ) ;
372
398
// let sigHex = DashTx.utils.bytesToHex(sigBytes);
373
399
Object . assign ( stateTransition , {
374
400
identity_id : identityId ,
@@ -436,74 +462,64 @@ function createIdentityId(fundingOutPointHex) {
436
462
}
437
463
438
464
/**
439
- * @param {DashHd.HDKey } walletKey
440
- * @param {Uint53 } idIndex
465
+ * @param {Required<Pick< DashHd.HDXKey, "privateKey"|"publicKey">> } masterKey
466
+ * @param {Required<Pick<DashHd.HDXKey, "privateKey"|"publicKey">> } otherKey
441
467
* @returns {Promise<Array<EvoKey>> }
442
468
*/
443
- async function getIdentityKeys ( walletKey , idIndex ) {
444
- let identityEcdsaKey = await DashHd . derivePath ( walletKey , identityEcdsaPath ) ;
445
- let identityKey = await DashHd . deriveChild (
446
- identityEcdsaKey ,
447
- idIndex ,
448
- DashHd . HARDENED ,
449
- ) ;
450
-
469
+ async function getKnownIdentityKeys ( masterKey , otherKey ) {
470
+ if ( ! masterKey . privateKey ) {
471
+ throw new Error ( "linter fail" ) ;
472
+ }
473
+ if ( ! otherKey . privateKey ) {
474
+ throw new Error ( "linter fail" ) ;
475
+ }
451
476
let keyDescs = [
477
+ // {"$version":"0","id":0,"purpose":0,"securityLevel":0,"contractBounds":null,"type":0,"readOnly":false,"data":[3,58,154,139,30,76,88,26,25,135,114,76,102,151,19,93,49,192,126,231,172,130,126,106,89,206,192,34,176,77,81,5,95],"disabledAt":null}
452
478
{
453
479
id : 0 ,
454
480
type : KEY_TYPES . ECDSA_SECP256K1 ,
455
481
purpose : KEY_PURPOSES . AUTHENTICATION ,
456
- data : "" ,
457
482
securityLevel : KEY_LEVELS . MASTER ,
458
- // readOnly: false,
459
- } ,
460
- {
461
- id : 1 ,
462
- type : KEY_TYPES . ECDSA_SECP256K1 ,
463
- purpose : KEY_PURPOSES . AUTHENTICATION ,
483
+ readOnly : false ,
484
+ publicKey : masterKey . publicKey ,
485
+ privateKey : masterKey . privateKey ,
464
486
data : "" ,
465
- securityLevel : KEY_LEVELS . HIGH ,
466
- // readOnly: false,
467
487
} ,
488
+ // {"$version":"0","id":1,"purpose":0,"securityLevel":1,"contractBounds":null,"type":0,"readOnly":false,"data":[2,1,70,3,1,141,196,55,100,45,218,22,244,199,252,80,228,130,221,35,226,70,128,188,179,165,150,108,59,52,56,72,226],"disabledAt":null}
468
489
{
469
- id : 2 ,
490
+ id : 1 ,
470
491
type : KEY_TYPES . ECDSA_SECP256K1 ,
471
492
purpose : KEY_PURPOSES . AUTHENTICATION ,
472
- data : "" ,
473
493
securityLevel : KEY_LEVELS . CRITICAL ,
474
- // readOnly: false,
475
- } ,
476
- {
477
- id : 3 ,
478
- type : KEY_TYPES . ECDSA_SECP256K1 ,
479
- purpose : KEY_PURPOSES . TRANSFER ,
494
+ readOnly : false ,
495
+ privateKey : otherKey . privateKey ,
496
+ publicKey : otherKey . publicKey ,
480
497
data : "" ,
481
- securityLevel : KEY_LEVELS . CRITICAL ,
482
- // readOnly: false,
483
498
} ,
484
499
] ;
500
+ return keyDescs ;
501
+
502
+ // let privKeyDescs = [];
503
+ // for (let keyDesc of keyDescs) {
504
+ // let key = await DashHd.deriveChild(
505
+ // identityKey,
506
+ // keyDesc.id,
507
+ // DashHd.HARDENED,
508
+ // );
509
+ // let privKeyDesc = Object.assign(keyDesc, key);
510
+ // privKeyDescs.push(privKeyDesc); // for type info
511
+
512
+ // let dppKey = new WasmDpp.IdentityPublicKey(L2_VERSION_PLATFORM);
513
+ // dppKey.setId(keyDesc.id);
514
+ // dppKey.setData(key.publicKey);
515
+ // if (keyDesc.purpose) {
516
+ // dppKey.setPurpose(keyDesc.purpose);
517
+ // }
518
+ // dppKey.setSecurityLevel(keyDesc.securityLevel);
519
+ // dppKeys.push(dppKey);
520
+ // }
485
521
486
- let privKeyDescs = [ ] ;
487
- for ( let keyDesc of keyDescs ) {
488
- let key = await DashHd . deriveChild (
489
- identityKey ,
490
- keyDesc . id ,
491
- DashHd . HARDENED ,
492
- ) ;
493
- let privKeyDesc = Object . assign ( keyDesc , key ) ;
494
- privKeyDescs . push ( privKeyDesc ) ; // for type info
495
-
496
- // let dppKey = new WasmDpp.IdentityPublicKey(L2_VERSION_PLATFORM);
497
- // dppKey.setId(keyDesc.id);
498
- // dppKey.setData(key.publicKey);
499
- // if (keyDesc.purpose) {
500
- // dppKey.setPurpose(keyDesc.purpose);
501
- // }
502
- // dppKey.setSecurityLevel(keyDesc.securityLevel);
503
- // dppKeys.push(dppKey);
504
- }
505
-
506
- return privKeyDescs ;
522
+ // return privKeyDescs;
507
523
}
508
524
509
525
/**
0 commit comments