@@ -4866,237 +4866,6 @@ describe('client API', function() {
48664866 } ) ;
48674867 } ) ;
48684868
4869- describe ( 'Legacy Copay Import' , function ( ) {
4870- var db2 ;
4871- before ( ( done ) => {
4872- helpers . newDb ( 2 , ( err , in_db ) => {
4873- db2 = in_db ;
4874- return done ( err ) ;
4875- } ) ;
4876- } ) ;
4877-
4878- it ( 'Should get wallets from profile' , function ( done ) {
4879- var t = ImportData . copayers [ 0 ] ;
4880- var c = helpers . newClient ( app ) ;
4881- var ids = c . getWalletIdsFromOldCopay ( t . username , t . password , t . ls [ 'profile::4872dd8b2ceaa54f922e8e6ba6a8eaa77b488721' ] ) ;
4882- ids . should . deep . equal ( [
4883- '8f197244e661f4d0' ,
4884- '4d32f0737a05f072' ,
4885- 'e2c2d72024979ded' ,
4886- '7065a73486c8cb5d'
4887- ] ) ;
4888- done ( ) ;
4889- } ) ;
4890- it ( 'Should import a 1-1 wallet' , function ( done ) {
4891- var t = ImportData . copayers [ 0 ] ;
4892- var c = helpers . newClient ( app ) ;
4893- c . createWalletFromOldCopay ( t . username , t . password , t . ls [ 'wallet::e2c2d72024979ded' ] , function ( err ) {
4894- should . not . exist ( err ) ;
4895- c . credentials . m . should . equal ( 1 ) ;
4896- c . credentials . n . should . equal ( 1 ) ;
4897-
4898- c . createAddress ( function ( err , x0 ) {
4899- should . not . exist ( err ) ;
4900- // This is the first 'shared' address, created automatically
4901- // by old copay
4902- x0 . address . should . equal ( '2N3w8sJUyAXCQirqNsTayWr7pWADFNdncmf' ) ;
4903- c . getStatus ( { } , function ( err , status ) {
4904- should . not . exist ( err ) ;
4905- status . wallet . name . should . equal ( '1-1' ) ;
4906- status . wallet . status . should . equal ( 'complete' ) ;
4907- c . credentials . walletId . should . equal ( 'e2c2d72024979ded' ) ;
4908- c . credentials . walletPrivKey . should . equal ( 'c3463113c6e1d0fc2f2bd520f7d9d62f8e1fdcdd96005254571c64902aeb1648' ) ;
4909- c . credentials . sharedEncryptingKey . should . equal ( 'x3D/7QHa4PkKMbSXEvXwaw==' ) ;
4910- status . wallet . copayers . length . should . equal ( 1 ) ;
4911- status . wallet . copayers [ 0 ] . name . should . equal ( '123' ) ;
4912- done ( ) ;
4913- } ) ;
4914- } ) ;
4915- } ) ;
4916- } ) ;
4917-
4918- it ( 'Should to import the same wallet twice with different clients' , function ( done ) {
4919- var t = ImportData . copayers [ 0 ] ;
4920- var c = helpers . newClient ( app ) ;
4921- c . createWalletFromOldCopay ( t . username , t . password , t . ls [ 'wallet::4d32f0737a05f072' ] , function ( err ) {
4922- should . not . exist ( err ) ;
4923- c . getStatus ( { } , function ( err , status ) {
4924- should . not . exist ( err ) ;
4925- status . wallet . status . should . equal ( 'complete' ) ;
4926- c . credentials . walletId . should . equal ( '4d32f0737a05f072' ) ;
4927- var c2 = helpers . newClient ( app ) ;
4928- c2 . createWalletFromOldCopay ( t . username , t . password , t . ls [ 'wallet::4d32f0737a05f072' ] , function ( err ) {
4929- should . not . exist ( err ) ;
4930- c2 . getStatus ( { } , function ( err , status ) {
4931- should . not . exist ( err ) ;
4932- status . wallet . status . should . equal ( 'complete' ) ;
4933- c2 . credentials . walletId . should . equal ( '4d32f0737a05f072' ) ;
4934- done ( ) ;
4935- } ) ;
4936- } ) ;
4937- } ) ;
4938- } ) ;
4939- } ) ;
4940-
4941- it ( 'Should not fail when importing the same wallet twice, same copayer' , function ( done ) {
4942- var t = ImportData . copayers [ 0 ] ;
4943- var c = helpers . newClient ( app ) ;
4944- c . createWalletFromOldCopay ( t . username , t . password , t . ls [ 'wallet::4d32f0737a05f072' ] , function ( err ) {
4945- should . not . exist ( err ) ;
4946- c . getStatus ( { } , function ( err , status ) {
4947- should . not . exist ( err ) ;
4948- status . wallet . status . should . equal ( 'complete' ) ;
4949- c . credentials . walletId . should . equal ( '4d32f0737a05f072' ) ;
4950- c . createWalletFromOldCopay ( t . username , t . password , t . ls [ 'wallet::4d32f0737a05f072' ] , function ( err ) {
4951- should . not . exist ( err ) ;
4952- done ( ) ;
4953- } ) ;
4954- } ) ;
4955- } ) ;
4956- } ) ;
4957-
4958- it ( 'Should import and complete 2-2 wallet from 2 copayers, and create addresses' , function ( done ) {
4959- var t = ImportData . copayers [ 0 ] ;
4960- var c = helpers . newClient ( app ) ;
4961- c . createWalletFromOldCopay ( t . username , t . password , t . ls [ 'wallet::4d32f0737a05f072' ] , function ( err ) {
4962- should . not . exist ( err ) ;
4963- c . getStatus ( { } , function ( err , status ) {
4964- should . not . exist ( err ) ;
4965- status . wallet . status . should . equal ( 'complete' ) ;
4966- c . credentials . sharedEncryptingKey . should . equal ( 'Ou2j4kq3z1w4yTr9YybVxg==' ) ;
4967-
4968- var t2 = ImportData . copayers [ 1 ] ;
4969- var c2 = helpers . newClient ( app ) ;
4970- c2 . createWalletFromOldCopay ( t2 . username , t2 . password , t2 . ls [ 'wallet::4d32f0737a05f072' ] , function ( err ) {
4971- should . not . exist ( err ) ;
4972- c2 . credentials . sharedEncryptingKey . should . equal ( 'Ou2j4kq3z1w4yTr9YybVxg==' ) ;
4973-
4974- // This should pull the non-temporary keys
4975- c2 . getStatus ( { } , function ( err , status ) {
4976- should . not . exist ( err ) ;
4977- status . wallet . status . should . equal ( 'complete' ) ;
4978- c2 . createAddress ( function ( err , x0 ) {
4979- x0 . address . should . be . equal ( '2Mv1DHpozzZ9fup2nZ1kmdRXoNnDJ8b1JF2' ) ;
4980- c . createAddress ( function ( err , x0 ) {
4981- x0 . address . should . be . equal ( '2N2dZ1HogpxHVKv3CD2R4WrhWRwqZtpDc2M' ) ;
4982- done ( ) ;
4983- } ) ;
4984- } ) ;
4985- } ) ;
4986- } ) ;
4987- } ) ;
4988- } ) ;
4989- } ) ;
4990-
4991- it ( 'Should import and complete 2-3 wallet from 2 copayers, and create addresses' , function ( done ) {
4992- var w = 'wallet::7065a73486c8cb5d' ;
4993- var key = 'fS4HhoRd25KJY4VpNpO1jg==' ;
4994- var t = ImportData . copayers [ 0 ] ;
4995- var c = helpers . newClient ( app ) ;
4996- c . createWalletFromOldCopay ( t . username , t . password , t . ls [ w ] , function ( err ) {
4997- should . not . exist ( err ) ;
4998- c . getStatus ( { } , function ( err , status ) {
4999- should . not . exist ( err ) ;
5000- status . wallet . status . should . equal ( 'complete' ) ;
5001- c . credentials . sharedEncryptingKey . should . equal ( key ) ;
5002-
5003- var t2 = ImportData . copayers [ 1 ] ;
5004- var c2 = helpers . newClient ( app ) ;
5005- c2 . createWalletFromOldCopay ( t2 . username , t2 . password , t2 . ls [ w ] , function ( err ) {
5006- should . not . exist ( err ) ;
5007- c2 . credentials . sharedEncryptingKey . should . equal ( key ) ;
5008-
5009- c2 . getStatus ( { } , function ( err , status ) {
5010- should . not . exist ( err ) ;
5011- status . wallet . status . should . equal ( 'complete' ) ;
5012-
5013- var t3 = ImportData . copayers [ 2 ] ;
5014- var c3 = helpers . newClient ( app ) ;
5015- c3 . createWalletFromOldCopay ( t3 . username , t3 . password , t3 . ls [ w ] , function ( err ) {
5016- should . not . exist ( err ) ;
5017- c3 . credentials . sharedEncryptingKey . should . equal ( key ) ;
5018-
5019- // This should pull the non-temporary keys
5020- c3 . getStatus ( { } , function ( err , status ) {
5021- should . not . exist ( err ) ;
5022- status . wallet . status . should . equal ( 'complete' ) ;
5023- done ( ) ;
5024- } ) ;
5025- } ) ;
5026- } ) ;
5027- } ) ;
5028- } ) ;
5029- } ) ;
5030- } ) ;
5031-
5032- it ( 'Should import a 2-3 wallet from 2 copayers, and recreate it, and then on the recreated other copayers should be able to access' , function ( done ) {
5033- var w = 'wallet::7065a73486c8cb5d' ;
5034- var key = 'fS4HhoRd25KJY4VpNpO1jg==' ;
5035- var t = ImportData . copayers [ 0 ] ;
5036- var c = helpers . newClient ( app ) ;
5037- c . createWalletFromOldCopay ( t . username , t . password , t . ls [ w ] , function ( err ) {
5038- should . not . exist ( err ) ;
5039- var t2 = ImportData . copayers [ 1 ] ;
5040- var c2 = helpers . newClient ( app ) ;
5041- c2 . createWalletFromOldCopay ( t2 . username , t2 . password , t2 . ls [ w ] , function ( err ) {
5042- should . not . exist ( err ) ;
5043-
5044- // New BWS server...
5045- var storage = new Storage ( {
5046- db : db2 ,
5047- } ) ;
5048- var newApp ;
5049- var expressApp = new ExpressApp ( ) ;
5050- expressApp . start ( {
5051- storage : storage ,
5052- blockchainExplorer : blockchainExplorerMock ,
5053- disableLogs : true ,
5054- } ,
5055- function ( ) {
5056- newApp = expressApp . app ;
5057- } ) ;
5058- var recoveryClient = helpers . newClient ( newApp ) ;
5059- recoveryClient . import ( c . export ( ) ) ;
5060-
5061- /*
5062- * This is to export 2 old BIP45 wallets
5063- var b= c.export();
5064-
5065- var e = sjcl.encrypt('hola', b, {
5066- iter: 10000
5067- });
5068- console.log("[client.js.4813] C EXPORT\n", e); //TODO
5069-
5070- b= c2.export();
5071- e= sjcl.encrypt('hola', b, {
5072- iter: 10000
5073- });
5074-
5075- console.log("[client.js.4813] C2 EXPORT\n", e); //TODO
5076- */
5077-
5078- recoveryClient . recreateWallet ( function ( err ) {
5079- should . not . exist ( err ) ;
5080- recoveryClient . getStatus ( { } , function ( err , status ) {
5081- should . not . exist ( err ) ;
5082- _ . map ( status . wallet . copayers , 'name' ) . sort ( ) . should . deep . equal ( [ '123' , '234' , '345' ] ) ;
5083- var t2 = ImportData . copayers [ 1 ] ;
5084- var c2p = helpers . newClient ( newApp ) ;
5085- c2p . createWalletFromOldCopay ( t2 . username , t2 . password , t2 . ls [ w ] , function ( err ) {
5086- should . not . exist ( err ) ;
5087- c2p . getStatus ( { } , function ( err , status ) {
5088- should . not . exist ( err ) ;
5089- _ . map ( status . wallet . copayers , 'name' ) . sort ( ) . should . deep . equal ( [ '123' , '234' , '345' ] ) ;
5090- done ( ) ;
5091- } ) ;
5092- } ) ;
5093- } ) ;
5094- } ) ;
5095- } ) ;
5096- } ) ;
5097- } ) ;
5098- } ) ;
5099-
51004869 describe ( 'Private key encryption' , function ( ) {
51014870 var password = 'jesuissatoshi' ;
51024871 var c1 , c2 ;
0 commit comments