@@ -468,36 +468,36 @@ function buildInput (input, allowIncomplete) {
468468}
469469
470470function TransactionBuilder ( network , maximumFeeRate ) {
471- this . prevTxMap = { }
471+ this . __prevTxSet = { }
472472 this . network = network || networks . bitcoin
473473
474474 // WARNING: This is __NOT__ to be relied on, its just another potential safety mechanism (safety in-depth)
475475 this . maximumFeeRate = maximumFeeRate || 2500
476476
477- this . inputs = [ ]
478- this . tx = new Transaction ( )
477+ this . __inputs = [ ]
478+ this . __tx = new Transaction ( )
479479}
480480
481481TransactionBuilder . prototype . setLockTime = function ( locktime ) {
482482 typeforce ( types . UInt32 , locktime )
483483
484484 // if any signatures exist, throw
485- if ( this . inputs . some ( function ( input ) {
485+ if ( this . __inputs . some ( function ( input ) {
486486 if ( ! input . signatures ) return false
487487
488488 return input . signatures . some ( function ( s ) { return s } )
489489 } ) ) {
490490 throw new Error ( 'No, this would invalidate signatures' )
491491 }
492492
493- this . tx . locktime = locktime
493+ this . __tx . locktime = locktime
494494}
495495
496496TransactionBuilder . prototype . setVersion = function ( version ) {
497497 typeforce ( types . UInt32 , version )
498498
499499 // XXX: this might eventually become more complex depending on what the versions represent
500- this . tx . version = version
500+ this . __tx . version = version
501501}
502502
503503TransactionBuilder . fromTransaction = function ( transaction , network ) {
@@ -522,7 +522,7 @@ TransactionBuilder.fromTransaction = function (transaction, network) {
522522 } )
523523
524524 // fix some things not possible through the public API
525- txb . inputs . forEach ( function ( input , i ) {
525+ txb . __inputs . forEach ( function ( input , i ) {
526526 fixMultisigOrder ( input , transaction , i )
527527 } )
528528
@@ -563,7 +563,7 @@ TransactionBuilder.prototype.__addInputUnsafe = function (txHash, vout, options)
563563 }
564564
565565 var prevTxOut = txHash . toString ( 'hex' ) + ':' + vout
566- if ( this . prevTxMap [ prevTxOut ] !== undefined ) throw new Error ( 'Duplicate TxOut: ' + prevTxOut )
566+ if ( this . __prevTxSet [ prevTxOut ] !== undefined ) throw new Error ( 'Duplicate TxOut: ' + prevTxOut )
567567
568568 var input = { }
569569
@@ -596,9 +596,9 @@ TransactionBuilder.prototype.__addInputUnsafe = function (txHash, vout, options)
596596 input . prevOutType = prevOutType || btemplates . classifyOutput ( options . prevOutScript )
597597 }
598598
599- var vin = this . tx . addInput ( txHash , vout , options . sequence , options . scriptSig )
600- this . inputs [ vin ] = input
601- this . prevTxMap [ prevTxOut ] = vin
599+ var vin = this . __tx . addInput ( txHash , vout , options . sequence , options . scriptSig )
600+ this . __inputs [ vin ] = input
601+ this . __prevTxSet [ prevTxOut ] = true
602602 return vin
603603}
604604
@@ -612,7 +612,7 @@ TransactionBuilder.prototype.addOutput = function (scriptPubKey, value) {
612612 scriptPubKey = baddress . toOutputScript ( scriptPubKey , this . network )
613613 }
614614
615- return this . tx . addOutput ( scriptPubKey , value )
615+ return this . __tx . addOutput ( scriptPubKey , value )
616616}
617617
618618TransactionBuilder . prototype . build = function ( ) {
@@ -624,13 +624,13 @@ TransactionBuilder.prototype.buildIncomplete = function () {
624624
625625TransactionBuilder . prototype . __build = function ( allowIncomplete ) {
626626 if ( ! allowIncomplete ) {
627- if ( ! this . tx . ins . length ) throw new Error ( 'Transaction has no inputs' )
628- if ( ! this . tx . outs . length ) throw new Error ( 'Transaction has no outputs' )
627+ if ( ! this . __tx . ins . length ) throw new Error ( 'Transaction has no inputs' )
628+ if ( ! this . __tx . outs . length ) throw new Error ( 'Transaction has no outputs' )
629629 }
630630
631- var tx = this . tx . clone ( )
631+ var tx = this . __tx . clone ( )
632632 // Create script signatures from inputs
633- this . inputs . forEach ( function ( input , i ) {
633+ this . __inputs . forEach ( function ( input , i ) {
634634 var scriptType = input . witnessScriptType || input . redeemScriptType || input . prevOutType
635635 if ( ! scriptType && ! allowIncomplete ) throw new Error ( 'Transaction is not complete' )
636636 var result = buildInput ( input , allowIncomplete )
@@ -672,10 +672,10 @@ function canSign (input) {
672672TransactionBuilder . prototype . sign = function ( vin , keyPair , redeemScript , hashType , witnessValue , witnessScript ) {
673673 // TODO: remove keyPair.network matching in 4.0.0
674674 if ( keyPair . network && keyPair . network !== this . network ) throw new TypeError ( 'Inconsistent network' )
675- if ( ! this . inputs [ vin ] ) throw new Error ( 'No input at index: ' + vin )
675+ if ( ! this . __inputs [ vin ] ) throw new Error ( 'No input at index: ' + vin )
676676 hashType = hashType || Transaction . SIGHASH_ALL
677677
678- var input = this . inputs [ vin ]
678+ var input = this . __inputs [ vin ]
679679
680680 // if redeemScript was previously provided, enforce consistency
681681 if ( input . redeemScript !== undefined &&
@@ -699,9 +699,9 @@ TransactionBuilder.prototype.sign = function (vin, keyPair, redeemScript, hashTy
699699 // ready to sign
700700 var signatureHash
701701 if ( input . witness ) {
702- signatureHash = this . tx . hashForWitnessV0 ( vin , input . signScript , input . value , hashType )
702+ signatureHash = this . __tx . hashForWitnessV0 ( vin , input . signScript , input . value , hashType )
703703 } else {
704- signatureHash = this . tx . hashForSignature ( vin , input . signScript , hashType )
704+ signatureHash = this . __tx . hashForSignature ( vin , input . signScript , hashType )
705705 }
706706
707707 // enforce in order signing of public keys
@@ -730,7 +730,7 @@ function signatureHashType (buffer) {
730730}
731731
732732TransactionBuilder . prototype . __canModifyInputs = function ( ) {
733- return this . inputs . every ( function ( input ) {
733+ return this . __inputs . every ( function ( input ) {
734734 // any signatures?
735735 if ( input . signatures === undefined ) return true
736736
@@ -746,10 +746,10 @@ TransactionBuilder.prototype.__canModifyInputs = function () {
746746}
747747
748748TransactionBuilder . prototype . __canModifyOutputs = function ( ) {
749- var nInputs = this . tx . ins . length
750- var nOutputs = this . tx . outs . length
749+ var nInputs = this . __tx . ins . length
750+ var nOutputs = this . __tx . outs . length
751751
752- return this . inputs . every ( function ( input ) {
752+ return this . __inputs . every ( function ( input ) {
753753 if ( input . signatures === undefined ) return true
754754
755755 return input . signatures . every ( function ( signature ) {
@@ -770,11 +770,11 @@ TransactionBuilder.prototype.__canModifyOutputs = function () {
770770
771771TransactionBuilder . prototype . __overMaximumFees = function ( bytes ) {
772772 // not all inputs will have .value defined
773- var incoming = this . inputs . reduce ( function ( a , x ) { return a + ( x . value >>> 0 ) } , 0 )
773+ var incoming = this . __inputs . reduce ( function ( a , x ) { return a + ( x . value >>> 0 ) } , 0 )
774774
775775 // but all outputs do, and if we have any input value
776776 // we can immediately determine if the outputs are too small
777- var outgoing = this . tx . outs . reduce ( function ( a , x ) { return a + x . value } , 0 )
777+ var outgoing = this . __tx . outs . reduce ( function ( a , x ) { return a + x . value } , 0 )
778778 var fee = incoming - outgoing
779779 var feeRate = fee / bytes
780780
0 commit comments