@@ -468,37 +468,37 @@ 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 this . tx . version = 2
480480}
481481
482482TransactionBuilder . prototype . setLockTime = function ( locktime ) {
483483 typeforce ( types . UInt32 , locktime )
484484
485485 // if any signatures exist, throw
486- if ( this . inputs . some ( function ( input ) {
486+ if ( this . __inputs . some ( function ( input ) {
487487 if ( ! input . signatures ) return false
488488
489489 return input . signatures . some ( function ( s ) { return s } )
490490 } ) ) {
491491 throw new Error ( 'No, this would invalidate signatures' )
492492 }
493493
494- this . tx . locktime = locktime
494+ this . __tx . locktime = locktime
495495}
496496
497497TransactionBuilder . prototype . setVersion = function ( version ) {
498498 typeforce ( types . UInt32 , version )
499499
500500 // XXX: this might eventually become more complex depending on what the versions represent
501- this . tx . version = version
501+ this . __tx . version = version
502502}
503503
504504TransactionBuilder . fromTransaction = function ( transaction , network ) {
@@ -523,7 +523,7 @@ TransactionBuilder.fromTransaction = function (transaction, network) {
523523 } )
524524
525525 // fix some things not possible through the public API
526- txb . inputs . forEach ( function ( input , i ) {
526+ txb . __inputs . forEach ( function ( input , i ) {
527527 fixMultisigOrder ( input , transaction , i )
528528 } )
529529
@@ -564,7 +564,7 @@ TransactionBuilder.prototype.__addInputUnsafe = function (txHash, vout, options)
564564 }
565565
566566 var prevTxOut = txHash . toString ( 'hex' ) + ':' + vout
567- if ( this . prevTxMap [ prevTxOut ] !== undefined ) throw new Error ( 'Duplicate TxOut: ' + prevTxOut )
567+ if ( this . __prevTxSet [ prevTxOut ] !== undefined ) throw new Error ( 'Duplicate TxOut: ' + prevTxOut )
568568
569569 var input = { }
570570
@@ -597,9 +597,9 @@ TransactionBuilder.prototype.__addInputUnsafe = function (txHash, vout, options)
597597 input . prevOutType = prevOutType || btemplates . classifyOutput ( options . prevOutScript )
598598 }
599599
600- var vin = this . tx . addInput ( txHash , vout , options . sequence , options . scriptSig )
601- this . inputs [ vin ] = input
602- this . prevTxMap [ prevTxOut ] = vin
600+ var vin = this . __tx . addInput ( txHash , vout , options . sequence , options . scriptSig )
601+ this . __inputs [ vin ] = input
602+ this . __prevTxSet [ prevTxOut ] = true
603603 return vin
604604}
605605
@@ -613,7 +613,7 @@ TransactionBuilder.prototype.addOutput = function (scriptPubKey, value) {
613613 scriptPubKey = baddress . toOutputScript ( scriptPubKey , this . network )
614614 }
615615
616- return this . tx . addOutput ( scriptPubKey , value )
616+ return this . __tx . addOutput ( scriptPubKey , value )
617617}
618618
619619TransactionBuilder . prototype . build = function ( ) {
@@ -625,13 +625,13 @@ TransactionBuilder.prototype.buildIncomplete = function () {
625625
626626TransactionBuilder . prototype . __build = function ( allowIncomplete ) {
627627 if ( ! allowIncomplete ) {
628- if ( ! this . tx . ins . length ) throw new Error ( 'Transaction has no inputs' )
629- if ( ! this . tx . outs . length ) throw new Error ( 'Transaction has no outputs' )
628+ if ( ! this . __tx . ins . length ) throw new Error ( 'Transaction has no inputs' )
629+ if ( ! this . __tx . outs . length ) throw new Error ( 'Transaction has no outputs' )
630630 }
631631
632- var tx = this . tx . clone ( )
632+ var tx = this . __tx . clone ( )
633633 // Create script signatures from inputs
634- this . inputs . forEach ( function ( input , i ) {
634+ this . __inputs . forEach ( function ( input , i ) {
635635 var scriptType = input . witnessScriptType || input . redeemScriptType || input . prevOutType
636636 if ( ! scriptType && ! allowIncomplete ) throw new Error ( 'Transaction is not complete' )
637637 var result = buildInput ( input , allowIncomplete )
@@ -673,10 +673,10 @@ function canSign (input) {
673673TransactionBuilder . prototype . sign = function ( vin , keyPair , redeemScript , hashType , witnessValue , witnessScript ) {
674674 // TODO: remove keyPair.network matching in 4.0.0
675675 if ( keyPair . network && keyPair . network !== this . network ) throw new TypeError ( 'Inconsistent network' )
676- if ( ! this . inputs [ vin ] ) throw new Error ( 'No input at index: ' + vin )
676+ if ( ! this . __inputs [ vin ] ) throw new Error ( 'No input at index: ' + vin )
677677 hashType = hashType || Transaction . SIGHASH_ALL
678678
679- var input = this . inputs [ vin ]
679+ var input = this . __inputs [ vin ]
680680
681681 // if redeemScript was previously provided, enforce consistency
682682 if ( input . redeemScript !== undefined &&
@@ -700,9 +700,9 @@ TransactionBuilder.prototype.sign = function (vin, keyPair, redeemScript, hashTy
700700 // ready to sign
701701 var signatureHash
702702 if ( input . witness ) {
703- signatureHash = this . tx . hashForWitnessV0 ( vin , input . signScript , input . value , hashType )
703+ signatureHash = this . __tx . hashForWitnessV0 ( vin , input . signScript , input . value , hashType )
704704 } else {
705- signatureHash = this . tx . hashForSignature ( vin , input . signScript , hashType )
705+ signatureHash = this . __tx . hashForSignature ( vin , input . signScript , hashType )
706706 }
707707
708708 // enforce in order signing of public keys
@@ -731,7 +731,7 @@ function signatureHashType (buffer) {
731731}
732732
733733TransactionBuilder . prototype . __canModifyInputs = function ( ) {
734- return this . inputs . every ( function ( input ) {
734+ return this . __inputs . every ( function ( input ) {
735735 // any signatures?
736736 if ( input . signatures === undefined ) return true
737737
@@ -747,10 +747,10 @@ TransactionBuilder.prototype.__canModifyInputs = function () {
747747}
748748
749749TransactionBuilder . prototype . __canModifyOutputs = function ( ) {
750- var nInputs = this . tx . ins . length
751- var nOutputs = this . tx . outs . length
750+ var nInputs = this . __tx . ins . length
751+ var nOutputs = this . __tx . outs . length
752752
753- return this . inputs . every ( function ( input ) {
753+ return this . __inputs . every ( function ( input ) {
754754 if ( input . signatures === undefined ) return true
755755
756756 return input . signatures . every ( function ( signature ) {
@@ -771,11 +771,11 @@ TransactionBuilder.prototype.__canModifyOutputs = function () {
771771
772772TransactionBuilder . prototype . __overMaximumFees = function ( bytes ) {
773773 // not all inputs will have .value defined
774- var incoming = this . inputs . reduce ( function ( a , x ) { return a + ( x . value >>> 0 ) } , 0 )
774+ var incoming = this . __inputs . reduce ( function ( a , x ) { return a + ( x . value >>> 0 ) } , 0 )
775775
776776 // but all outputs do, and if we have any input value
777777 // we can immediately determine if the outputs are too small
778- var outgoing = this . tx . outs . reduce ( function ( a , x ) { return a + x . value } , 0 )
778+ var outgoing = this . __tx . outs . reduce ( function ( a , x ) { return a + x . value } , 0 )
779779 var fee = incoming - outgoing
780780 var feeRate = fee / bytes
781781
0 commit comments