|
|
@ -51,6 +51,19 @@ function WalletService() { |
|
|
|
this.notifyTicker = 0; |
|
|
|
}; |
|
|
|
|
|
|
|
WalletService.SCRIPT_TYPES = { |
|
|
|
P2SH: 'P2SH', |
|
|
|
P2PKH: 'P2PKH', |
|
|
|
}; |
|
|
|
WalletService.DERIVATION_STRATEGIES = { |
|
|
|
BIP44: 'BIP44', |
|
|
|
BIP45: 'BIP45', |
|
|
|
}; |
|
|
|
|
|
|
|
WalletService.DEFAULT_FEE_PER_KB = 10000; |
|
|
|
WalletService.MIN_FEE_PER_KB = 0; |
|
|
|
WalletService.MAX_FEE_PER_KB = 1000000; |
|
|
|
WalletService.MAX_TX_FEE = 1 * 1e8; |
|
|
|
|
|
|
|
WalletService.MAX_KEYS = 100; |
|
|
|
|
|
|
@ -234,8 +247,8 @@ WalletService.prototype.createWallet = function(opts, cb) { |
|
|
|
|
|
|
|
opts.supportBIP44AndP2PKH = _.isBoolean(opts.supportBIP44AndP2PKH) ? opts.supportBIP44AndP2PKH : true; |
|
|
|
|
|
|
|
var derivationStrategy = opts.supportBIP44AndP2PKH ? WalletUtils.DERIVATION_STRATEGIES.BIP44 : WalletUtils.DERIVATION_STRATEGIES.BIP45; |
|
|
|
var addressType = (opts.n == 1 && opts.supportBIP44AndP2PKH) ? WalletUtils.SCRIPT_TYPES.P2PKH : WalletUtils.SCRIPT_TYPES.P2SH; |
|
|
|
var derivationStrategy = opts.supportBIP44AndP2PKH ? WalletService.DERIVATION_STRATEGIES.BIP44 : WalletService.DERIVATION_STRATEGIES.BIP45; |
|
|
|
var addressType = (opts.n == 1 && opts.supportBIP44AndP2PKH) ? WalletService.SCRIPT_TYPES.P2PKH : WalletService.SCRIPT_TYPES.P2SH; |
|
|
|
|
|
|
|
try { |
|
|
|
pubKey = new PublicKey.fromString(opts.pubKey); |
|
|
@ -593,12 +606,12 @@ WalletService.prototype.joinWallet = function(opts, cb) { |
|
|
|
|
|
|
|
if (opts.supportBIP44AndP2PKH) { |
|
|
|
// New client trying to join legacy wallet
|
|
|
|
if (wallet.derivationStrategy == WalletUtils.DERIVATION_STRATEGIES.BIP45) { |
|
|
|
if (wallet.derivationStrategy == WalletService.DERIVATION_STRATEGIES.BIP45) { |
|
|
|
return cb(new ClientError('The wallet you are trying to join was created with an older version of the client app.')); |
|
|
|
} |
|
|
|
} else { |
|
|
|
// Legacy client trying to join new wallet
|
|
|
|
if (wallet.derivationStrategy == WalletUtils.DERIVATION_STRATEGIES.BIP44) { |
|
|
|
if (wallet.derivationStrategy == WalletService.DERIVATION_STRATEGIES.BIP44) { |
|
|
|
return cb(new ClientError(Errors.codes.UPGRADE_NEEDED, 'To join this wallet you need to upgrade your client app.')); |
|
|
|
} |
|
|
|
} |
|
|
@ -1212,8 +1225,8 @@ WalletService.prototype.createTx = function(opts, cb) { |
|
|
|
valid: false |
|
|
|
})) return; |
|
|
|
|
|
|
|
var feePerKb = opts.feePerKb || WalletUtils.DEFAULT_FEE_PER_KB; |
|
|
|
if (feePerKb < WalletUtils.MIN_FEE_PER_KB || feePerKb > WalletUtils.MAX_FEE_PER_KB) |
|
|
|
var feePerKb = opts.feePerKb || WalletService.DEFAULT_FEE_PER_KB; |
|
|
|
if (feePerKb < WalletService.MIN_FEE_PER_KB || feePerKb > WalletService.MAX_FEE_PER_KB) |
|
|
|
return cb(new ClientError('Invalid fee per KB value')); |
|
|
|
|
|
|
|
self._runLocked(cb, function(cb) { |
|
|
|