|
@ -4116,205 +4116,6 @@ describe('Wallet service', function() { |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
describe('#replaceTemporaryRequestKey', function() { |
|
|
|
|
|
var server, walletId; |
|
|
|
|
|
beforeEach(function(done) { |
|
|
|
|
|
server = new WalletService(); |
|
|
|
|
|
var walletOpts = { |
|
|
|
|
|
name: 'my wallet', |
|
|
|
|
|
m: 2, |
|
|
|
|
|
n: 2, |
|
|
|
|
|
pubKey: TestData.keyPair.pub, |
|
|
|
|
|
}; |
|
|
|
|
|
server.createWallet(walletOpts, function(err, wId) { |
|
|
|
|
|
should.not.exist(err); |
|
|
|
|
|
should.exist.walletId; |
|
|
|
|
|
walletId = wId; |
|
|
|
|
|
done(); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should join existing wallet with temporaryRequestKey', function(done) { |
|
|
|
|
|
var copayerOpts = helpers.getSignedCopayerOpts({ |
|
|
|
|
|
walletId: walletId, |
|
|
|
|
|
name: 'me', |
|
|
|
|
|
xPubKey: TestData.copayers[0].xPubKey_45H, |
|
|
|
|
|
requestPubKey: TestData.copayers[0].pubKey_1H_0, |
|
|
|
|
|
}); |
|
|
|
|
|
copayerOpts.isTemporaryRequestKey = true; |
|
|
|
|
|
|
|
|
|
|
|
server.joinWallet(copayerOpts, function(err, result) { |
|
|
|
|
|
should.not.exist(err); |
|
|
|
|
|
var copayerId = result.copayerId; |
|
|
|
|
|
helpers.getAuthServer(copayerId, function(server) { |
|
|
|
|
|
server.getWallet({}, function(err, wallet) { |
|
|
|
|
|
wallet.id.should.equal(walletId); |
|
|
|
|
|
var copayer = wallet.copayers[0]; |
|
|
|
|
|
copayer.isTemporaryRequestKey.should.equal(true); |
|
|
|
|
|
done(); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should fail to replace a temporaryRequestKey on a not-complete wallet', function(done) { |
|
|
|
|
|
var copayerOpts = helpers.getSignedCopayerOpts({ |
|
|
|
|
|
walletId: walletId, |
|
|
|
|
|
name: 'me', |
|
|
|
|
|
xPubKey: TestData.copayers[0].xPubKey_45H, |
|
|
|
|
|
requestPubKey: TestData.copayers[0].pubKey_1_0, |
|
|
|
|
|
}); |
|
|
|
|
|
copayerOpts.isTemporaryRequestKey = true; |
|
|
|
|
|
|
|
|
|
|
|
server.joinWallet(copayerOpts, function(err, result) { |
|
|
|
|
|
should.not.exist(err); |
|
|
|
|
|
var copayerId = result.copayerId; |
|
|
|
|
|
helpers.getAuthServer(copayerId, function(server) { |
|
|
|
|
|
server.getWallet({}, function(err, wallet) { |
|
|
|
|
|
|
|
|
|
|
|
var copayerOpts = helpers.getSignedCopayerOpts({ |
|
|
|
|
|
walletId: walletId, |
|
|
|
|
|
name: 'me', |
|
|
|
|
|
xPubKey: TestData.copayers[0].xPubKey_45H, |
|
|
|
|
|
requestPubKey: TestData.copayers[0].pubKey_1H_0, |
|
|
|
|
|
}); |
|
|
|
|
|
copayerOpts.isTemporaryRequestKey = false; |
|
|
|
|
|
server.replaceTemporaryRequestKey(copayerOpts, function(err, wallet) { |
|
|
|
|
|
err.code.should.equal('WALLET_NOT_COMPLETE'); |
|
|
|
|
|
done(); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('should fail to replace a temporaryRequestKey is Copayer is not in wallet', function(done) { |
|
|
|
|
|
var copayerOpts = helpers.getSignedCopayerOpts({ |
|
|
|
|
|
walletId: walletId, |
|
|
|
|
|
name: 'me', |
|
|
|
|
|
xPubKey: TestData.copayers[0].xPubKey_45H, |
|
|
|
|
|
requestPubKey: TestData.copayers[0].pubKey_1_0, |
|
|
|
|
|
}); |
|
|
|
|
|
copayerOpts.isTemporaryRequestKey = true; |
|
|
|
|
|
|
|
|
|
|
|
server.joinWallet(copayerOpts, function(err, result) { |
|
|
|
|
|
should.not.exist(err); |
|
|
|
|
|
var copayerId = result.copayerId; |
|
|
|
|
|
helpers.getAuthServer(copayerId, function(server) { |
|
|
|
|
|
server.getWallet({}, function(err, wallet) { |
|
|
|
|
|
|
|
|
|
|
|
var copayerOpts = helpers.getSignedCopayerOpts({ |
|
|
|
|
|
walletId: walletId, |
|
|
|
|
|
name: 'me', |
|
|
|
|
|
xPubKey: TestData.copayers[1].xPubKey_45H, |
|
|
|
|
|
requestPubKey: TestData.copayers[1].pubKey_1H_0, |
|
|
|
|
|
}); |
|
|
|
|
|
copayerOpts.isTemporaryRequestKey = false; |
|
|
|
|
|
server.replaceTemporaryRequestKey(copayerOpts, function(err, wallet) { |
|
|
|
|
|
err.code.should.equal('COPAYER_DATA_MISMATCH'); |
|
|
|
|
|
done(); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should fail replace a temporaryRequestKey with invalid copayer', function(done) { |
|
|
|
|
|
var copayerOpts = helpers.getSignedCopayerOpts({ |
|
|
|
|
|
walletId: walletId, |
|
|
|
|
|
name: 'me', |
|
|
|
|
|
xPubKey: TestData.copayers[0].xPubKey_45H, |
|
|
|
|
|
requestPubKey: TestData.copayers[0].pubKey_1_0, |
|
|
|
|
|
}); |
|
|
|
|
|
copayerOpts.isTemporaryRequestKey = true; |
|
|
|
|
|
|
|
|
|
|
|
server.joinWallet(copayerOpts, function(err, result) { |
|
|
|
|
|
should.not.exist(err); |
|
|
|
|
|
|
|
|
|
|
|
var copayerOpts2 = helpers.getSignedCopayerOpts({ |
|
|
|
|
|
walletId: walletId, |
|
|
|
|
|
name: 'me', |
|
|
|
|
|
xPubKey: TestData.copayers[1].xPubKey_45H, |
|
|
|
|
|
requestPubKey: TestData.copayers[1].pubKey_1H_0, |
|
|
|
|
|
}); |
|
|
|
|
|
copayerOpts2.isTemporaryRequestKey = false; |
|
|
|
|
|
|
|
|
|
|
|
server.joinWallet(copayerOpts2, function(err, result) { |
|
|
|
|
|
should.not.exist(err); |
|
|
|
|
|
|
|
|
|
|
|
var copayerId = result.copayerId; |
|
|
|
|
|
helpers.getAuthServer(copayerId, function(server) { |
|
|
|
|
|
server.getWallet({}, function(err, wallet) { |
|
|
|
|
|
|
|
|
|
|
|
var copayerOpts = helpers.getSignedCopayerOpts({ |
|
|
|
|
|
walletId: walletId, |
|
|
|
|
|
name: 'me', |
|
|
|
|
|
xPubKey: TestData.copayers[1].xPubKey_45H, |
|
|
|
|
|
requestPubKey: TestData.copayers[1].pubKey_1H_0, |
|
|
|
|
|
}); |
|
|
|
|
|
copayerOpts.isTemporaryRequestKey = false; |
|
|
|
|
|
server.replaceTemporaryRequestKey(copayerOpts, function(err, wallet) { |
|
|
|
|
|
err.code.should.equal('COPAYER_DATA_MISMATCH'); |
|
|
|
|
|
done(); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should replace a temporaryRequestKey', function(done) { |
|
|
|
|
|
var copayerOpts = helpers.getSignedCopayerOpts({ |
|
|
|
|
|
walletId: walletId, |
|
|
|
|
|
name: 'me', |
|
|
|
|
|
xPubKey: TestData.copayers[0].xPubKey_45H, |
|
|
|
|
|
requestPubKey: TestData.copayers[0].pubKey_1_0, |
|
|
|
|
|
}); |
|
|
|
|
|
copayerOpts.isTemporaryRequestKey = true; |
|
|
|
|
|
|
|
|
|
|
|
server.joinWallet(copayerOpts, function(err, result) { |
|
|
|
|
|
should.not.exist(err); |
|
|
|
|
|
var copayerId = result.copayerId; |
|
|
|
|
|
|
|
|
|
|
|
var copayerOpts2 = helpers.getSignedCopayerOpts({ |
|
|
|
|
|
walletId: walletId, |
|
|
|
|
|
name: 'me', |
|
|
|
|
|
xPubKey: TestData.copayers[1].xPubKey_45H, |
|
|
|
|
|
requestPubKey: TestData.copayers[1].pubKey_1H_0, |
|
|
|
|
|
}); |
|
|
|
|
|
copayerOpts2.isTemporaryRequestKey = false; |
|
|
|
|
|
|
|
|
|
|
|
server.joinWallet(copayerOpts2, function(err, result) { |
|
|
|
|
|
should.not.exist(err); |
|
|
|
|
|
var copayerId2 = result.copayerId; |
|
|
|
|
|
|
|
|
|
|
|
helpers.getAuthServer(copayerId, function(server) { |
|
|
|
|
|
server.getWallet({}, function(err, wallet) { |
|
|
|
|
|
|
|
|
|
|
|
var copayerOpts = helpers.getSignedCopayerOpts({ |
|
|
|
|
|
walletId: walletId, |
|
|
|
|
|
name: 'me', |
|
|
|
|
|
xPubKey: TestData.copayers[0].xPubKey_45H, |
|
|
|
|
|
requestPubKey: TestData.copayers[0].pubKey_1H_0, |
|
|
|
|
|
}); |
|
|
|
|
|
copayerOpts.isTemporaryRequestKey = false; |
|
|
|
|
|
server.replaceTemporaryRequestKey(copayerOpts, function(err, wallet) { |
|
|
|
|
|
should.not.exist(err); |
|
|
|
|
|
server.getWallet({}, function(err, wallet) { |
|
|
|
|
|
wallet.copayers[0].isTemporaryRequestKey.should.equal(false); |
|
|
|
|
|
wallet.copayers[1].isTemporaryRequestKey.should.equal(false); |
|
|
|
|
|
done(); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
describe('Legacy', function() { |
|
|
describe('Legacy', function() { |
|
|
describe('Fees', function() { |
|
|
describe('Fees', function() { |
|
|
var server, wallet; |
|
|
var server, wallet; |
|
|