Skip to content

Commit

Permalink
Merge pull request #263 from sCrypt-Inc/bsv-types
Browse files Browse the repository at this point in the history
Add missing functions for Point and Signatures
  • Loading branch information
xhliu authored Feb 13, 2024
2 parents dc9c095 + ce548b4 commit 4502c17
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scryptlib",
"version": "2.1.39",
"version": "2.1.40",
"description": "Javascript SDK for integration of Bitcoin SV Smart Contracts written in sCrypt language.",
"engines": {
"node": ">=14.0.0"
Expand Down
30 changes: 19 additions & 11 deletions patches/bsv/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,14 @@ declare module 'bsv' {
*/
static OP_16: number;

/**
* Does nothing.
* @opcode {`97`}
* @hex {`0x61`}
* @input Nothing
* @output Nothing
* @static
*/
/**
* Does nothing.
* @opcode {`97`}
* @hex {`0x61`}
* @input Nothing
* @output Nothing
* @static
*/
static OP_NOP: number;

/**
Expand Down Expand Up @@ -753,16 +753,24 @@ declare module 'bsv' {
}

class Point {
constructor(x: crypto.BN | string,
y: crypto.BN | string,
isRed: boolean);

static fromX(odd: boolean, x: crypto.BN | string): Point;
static getG(): any;
static getN(): crypto.BN;
getX(): crypto.BN;
getY(): crypto.BN;
validate(): this;
mul(n: crypto.BN): Point;
add(n: crypto.Point): Point;
neg(): Point;
}

class Signature {
constructor(r: crypto.BN, s: crypto.BN);

static fromDER(sig: Buffer): Signature;
static fromTxFormat(buf: Buffer): Signature;
static fromString(data: string): Signature;
Expand Down Expand Up @@ -922,7 +930,7 @@ declare module 'bsv' {
privateKey: PrivateKey[] | string[] | PrivateKey | string,
sigtype?: number
): this;
applySignature(sig: { inputIndex: number, sigtype: number, publicKey: PublicKey, signature: crypto.Signature}): this;
applySignature(sig: { inputIndex: number, sigtype: number, publicKey: PublicKey, signature: crypto.Signature }): this;
verifySignature(sig: crypto.Signature, pubkey: PublicKey, nin: number, subscript: Script, satoshisBN: crypto.BN, flags: number): boolean;
addInput(
input: Transaction.Input,
Expand All @@ -938,7 +946,7 @@ declare module 'bsv' {
hasWitnesses(): boolean;
getFee(): number;
getChangeOutput(): Transaction.Output | null;
getChangeAddress(): Address | null;
getChangeAddress(): Address | null;
getLockTime(): Date | number;
setLockTime(t: number): this;

Expand Down Expand Up @@ -995,7 +1003,7 @@ declare module 'bsv' {
error: string,
failedAt: any
};
verifyScript(inputIndex: number): {
verifyScript(inputIndex: number): {
success: boolean,
error: string,
failedAt: any
Expand Down

0 comments on commit 4502c17

Please sign in to comment.