@@ -8,7 +8,7 @@ import AcreBtcNew from "../../src/AcreBtcNew";
8
8
import { DefaultDescriptorTemplate , WalletPolicy } from "../../src/newops/policy" ;
9
9
import { PsbtV2 } from "../../src/newops/psbtv2" ;
10
10
import { splitTransaction } from "../../src/splitTransaction" ;
11
- import { withdrawalAPDUs , signMessageAPDUs } from "./apdus" ;
11
+ import { withdrawalAPDUs , signMessageAPDUs , signERC4361APDUs } from "./apdus" ;
12
12
import {
13
13
StandardPurpose ,
14
14
addressFormatFromDescriptorTemplate ,
@@ -58,10 +58,13 @@ test("testSignMessage", async () => {
58
58
await testSignMessageReplayer ( "m/44'/0'/0'" ) ;
59
59
} ) ;
60
60
61
+ test ( "signWithdrawal" , async ( ) => {
62
+ await testSignWithdrawalReplayer ( ) ;
63
+ } ) ;
61
64
62
- test ( "Sign ERC-4361 message" , async ( ) => {
63
- await testSignERC4361Speculos ( ) ;
64
- } , 60 * 10 * 1000 ) ; // 10-minute timeout (60 seconds * 10 minutes * 1000 milliseconds)
65
+ test ( "Sign ERC4361 message" , async ( ) => {
66
+ await testSignERC4361MessageReplayer ( "m/44'/0'/0'" ) ;
67
+ } ) ;
65
68
66
69
function testPaths ( type : StandardPurpose ) : { ins : string [ ] ; out ?: string } {
67
70
const basePath = `m/${ type } /1'/0'/` ;
@@ -230,14 +233,22 @@ async function testSignWithdrawalReplayer() {
230
233
} ) ;
231
234
}
232
235
233
- async function testSignERC4361Speculos ( ) {
234
- const transport = new SpeculosTransport ( 'http://localhost:5000' )
236
+ async function testSignERC4361MessageReplayer (
237
+ accountPath : string ,
238
+ ) {
239
+ const transport = await openTransportReplayer ( RecordStore . fromString ( signERC4361APDUs ) ) ;
235
240
const client = new AppClient ( transport ) ;
241
+ const path = accountPath + "/0/0" ;
242
+
236
243
const acreBtcNew = new AcreBtcNew ( client ) ;
237
244
const message = "stake.acre.fi wants you to sign in with your Bitcoin account:\nbc1q8fq0vs2f9g52cuk8px9f664qs0j7vtmx3r7wvx\n\n\nURI: https://stake.acre.fi\nVersion: 1\nNonce: cw73Kfdfn1lY42Jj8\nIssued At: 2024-10-01T11:03:05.707Z\nExpiration Time: 2024-10-08T11:03:05.707Z"
238
- const path = "m/44'/0'/0'/0/0" ;
239
245
const result = await acreBtcNew . signERC4361Message ( { messageHex : Buffer . from ( message ) . toString ( "hex" ) , path : path } ) ;
240
- console . log ( result ) ;
246
+ expect ( result ) . toEqual ( {
247
+ v : 1 ,
248
+ r : 'f30ff91331b840cc97560b468d9dce0647afbef7fd74819773721a096905da7e' ,
249
+ s : '664a3ce374f1951e40222d433cd8d6977dde08af6320acc8dd90fa35ed1c8ed8'
250
+ } ) ;
251
+
241
252
}
242
253
243
254
function verifyGetWalletPublicKeyResult (
0 commit comments