@@ -15,12 +15,27 @@ const nostrPublicKey = '0x45c41f21e1cf715fa6d9ca20b8e002a574db7bb49e96ee89834c66
1515const nostrLockScript = sdk .lock .buildScript (nostrPublicKey );
1616const ckbAddress = sdk .lock .encodeToCKBAddress (nostrPublicKey );
1717
18- // signed a nostr-lock input transaction
18+ // **** Signed a nostr-lock input transaction ****//
19+
20+ // construct a nostr signer first
1921const signer = async (event : EventToSign ) => {
2022 // ...nostr signing event code
2123 const signedEvent: SignedEvent = // ...
2224 return signedEvent ;
2325};
26+ // sdk.lock.signTx will overwrite the witness lock with dummyLock and then generate sigHashAll,
27+ // sign it and return signed transaction. It is a easy way to do nostr lock signing if
28+ // transaction fee estimation is not a problem to you. After calling this function, witness
29+ // is auto-filled with signedEvent.
2430txSkeleton = await sdk .lock .signTx (txSkeleton , signer );
25- // witness is auto-filled with signedEvent
31+
32+ // or prepare your transaction first
33+ import { createTransactionFromSkeleton } from " @ckb-lumos/lumos/helpers" ;
34+ let tx = createTransactionFromSkeleton (txSkeleton );
35+ // fill-in the witness of nostr-lock with corresponding dummyLock
36+ tx = await sdk .lock .prepareTx (transaction : Transaction );
37+ // sdk.lock.signPreparedTx will checks if the transaction is placed with correct Nostr-lock dummyLock
38+ // and then directly generate sigHashAll from the giving transaction, sign it and return
39+ // signed transaction. You need to call prepareTx before this function.
40+ const signedTx = await sdk .lock .signPreparedTx (tx , signer );
2641```
0 commit comments