Fix class constructors

This commit is contained in:
junderw 2019-03-20 15:25:48 +09:00
parent fabd1d6c9d
commit 74375bfedf
No known key found for this signature in database
GPG key ID: B256185D3A971908
11 changed files with 101 additions and 125 deletions

View file

@ -20,6 +20,16 @@ function txIsTransaction(tx) {
return tx instanceof transaction_1.Transaction;
}
class TransactionBuilder {
// WARNING: maximumFeeRate is __NOT__ to be relied on,
// it's just another potential safety mechanism (safety in-depth)
constructor(network = networks.bitcoin, maximumFeeRate = 2500) {
this.network = network;
this.maximumFeeRate = maximumFeeRate;
this.__PREV_TX_SET = {};
this.__INPUTS = [];
this.__TX = new transaction_1.Transaction();
this.__TX.version = 2;
}
static fromTransaction(transaction, network) {
const txb = new TransactionBuilder(network);
// Copy transaction fields
@ -43,15 +53,6 @@ class TransactionBuilder {
});
return txb;
}
constructor(network, maximumFeeRate) {
this.__PREV_TX_SET = {};
this.network = network || networks.bitcoin;
// WARNING: This is __NOT__ to be relied on, its just another potential safety mechanism (safety in-depth)
this.maximumFeeRate = maximumFeeRate || 2500;
this.__INPUTS = [];
this.__TX = new transaction_1.Transaction();
this.__TX.version = 2;
}
setLockTime(locktime) {
typeforce(types.UInt32, locktime);
// if any signatures exist, throw