@@ -70,6 +70,9 @@ <h1 class="text-3xl font-bold text-center text-blue-600 mb-6">Mintlayer Wallet D
70
70
< button onclick ="toggleSection('delegationStake') " class ="bg-gray-200 text-gray-700 py-2 px-4 rounded-md hover:bg-gray-300 transition "> Delegation Stake</ button >
71
71
< button onclick ="toggleSection('delegationWithdraw') " class ="bg-gray-200 text-gray-700 py-2 px-4 rounded-md hover:bg-gray-300 transition "> Delegation Withdraw</ button >
72
72
< button onclick ="toggleSection('signChallenge') " class ="bg-gray-200 text-gray-700 py-2 px-4 rounded-md hover:bg-gray-300 transition "> Sign Challenge</ button >
73
+ < button onclick ="toggleSection('requestSecretHash') " class ="bg-gray-200 text-gray-700 py-2 px-4 rounded-md hover:bg-gray-300 transition "> Request Secret Hash</ button >
74
+ < button onclick ="toggleSection('createHtlc') " class ="bg-gray-200 text-gray-700 py-2 px-4 rounded-md hover:bg-gray-300 transition "> Create Htlc</ button >
75
+ < button onclick ="toggleSection('refundHtlc') " class ="bg-gray-200 text-gray-700 py-2 px-4 rounded-md hover:bg-gray-300 transition "> Refund Htlc</ button >
73
76
</ div >
74
77
75
78
<!-- Transfer Section -->
@@ -328,6 +331,42 @@ <h3 class="text-lg font-semibold text-gray-700 mb-4">Sign Challenge</h3>
328
331
< button onclick ="signChallenge() " class ="bg-green-500 text-white py-2 px-4 rounded-md shadow hover:bg-green-600 transition w-full "> Sign Challenge</ button >
329
332
</ div >
330
333
</ div >
334
+
335
+ <!-- RequestSecretHash Section -->
336
+ < div id ="requestSecretHash " class ="bg-white p-6 rounded-lg shadow-md hidden ">
337
+ < h3 class ="text-lg font-semibold text-gray-700 mb-4 "> Request Secret Hash</ h3 >
338
+ < div class ="space-y-4 ">
339
+ < button onclick ="requestSecretHash() " class ="bg-green-500 text-white py-2 px-4 rounded-md shadow hover:bg-green-600 transition w-full "> Request Secret Hash</ button >
340
+ </ div >
341
+ </ div >
342
+
343
+ <!-- Create HTLC Section -->
344
+ < div id ="createHtlc " class ="bg-white p-6 rounded-lg shadow-md hidden ">
345
+ < h3 class ="text-lg font-semibold text-gray-700 mb-4 "> Create HTLC</ h3 >
346
+ < div class ="space-y-4 ">
347
+ < input type ="text " id ="create_htlc_amount " placeholder ="Amount " class ="w-full border border-gray-300 rounded-md p-2 focus:ring-2 focus:ring-blue-500 focus:outline-none " />
348
+ < input type ="text " id ="create_htlc_token_id " placeholder ="Token ID (leave empty for ML Coin) " class ="w-full border border-gray-300 rounded-md p-2 focus:ring-2 focus:ring-blue-500 focus:outline-none " />
349
+ < input type ="text " id ="create_htlc_spend_address " placeholder ="Spend Address " class ="w-full border border-gray-300 rounded-md p-2 focus:ring-2 focus:ring-blue-500 focus:outline-none " />
350
+ < input type ="text " id ="create_htlc_refund_address " placeholder ="Refund Address " class ="w-full border border-gray-300 rounded-md p-2 focus:ring-2 focus:ring-blue-500 focus:outline-none " />
351
+ < input type ="text " id ="create_htlc_secret_hash_hex " placeholder ="Secret hash hex " class ="w-full border border-gray-300 rounded-md p-2 focus:ring-2 focus:ring-blue-500 focus:outline-none " />
352
+ < select name ="create_htlc_lock_type " id ="create_htlc_lock_type " class ="w-full border border-gray-300 rounded-md p-2 focus:ring-2 focus:ring-blue-500 focus:outline-none ">
353
+ < option value =""> Lock Type</ option >
354
+ < option value ="ForBlockCount "> ForBlockCount</ option >
355
+ < option value ="UntilTime "> UntilTime</ option >
356
+ </ select >
357
+ < input type ="text " id ="create_htlc_lock_content " placeholder ="Lock content " class ="w-full border border-gray-300 rounded-md p-2 focus:ring-2 focus:ring-blue-500 focus:outline-none " />
358
+ < button onclick ="createHTLC() " class ="bg-green-500 text-white py-2 px-4 rounded-md shadow hover:bg-green-600 transition w-full "> Create HTLC</ button >
359
+ </ div >
360
+ </ div >
361
+
362
+ <!-- Refund HTLC Section -->
363
+ < div id ="refundHtlc " class ="bg-white p-6 rounded-lg shadow-md hidden ">
364
+ < h3 class ="text-lg font-semibold text-gray-700 mb-4 "> Refund HTLC</ h3 >
365
+ < div class ="space-y-4 ">
366
+ < input type ="text " id ="refund_htlc_transaction_id " placeholder ="Transaction ID with HTLC " class ="w-full border border-gray-300 rounded-md p-2 focus:ring-2 focus:ring-blue-500 focus:outline-none " />
367
+ < button onclick ="refundHTLC() " class ="bg-green-500 text-white py-2 px-4 rounded-md shadow hover:bg-green-600 transition w-full "> Refund HTLC</ button >
368
+ </ div >
369
+ </ div >
331
370
</ div >
332
371
</ div >
333
372
@@ -351,7 +390,7 @@ <h3 class="text-xl font-semibold text-gray-700 mb-4">Output</h3>
351
390
'lockTokenSupply' , 'changeTokenAuthority' , 'changeTokenMetadata' , 'createOrder' ,
352
391
'fillOrder' , 'concludeOrder' , 'bridgeRequest' , 'broadcastTx' , 'freezeToken' ,
353
392
'unfreezeToken' , 'burn' , 'dataDeposit' , 'createDelegation' , 'delegationStake' ,
354
- 'delegationWithdraw' , 'signChallenge'
393
+ 'delegationWithdraw' , 'signChallenge' , 'createHtlc' , 'refundHtlc' , 'requestSecretHash'
355
394
] ;
356
395
sections . forEach ( id => {
357
396
const el = document . getElementById ( id ) ;
@@ -921,6 +960,60 @@ <h3 class="text-xl font-semibold text-gray-700 mb-4">Output</h3>
921
960
}
922
961
}
923
962
963
+ async function createHTLC ( ) {
964
+ const amount = document . getElementById ( 'create_htlc_amount' ) . value ;
965
+ const spend_address = document . getElementById ( 'create_htlc_spend_address' ) . value ;
966
+ const refund_address = document . getElementById ( 'create_htlc_refund_address' ) . value ;
967
+ const secret_hash_hex = document . getElementById ( 'create_htlc_secret_hash_hex' ) . value ;
968
+ const lock_type = document . getElementById ( 'create_htlc_lock_type' ) . value ;
969
+ const lock_content = document . getElementById ( 'create_htlc_lock_content' ) . value ;
970
+ const token_id = document . getElementById ( 'create_htlc_token_id' ) . value ;
971
+
972
+ try {
973
+ const result = await window . mintlayer . createHtlc ( {
974
+ amount : amount ,
975
+ spend_address : spend_address ,
976
+ refund_address : refund_address ,
977
+ refund_timelock : {
978
+ type : lock_type ,
979
+ content : lock_content
980
+ } ,
981
+ token_id : token_id || null , // null for native token
982
+ secret_hash : {
983
+ hex : secret_hash_hex
984
+ } ,
985
+ } ) ;
986
+
987
+ displayOutput ( `Transaction: ${ JSON . stringify ( result , null , 2 ) } ` ) ;
988
+ } catch ( error ) {
989
+ displayOutput ( `Error: ${ error . message } ` ) ;
990
+ }
991
+ }
992
+
993
+ async function refundHTLC ( ) {
994
+ const transaction_id = document . getElementById ( 'refund_htlc_transaction_id' ) . value ;
995
+
996
+ try {
997
+ const { signature } = await window . mintlayer . refundHtlc ( {
998
+ transaction_id,
999
+ } ) ;
1000
+
1001
+ displayOutput ( `Signature: ${ JSON . stringify ( signature , null , 2 ) } ` ) ;
1002
+ } catch ( error ) {
1003
+ displayOutput ( `Error: ${ error . message } ` ) ;
1004
+ }
1005
+ }
1006
+
1007
+ async function requestSecretHash ( ) {
1008
+ try {
1009
+ const response = await window . mintlayer . requestSecretHash ( ) ;
1010
+
1011
+ displayOutput ( `Secret Hash: ${ JSON . stringify ( response , null , 2 ) } ` ) ;
1012
+ } catch ( error ) {
1013
+ displayOutput ( `Error: ${ error . message } ` ) ;
1014
+ }
1015
+ }
1016
+
924
1017
if ( window . mintlayer ) displayOutput ( 'Mintlayer Connect SDK detected!' ) ;
925
1018
else displayOutput ( 'Mintlayer Connect SDK not found.' ) ;
926
1019
</ script >
0 commit comments