|
@ -169,6 +169,25 @@ TxProposal.prototype.getRawTx = function() { |
|
|
return t.uncheckedSerialize(); |
|
|
return t.uncheckedSerialize(); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
TxProposal.prototype.estimateFee = function(walletN) { |
|
|
|
|
|
// Note: found empirically based on all multisig P2SH inputs and within m & n allowed limits.
|
|
|
|
|
|
var safetyMargin = 0.05; |
|
|
|
|
|
|
|
|
|
|
|
var walletM = this.requiredSignatures; |
|
|
|
|
|
|
|
|
|
|
|
var overhead = 4 + 4 + 9 + 9; |
|
|
|
|
|
var inputSize = walletM * 72 + walletN * 36 + 44; |
|
|
|
|
|
var outputSize = 34; |
|
|
|
|
|
var nbInputs = this.inputs.length; |
|
|
|
|
|
var nbOutputs = (_.isArray(this.outputs) ? this.outputs.length : 1) + 1; |
|
|
|
|
|
|
|
|
|
|
|
var size = overhead + inputSize * nbInputs + outputSize * nbOutputs; |
|
|
|
|
|
|
|
|
|
|
|
var fee = this.feePerKb * (size * (1 + safetyMargin)) / 1000; |
|
|
|
|
|
|
|
|
|
|
|
// Round up to nearest bit
|
|
|
|
|
|
this.fee = parseInt((Math.ceil(fee / 100) * 100).toFixed(0)); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* getTotalAmount |
|
|
* getTotalAmount |
|
|