From 41e8eabde10f44f7c05df2c833a88c124b5696b3 Mon Sep 17 00:00:00 2001 From: ByteZhang Date: Mon, 29 Jul 2024 18:34:38 +0800 Subject: [PATCH] chore: release version 1.0.0-alpha.2 --- index.d.ts | 4 ++-- lib/transaction/sighash.js | 4 ++-- lib/transaction/unspentoutput.js | 13 +++++++++++-- package.json | 2 +- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/index.d.ts b/index.d.ts index 2d0e50f..e271145 100644 --- a/index.d.ts +++ b/index.d.ts @@ -93,7 +93,7 @@ declare module '@onekeyfe/kaspacore-lib' { export namespace Transaction { static class sighash { - static sign(transaction, privateKey, sighashType, inputIndex, subscript, satoshisBN, flags, signingMethod); + // static sign(transaction, privateKey, sighashType, inputIndex, subscript, satoshisBN, flags, signingMethod); static sighash(transaction, sighashType, inputNumber, subscript, satoshisBN, flags): Buffer; } class UnspentOutput { @@ -155,7 +155,7 @@ declare module '@onekeyfe/kaspacore-lib' { fee(amount: number): this; setVersion(version: number): this; feePerKb(amount: number): this; - sign(privateKey: PrivateKey|PrivateKey[] | string|string[], sigtype:number, signingMethod:string|undefined): this; + // sign(privateKey: PrivateKey|PrivateKey[] | string|string[], sigtype:number, signingMethod:string|undefined): this; applySignature(sig: crypto.Signature): this; addInput(input: Transaction.Input): this; addOutput(output: Transaction.Output): this; diff --git a/lib/transaction/sighash.js b/lib/transaction/sighash.js index 2f90ee7..34d1979 100644 --- a/lib/transaction/sighash.js +++ b/lib/transaction/sighash.js @@ -529,6 +529,6 @@ function verify(transaction, signature, publicKey, inputIndex, subscript, satosh */ module.exports = { sighash: sighash, - sign: sign, - verify: verify + // sign: sign, + // verify: verify }; \ No newline at end of file diff --git a/lib/transaction/unspentoutput.js b/lib/transaction/unspentoutput.js index 933cb17..e142cad 100644 --- a/lib/transaction/unspentoutput.js +++ b/lib/transaction/unspentoutput.js @@ -7,6 +7,7 @@ var JSUtil = require('../util/js'); var Script = require('../script'); var Address = require('../address'); var Unit = require('../unit'); +var BN = require('../crypto/bn'); /** * Represents an unspent output information: its script, associated amount and address, @@ -46,8 +47,16 @@ function UnspentOutput(data) { var script = new Script(data.scriptPubKey || data.script); $.checkArgument(!_.isUndefined(data.amount) || !_.isUndefined(data.satoshis), 'Must provide an amount for the output'); - var amount = !_.isUndefined(data.amount) ? new Unit.fromBTC(data.amount).toSatoshis() : data.satoshis; - $.checkArgument(_.isNumber(amount), 'Amount must be a number'); + + var amount; + if (!_.isUndefined(data.amount)) { + amount = BN.fromNumber(data.amount); + amount = amount.mul(new BN(1e8)).toString(); + } else { + amount = BN.fromNumber(data.satoshis).toString(); + } + $.checkArgument(!amount.isNaN() && amount.gte(0) && amount.includes('.'), 'Amount must be a number'); + JSUtil.defineImmutable(this, { address: address, txId: txId, diff --git a/package.json b/package.json index 0f0a0aa..3277a79 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/kaspacore-lib", - "version": "1.0.0-alpha.1", + "version": "1.0.0-alpha.2", "main": "index.js", "authors": [ {