We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 01c8574 commit cba36c9Copy full SHA for cba36c9
examples/p-chain/etna/utils/addSignatureToAllCred.ts
@@ -0,0 +1,18 @@
1
+import { secp256k1, type UnsignedTx } from '../../../../src';
2
+
3
+export const addSigToAllCreds = async (
4
+ unsignedTx: UnsignedTx,
5
+ privateKey: Uint8Array,
6
+) => {
7
+ const unsignedBytes = unsignedTx.toBytes();
8
+ const publicKey = secp256k1.getPublicKey(privateKey);
9
10
+ if (!unsignedTx.hasPubkey(publicKey)) {
11
+ return;
12
+ }
13
+ const signature = await secp256k1.sign(unsignedBytes, privateKey);
14
15
+ for (let i = 0; i < unsignedTx.getCredentials().length; i++) {
16
+ unsignedTx.addSignatureAt(signature, i, 0);
17
18
+};
0 commit comments