Code Duplication    Length = 20-20 lines in 2 locations

test/size_estimation.test.js 2 locations

@@ 127-146 (lines=20) @@
124
125
    return bitcoin.script.multisig.output.encode(m, keys);
126
}
127
function multisigScriptSizes(m, script) {
128
    var bareSize = 1/*op0*/ + m * (1 + SizeEstimation.SIZE_DER_SIGNATURE);
129
    var bareSig = 1 + bareSize;
130
    var p2shSig = bareSize + SizeEstimation.getLengthForScriptPush(script.length) + script.length;
131
132
    var p2wshHash = bitcoin.crypto.sha256(script);
133
    var p2wshScript = bitcoin.script.witnessScriptHash.output.encode(p2wshHash);
134
135
    var nestedSig = 1 + 1 + p2wshScript.length;
136
    var witSize = 1 + m * (1 + SizeEstimation.SIZE_DER_SIGNATURE);
137
    var nestedWit = witSize + 1 + 1 + script.length;
138
139
    return {
140
        bareSig: bareSig,
141
        p2shSig: SizeEstimation.getLengthForVarInt(p2shSig) + p2shSig,
142
        p2wshScript: p2wshScript,
143
        nestedSig: nestedSig,
144
        nestedWit: nestedWit
145
    }
146
}
147
148
function scriptUtxos(script) {
149
    var hash160 = bitcoin.crypto.hash160(script);
@@ 83-102 (lines=20) @@
80
    return bitcoin.script.pubKey.output.encode(keyu);
81
}
82
83
function p2pkhScriptSizes(script, compressed) {
84
    var bareSize = (1 + SizeEstimation.SIZE_DER_SIGNATURE) + (1 + (compressed ? 33 : 65));
85
    var bareSig = 1 + bareSize;
86
    var p2shSig = 1 + bareSize + 1 + script.length;
87
88
    var p2wshHash = bitcoin.crypto.sha256(script);
89
    var p2wshScript = bitcoin.script.witnessScriptHash.output.encode(p2wshHash);
90
91
    var nestedSig = 1 + 1 + p2wshScript.length;
92
    var witSize = (1 + SizeEstimation.SIZE_DER_SIGNATURE) + (1 + (compressed ? 33 : 65));
93
    var nestedWit = witSize + 1 + 1 + script.length;
94
95
    return {
96
        bareSig: bareSig,
97
        p2shSig: p2shSig,
98
        p2wshScript: p2wshScript,
99
        nestedSig: nestedSig,
100
        nestedWit: nestedWit
101
    }
102
}
103
function p2pkhFormFixture(wif, network) {
104
    var keyHash = p2pkhMakeScript(wif, network);
105
    var compressed = bitcoin.ECPair.fromWIF(wif, network).compressed;