From c96bb93841db151c1fb6d44b03c3bb5235fba7bc Mon Sep 17 00:00:00 2001 From: Karel Bilek Date: Tue, 20 Jun 2017 13:46:46 +0200 Subject: [PATCH] Add weight / vsize Weight / virtual size according to BIP141 --- src/transaction.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/transaction.js b/src/transaction.js index 41e00d9..86cccea 100644 --- a/src/transaction.js +++ b/src/transaction.js @@ -191,6 +191,16 @@ Transaction.prototype.hasWitnesses = function () { }) } +Transaction.prototype.weight = function () { + var base = this.__byteLength(false) + var total = this.__byteLength(true) + return base * 3 + total +} + +Transaction.prototype.virtualSize = function () { + return Math.ceil(this.weight() / 4) +} + Transaction.prototype.byteLength = function () { return this.__byteLength(true) }