Skip to content

Commit fcf7119

Browse files
authored
Merge pull request #260 from sCrypt-Inc/bsv
Bsv
2 parents 5720211 + 08cfaae commit fcf7119

5 files changed

Lines changed: 16 additions & 12 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "scryptlib",
3-
"version": "2.1.37",
3+
"version": "2.1.38",
44
"description": "Javascript SDK for integration of Bitcoin SV Smart Contracts written in sCrypt language.",
55
"engines": {
66
"node": ">=14.0.0"

patches/bsv/index.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,7 @@ declare module 'bsv' {
929929
outputScript?: Script | string,
930930
satoshis?: number
931931
): this;
932+
removeInput(txId: string, outputIndex: number): void;
932933
addOutput(output: Transaction.Output): this;
933934
addData(value: Buffer | string): this;
934935
lockUntilDate(time: Date | number): this;
@@ -958,9 +959,7 @@ declare module 'bsv' {
958959

959960
getSerializationError(opts?: object): any;
960961

961-
_getUnspentValue(): number;
962-
_estimateFee(): number;
963-
_estimateSize: number;
962+
getUnspentValue(): number;
964963
setInputScript(inputIndex: number | {
965964
inputIndex: number,
966965
privateKey?: PrivateKey | Array<PrivateKey>,
@@ -978,6 +977,7 @@ declare module 'bsv' {
978977
sealAsync(): Promise<this>;
979978
isSealed(): boolean;
980979
getChangeAmount(): number;
980+
getEstimateSize(): number;
981981
getEstimateFee(): number;
982982
checkFeeRate(feePerKb?: number): boolean;
983983
prevouts(): string;

patches/bsv/lib/bn.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050

5151
var Buffer
5252
try {
53-
Buffer = require('buffer').Buffer
53+
Buffer = require('buffer/').Buffer
5454
} catch (e) {
5555
}
5656

patches/bsv/lib/transaction/transaction.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ Transaction.prototype.getSerializationError = function (opts) {
202202
return new errors.Transaction.InvalidSatoshis()
203203
}
204204

205-
var unspent = this._getUnspentValue()
205+
var unspent = this.getUnspentValue()
206206
var unspentError
207207
if (unspent < 0) {
208208
if (!opts.disableMoreOutputThanInput) {
@@ -876,7 +876,7 @@ Transaction.prototype._updateChangeOutput = function () {
876876
script: this._changeScript,
877877
satoshis: 0
878878
}))
879-
var available = this._getUnspentValue()
879+
var available = this.getUnspentValue()
880880
var fee = this.getFee()
881881
var changeAmount = available - fee
882882
this._removeOutput(this._changeIndex)
@@ -917,7 +917,7 @@ Transaction.prototype.getFee = function () {
917917
}
918918
// if no change output is set, fees should equal all the unspent amount
919919
if (!this._changeScript) {
920-
return this._getUnspentValue()
920+
return this.getUnspentValue()
921921
}
922922
return this._estimateFee()
923923
}
@@ -930,7 +930,7 @@ Transaction.prototype._estimateFee = function () {
930930
return Math.ceil(estimatedSize / 1000 * (this._feePerKb || Transaction.FEE_PER_KB))
931931
}
932932

933-
Transaction.prototype._getUnspentValue = function () {
933+
Transaction.prototype.getUnspentValue = function () {
934934
return this._getInputAmount() - this._getOutputAmount()
935935
}
936936

@@ -951,6 +951,10 @@ Transaction.prototype._clearSignatures = function () {
951951
// ??? script
952952
//
953953
// 4 locktime
954+
Transaction.prototype.getEstimateSize = function () {
955+
return this._estimateSize()
956+
}
957+
954958
Transaction.prototype._estimateSize = function () {
955959
var result = 4 + 4 // size of version + size of locktime
956960
result += Varint(this.inputs.length).toBuffer().length
@@ -1439,7 +1443,7 @@ Transaction.prototype.getEstimateFee = function () {
14391443
* @returns true or false
14401444
*/
14411445
Transaction.prototype.checkFeeRate = function (feePerKb) {
1442-
var fee = this._getUnspentValue()
1446+
var fee = this.getUnspentValue()
14431447

14441448
var estimatedSize = this._estimateSize()
14451449
var expectedRate = (feePerKb || this._feePerKb || Transaction.FEE_PER_KB) / 1000

0 commit comments

Comments
 (0)