@smartledger/bsv 7.5.0 → 7.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bsv.d.ts CHANGED
@@ -176,19 +176,30 @@ declare module '@smartledger/bsv' {
176
176
  toAddress(): Address;
177
177
  toPublicKey(): PublicKey;
178
178
  toString(): string;
179
- toObject(): object;
180
- toJSON(): object;
179
+ /** Deliberate export, INCLUDING the secret scalar. Round-trips with fromObject(). */
180
+ toObject(): { bn: string; compressed: boolean; network: string };
181
+ /**
182
+ * What JSON.stringify() calls — the scalar is REDACTED. Use toObject() or toWIF()
183
+ * when you actually intend to export the secret.
184
+ */
185
+ toJSON(): { bn: '[REDACTED]'; compressed: boolean; network: string };
181
186
  toWIF(): string;
182
187
  toHex(): string;
183
188
  toBigNumber(): any; //BN;
184
189
  toBuffer(): Buffer;
185
190
  inspect(): string;
186
191
 
187
- static fromString(str: string): PrivateKey;
188
- static fromWIF(str: string): PrivateKey;
189
- static fromRandom(netowrk?: string): PrivateKey;
190
- static fromBuffer(buf: Buffer, network: string | Networks.Network): PrivateKey;
191
- static fromHex(hex: string, network: string | Networks.Network): PrivateKey;
192
+ /**
193
+ * From a WIF string, or a hex-encoded scalar. `network` is honoured; for a WIF,
194
+ * which encodes its own network, a conflicting value throws.
195
+ */
196
+ static fromString(str: string, network?: string | Networks.Network): PrivateKey;
197
+ static fromWIF(str: string, network?: string | Networks.Network): PrivateKey;
198
+ static fromRandom(network?: string): PrivateKey;
199
+ /** `compressed` defaults to true, matching every other constructor path. */
200
+ static fromBuffer(buf: Buffer, network?: string | Networks.Network, compressed?: boolean): PrivateKey;
201
+ /** `compressed` defaults to true, matching every other constructor path. */
202
+ static fromHex(hex: string, network?: string | Networks.Network, compressed?: boolean): PrivateKey;
192
203
  static getValidationError(data: string): any | null;
193
204
  static isValid(data: string): boolean;
194
205
  }
@@ -712,6 +723,24 @@ declare module '@smartledger/bsv' {
712
723
 
713
724
  // -------- GDAF (Global Digital Attestation Framework) ---------------
714
725
 
726
+ /** A spendable output supplied to the anchoring helpers. */
727
+ export interface Utxo {
728
+ txId: string;
729
+ outputIndex: number;
730
+ script: string;
731
+ satoshis: number;
732
+ }
733
+
734
+ export interface AnchorOptions {
735
+ /** UTXOs funding the anchor transaction. */
736
+ utxos?: Utxo[];
737
+ /**
738
+ * Serialised into the OP_RETURN: PUBLIC AND PERMANENT. Anchoring a PrivateKey, or
739
+ * any key-shaped field (`bn`, `wif`, `privateJwk`, `seed`, `xprv`, ...), throws.
740
+ */
741
+ metadata?: object;
742
+ }
743
+
715
744
  export class GDAF {
716
745
  constructor(options?: {
717
746
  attestationSigner?: object;
@@ -747,10 +776,15 @@ declare module '@smartledger/bsv' {
747
776
  verifyMembershipProof(proof: object, validSet: string[]): boolean;
748
777
 
749
778
  // Anchoring
750
- anchorCredential(credential: object, privateKey: PrivateKey, options?: object): object;
751
- anchorBatch(credentials: object[], privateKey: PrivateKey, options?: object): object;
752
- registerDID(did: string, didDocument: object, privateKey: PrivateKey, options?: object): object;
753
- revokeCredential(credentialId: string, reason: string, privateKey: PrivateKey, options?: object): object;
779
+ /**
780
+ * Anchor options. `metadata` is JSON-serialised into the OP_RETURN and is therefore
781
+ * PUBLIC AND PERMANENT — anchoring anything key-shaped throws. A bare UTXO array is
782
+ * also accepted in place of this object.
783
+ */
784
+ anchorCredential(credentialHash: string | Buffer, privateKey: PrivateKey, options?: AnchorOptions | Utxo[]): Promise<object>;
785
+ anchorBatch(credentialHashes: Array<string | Buffer>, privateKey: PrivateKey, options?: AnchorOptions | Utxo[]): Promise<object>;
786
+ registerDID(did: string, didDocument: object, privateKey: PrivateKey, options?: AnchorOptions | Utxo[]): Promise<object>;
787
+ revokeCredential(credentialId: string, reason: string, privateKey: PrivateKey, options?: AnchorOptions | Utxo[]): Promise<object>;
754
788
  queryAnchoredData(hash: string): object;
755
789
 
756
790
  // Schemas