@ -38,6 +38,40 @@ helpers.getAuthServer = function(copayerId, cb) {
} ) ;
} ;
helpers . _ generateCopayersTestData = function ( n ) {
console . log ( 'var copayers = [' ) ;
_ . each ( _ . range ( n ) , function ( c ) {
var xpriv = new Bitcore . HDPrivateKey ( ) ;
var xpub = Bitcore . HDPublicKey ( xpriv ) ;
var xpriv_45H = xpriv . derive ( 45 , true ) ;
var xpub_45H = Bitcore . HDPublicKey ( xpriv_45H ) ;
var id = WalletUtils . xPubToCopayerId ( xpub_45H . toString ( ) ) ;
var xpriv_1H = xpriv . derive ( 1 , true ) ;
var xpub_1H = Bitcore . HDPublicKey ( xpriv_1H ) ;
var priv = xpriv_1H . derive ( 0 ) . privateKey ;
var pub = xpub_1H . derive ( 0 ) . publicKey ;
console . log ( '{id: ' , "'" + id + "'," ) ;
console . log ( 'xPrivKey: ' , "'" + xpriv . toString ( ) + "'," ) ;
console . log ( 'xPubKey: ' , "'" + xpub . toString ( ) + "'," ) ;
console . log ( 'xPrivKey_45H: ' , "'" + xpriv_45H . toString ( ) + "'," ) ;
console . log ( 'xPubKey_45H: ' , "'" + xpub_45H . toString ( ) + "'," ) ;
console . log ( 'xPrivKey_1H: ' , "'" + xpriv_1H . toString ( ) + "'," ) ;
console . log ( 'xPubKey_1H: ' , "'" + xpub_1H . toString ( ) + "'," ) ;
console . log ( 'privKey_1H_0: ' , "'" + priv . toString ( ) + "'," ) ;
console . log ( 'pubKey_1H_0: ' , "'" + pub . toString ( ) + "'}," ) ;
} ) ;
console . log ( '];' ) ;
} ;
helpers . getSignedCopayerOpts = function ( opts ) {
var hash = WalletUtils . getCopayerHash ( opts . name , opts . xPubKey , opts . requestPubKey ) ;
opts . copayerSignature = WalletUtils . signMessage ( hash , TestData . keyPair . priv ) ;
return opts ;
} ;
helpers . createAndJoinWallet = function ( m , n , cb ) {
var server = new WalletService ( ) ;
var copayerIds = [ ] ;
@ -53,12 +87,12 @@ helpers.createAndJoinWallet = function(m, n, cb) {
if ( err ) return cb ( err ) ;
async . each ( _ . range ( n ) , function ( i , cb ) {
var copayerOpts = {
var copayerOpts = helpers . getSignedCopayerOpts ( {
walletId : walletId ,
name : 'copayer ' + ( i + 1 ) ,
xPubKey : TestData . copayers [ i + offset ] . xPubKey ,
xPubKeySignature : TestData . copayers [ i + offset ] . xPubKeySignature ,
} ;
xPubKey : TestData . copayers [ i + offset ] . xPubKey_45H ,
requestPubKey : TestData . copayers [ i + offset ] . pubKey_1H_0 ,
} ) ;
server . joinWallet ( copayerOpts , function ( err , result ) {
should . not . exist ( err ) ;
@ -222,11 +256,7 @@ describe('Copay server', function() {
helpers . createAndJoinWallet ( 1 , 2 , function ( s , wallet ) {
var xpriv = TestData . copayers [ 0 ] . xPrivKey ;
var priv = Bitcore . HDPrivateKey
. fromString ( xpriv )
. derive ( 'm/1/1' )
. privateKey
. toString ( ) ;
var priv = TestData . copayers [ 0 ] . privKey_1H_0 ;
var sig = WalletUtils . signMessage ( 'hello world' , priv ) ;
@ -380,12 +410,12 @@ describe('Copay server', function() {
} ) ;
it ( 'should join existing wallet' , function ( done ) {
var copayerOpts = {
var copayerOpts = helpers . getSignedCopayerOpts ( {
walletId : walletId ,
name : 'me' ,
xPubKey : TestData . copayers [ 0 ] . xPubKey ,
xPubKeySignature : TestData . copayers [ 0 ] . xPubKeySignature ,
} ;
xPubKey : TestData . copayers [ 0 ] . xPubKey_45H ,
requestPubKey : TestData . copayers [ 0 ] . pubKey_1H_0 ,
} ) ;
server . joinWallet ( copayerOpts , function ( err , result ) {
should . not . exist ( err ) ;
var copayerId = result . copayerId ;
@ -403,12 +433,12 @@ describe('Copay server', function() {
} ) ;
it ( 'should fail to join with no name' , function ( done ) {
var copayerOpts = {
var copayerOpts = helpers . getSignedCopayerOpts ( {
walletId : walletId ,
name : '' ,
xPubKey : TestData . copayers [ 0 ] . xPubKey ,
xPubKeySignature : TestData . copayers [ 0 ] . xPubKeySignature ,
} ;
xPubKey : TestData . copayers [ 0 ] . xPubKey_45H ,
requestPubKey : TestData . copayers [ 0 ] . pubKey_1H_0 ,
} ) ;
server . joinWallet ( copayerOpts , function ( err , result ) {
should . not . exist ( result ) ;
should . exist ( err ) ;
@ -422,7 +452,8 @@ describe('Copay server', function() {
walletId : '123' ,
name : 'me' ,
xPubKey : 'dummy' ,
xPubKeySignature : 'dummy' ,
requestPubKey : 'dummy' ,
copayerSignature : 'dummy' ,
} ;
server . joinWallet ( copayerOpts , function ( err ) {
should . exist ( err ) ;
@ -432,12 +463,12 @@ describe('Copay server', function() {
it ( 'should fail to join full wallet' , function ( done ) {
helpers . createAndJoinWallet ( 1 , 1 , function ( s , wallet ) {
var copayerOpts = {
var copayerOpts = helpers . getSignedCopayerOpts ( {
walletId : wallet . id ,
name : 'me' ,
xPubKey : TestData . copayers [ 1 ] . xPubKey ,
xPubKeySignature : TestData . copayers [ 1 ] . xPubKeySignature ,
} ;
xPubKey : TestData . copayers [ 1 ] . xPubKey_45H ,
requestPubKey : TestData . copayers [ 1 ] . pubKey_1H_0 ,
} ) ;
server . joinWallet ( copayerOpts , function ( err ) {
should . exist ( err ) ;
err . code . should . equal ( 'WFULL' ) ;
@ -448,12 +479,12 @@ describe('Copay server', function() {
} ) ;
it ( 'should fail to re-join wallet' , function ( done ) {
var copayerOpts = {
var copayerOpts = helpers . getSignedCopayerOpts ( {
walletId : walletId ,
name : 'me' ,
xPubKey : TestData . copayers [ 0 ] . xPubKey ,
xPubKeySignature : TestData . copayers [ 0 ] . xPubKeySignature ,
} ;
xPubKey : TestData . copayers [ 0 ] . xPubKey_45H ,
requestPubKey : TestData . copayers [ 0 ] . pubKey_1H_0 ,
} ) ;
server . joinWallet ( copayerOpts , function ( err ) {
should . not . exist ( err ) ;
server . joinWallet ( copayerOpts , function ( err ) {
@ -466,12 +497,12 @@ describe('Copay server', function() {
} ) ;
it ( 'should fail two wallets with same xPubKey' , function ( done ) {
var copayerOpts = {
var copayerOpts = helpers . getSignedCopayerOpts ( {
walletId : walletId ,
name : 'me' ,
xPubKey : TestData . copayers [ 0 ] . xPubKey ,
xPubKeySignature : TestData . copayers [ 0 ] . xPubKeySignature ,
} ;
xPubKey : TestData . copayers [ 0 ] . xPubKey_45H ,
requestPubKey : TestData . copayers [ 0 ] . pubKey_1H_0 ,
} ) ;
server . joinWallet ( copayerOpts , function ( err ) {
should . not . exist ( err ) ;
@ -483,12 +514,12 @@ describe('Copay server', function() {
} ;
server . createWallet ( walletOpts , function ( err , walletId ) {
should . not . exist ( err ) ;
copayerOpts = {
copayerOpts = helpers . getSignedCopayerOpts ( {
walletId : walletId ,
name : 'me' ,
xPubKey : TestData . copayers [ 0 ] . xPubKey ,
xPubKeySignature : TestData . copayers [ 0 ] . xPubKeySignature ,
} ;
xPubKey : TestData . copayers [ 0 ] . xPubKey_45H ,
requestPubKey : TestData . copayers [ 0 ] . pubKey_1H_0 ,
} ) ;
server . joinWallet ( copayerOpts , function ( err ) {
should . exist ( err ) ;
err . code . should . equal ( 'CREGISTERED' ) ;
@ -503,8 +534,9 @@ describe('Copay server', function() {
var copayerOpts = {
walletId : walletId ,
name : 'me' ,
xPubKey : TestData . copayers [ 0 ] . xPubKey ,
xPubKeySignature : 'bad sign' ,
xPubKey : TestData . copayers [ 0 ] . xPubKey_45H ,
requestPubKey : TestData . copayers [ 0 ] . pubKey_1H_0 ,
copayerSignature : 'bad sign' ,
} ;
server . joinWallet ( copayerOpts , function ( err ) {
err . message . should . equal ( 'Bad request' ) ;
@ -516,7 +548,8 @@ describe('Copay server', function() {
var copayerOpts = {
walletId : walletId ,
name : 'me' ,
xPubKey : TestData . copayers [ 0 ] . xPubKey [ 0 ] ,
xPubKey : TestData . copayers [ 0 ] . xPubKey_45H ,
requestPubKey : TestData . copayers [ 0 ] . pubKey_1H_0 ,
} ;
server . joinWallet ( copayerOpts , function ( err ) {
should . exist ( err ) ;
@ -526,12 +559,13 @@ describe('Copay server', function() {
} ) ;
it ( 'should fail to join with wrong signature' , function ( done ) {
var copayerOpts = {
var copayerOpts = helpers . getSignedCopayerOpts ( {
walletId : walletId ,
name : 'me' ,
xPubKey : TestData . copayers [ 0 ] . xPubKey ,
xPubKeySignature : TestData . copayers [ 1 ] . xPubKeySignature ,
} ;
xPubKey : TestData . copayers [ 0 ] . xPubKey_45H ,
requestPubKey : TestData . copayers [ 0 ] . pubKey_1H_0 ,
} ) ;
copayerOpts . name = 'me2' ;
server . joinWallet ( copayerOpts , function ( err ) {
err . message . should . equal ( 'Bad request' ) ;
done ( ) ;
@ -601,7 +635,7 @@ describe('Copay server', function() {
server . createAddress ( { } , function ( err , address ) {
should . not . exist ( err ) ;
address . should . exist ;
address . address . should . equal ( '38Jf1QE7ddXscW76ACgJrNkMWBwDAgMm6M ' ) ;
address . address . should . equal ( '3KxttbKQQPWmpsnXZ3rB4mgJTuLnVR7frg ' ) ;
address . isChange . should . be . false ;
address . path . should . equal ( 'm/2147483647/0/0' ) ;
done ( ) ;
@ -636,7 +670,7 @@ describe('Copay server', function() {
server . createAddress ( { } , function ( err , address ) {
should . not . exist ( err ) ;
address . should . exist ;
address . address . should . equal ( '38Jf1QE7ddXscW76ACgJrNkMWBwDAgMm6M ' ) ;
address . address . should . equal ( '3KxttbKQQPWmpsnXZ3rB4mgJTuLnVR7frg ' ) ;
address . path . should . equal ( 'm/2147483647/0/0' ) ;
done ( ) ;
} ) ;
@ -728,12 +762,12 @@ describe('Copay server', function() {
} ;
server . createWallet ( walletOpts , function ( err , walletId ) {
should . not . exist ( err ) ;
var copayerOpts = {
var copayerOpts = helpers . getSignedCopayerOpts ( {
walletId : walletId ,
name : 'me' ,
xPubKey : TestData . copayers [ 0 ] . xPubKey ,
xPubKeySignature : TestData . copayers [ 0 ] . xPubKeySignature ,
} ;
xPubKey : TestData . copayers [ 0 ] . xPubKey_45H ,
requestPubKey : TestData . copayers [ 0 ] . pubKey_1H_0 ,
} ) ;
server . joinWallet ( copayerOpts , function ( err , result ) {
should . not . exist ( err ) ;
helpers . getAuthServer ( result . copayerId , function ( server ) {
@ -758,12 +792,12 @@ describe('Copay server', function() {
} ;
server . createWallet ( walletOpts , function ( err , walletId ) {
should . not . exist ( err ) ;
var copayerOpts = {
var copayerOpts = helpers . getSignedCopayerOpts ( {
walletId : walletId ,
name : 'me' ,
xPubKey : TestData . copayers [ 0 ] . xPubKey ,
xPubKeySignature : TestData . copayers [ 0 ] . xPubKeySignature ,
} ;
xPubKey : TestData . copayers [ 0 ] . xPubKey_45H ,
requestPubKey : TestData . copayers [ 0 ] . pubKey_1H_0 ,
} ) ;
server . joinWallet ( copayerOpts , function ( err , result ) {
should . not . exist ( err ) ;
helpers . getAuthServer ( result . copayerId , function ( server , wallet ) {
@ -792,7 +826,7 @@ describe('Copay server', function() {
it ( 'should create a tx' , function ( done ) {
helpers . stubUtxos ( server , wallet , [ 100 , 200 ] , function ( ) {
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 80 , 'some message' , TestData . copayers [ 0 ] . privKey ) ;
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 80 , 'some message' , TestData . copayers [ 0 ] . privKey_1H_0 ) ;
server . createTx ( txOpts , function ( err , tx ) {
should . not . exist ( err ) ;
should . exist ( tx ) ;
@ -856,7 +890,7 @@ describe('Copay server', function() {
it ( 'should fail to create tx with proposal signed by another copayer' , function ( done ) {
helpers . stubUtxos ( server , wallet , [ 100 , 200 ] , function ( ) {
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 80 , null , TestData . copayers [ 1 ] . privKey ) ;
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 80 , null , TestData . copayers [ 1 ] . privKey_1H_0 ) ;
server . createTx ( txOpts , function ( err , tx ) {
should . not . exist ( tx ) ;
@ -869,7 +903,7 @@ describe('Copay server', function() {
it ( 'should fail to create tx for invalid address' , function ( done ) {
helpers . stubUtxos ( server , wallet , [ 100 , 200 ] , function ( ) {
var txOpts = helpers . createProposalOpts ( 'invalid address' , 80 , null , TestData . copayers [ 0 ] . privKey ) ;
var txOpts = helpers . createProposalOpts ( 'invalid address' , 80 , null , TestData . copayers [ 0 ] . privKey_1H_0 ) ;
server . createTx ( txOpts , function ( err , tx ) {
should . not . exist ( tx ) ;
@ -883,7 +917,7 @@ describe('Copay server', function() {
it ( 'should fail to create tx for address of different network' , function ( done ) {
helpers . stubUtxos ( server , wallet , [ 100 , 200 ] , function ( ) {
var txOpts = helpers . createProposalOpts ( 'myE38JHdxmQcTJGP1ZiX4BiGhDxMJDvLJD' , 80 , null , TestData . copayers [ 0 ] . privKey ) ;
var txOpts = helpers . createProposalOpts ( 'myE38JHdxmQcTJGP1ZiX4BiGhDxMJDvLJD' , 80 , null , TestData . copayers [ 0 ] . privKey_1H_0 ) ;
server . createTx ( txOpts , function ( err , tx ) {
should . not . exist ( tx ) ;
@ -896,7 +930,7 @@ describe('Copay server', function() {
} ) ;
it ( 'should fail to create tx for invalid amount' , function ( done ) {
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 0 , null , TestData . copayers [ 0 ] . privKey ) ;
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 0 , null , TestData . copayers [ 0 ] . privKey_1H_0 ) ;
server . createTx ( txOpts , function ( err , tx ) {
should . not . exist ( tx ) ;
should . exist ( err ) ;
@ -907,7 +941,7 @@ describe('Copay server', function() {
it ( 'should fail to create tx when insufficient funds' , function ( done ) {
helpers . stubUtxos ( server , wallet , [ 100 ] , function ( ) {
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 120 , null , TestData . copayers [ 0 ] . privKey ) ;
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 120 , null , TestData . copayers [ 0 ] . privKey_1H_0 ) ;
server . createTx ( txOpts , function ( err , tx ) {
should . exist ( err ) ;
err . code . should . equal ( 'INSUFFICIENTFUNDS' ) ;
@ -928,7 +962,7 @@ describe('Copay server', function() {
it ( 'should fail to create tx when insufficient funds for fee' , function ( done ) {
helpers . stubUtxos ( server , wallet , [ 100 ] , function ( ) {
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 100 , null , TestData . copayers [ 0 ] . privKey ) ;
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 100 , null , TestData . copayers [ 0 ] . privKey_1H_0 ) ;
server . createTx ( txOpts , function ( err , tx ) {
should . exist ( err ) ;
err . code . should . equal ( 'INSUFFICIENTFUNDS' ) ;
@ -940,7 +974,7 @@ describe('Copay server', function() {
it ( 'should fail to create tx for dust amount' , function ( done ) {
helpers . stubUtxos ( server , wallet , [ 1 ] , function ( ) {
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 0.00000001 , null , TestData . copayers [ 0 ] . privKey ) ;
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 0.00000001 , null , TestData . copayers [ 0 ] . privKey_1H_0 ) ;
server . createTx ( txOpts , function ( err , tx ) {
should . exist ( err ) ;
err . code . should . equal ( 'DUSTAMOUNT' ) ;
@ -957,7 +991,7 @@ describe('Copay server', function() {
name : 'dummy' ,
message : 'dummy exception'
} ) ;
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 2 , null , TestData . copayers [ 0 ] . privKey ) ;
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 2 , null , TestData . copayers [ 0 ] . privKey_1H_0 ) ;
server . createTx ( txOpts , function ( err , tx ) {
should . exist ( err ) ;
err . message . should . equal ( 'dummy exception' ) ;
@ -969,11 +1003,11 @@ describe('Copay server', function() {
it ( 'should create tx when there is a pending tx and enough UTXOs' , function ( done ) {
helpers . stubUtxos ( server , wallet , [ 10.1 , 10.2 , 10.3 ] , function ( ) {
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 12 , null , TestData . copayers [ 0 ] . privKey ) ;
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 12 , null , TestData . copayers [ 0 ] . privKey_1H_0 ) ;
server . createTx ( txOpts , function ( err , tx ) {
should . not . exist ( err ) ;
should . exist ( tx ) ;
var txOpts2 = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 8 , null , TestData . copayers [ 0 ] . privKey ) ;
var txOpts2 = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 8 , null , TestData . copayers [ 0 ] . privKey_1H_0 ) ;
server . createTx ( txOpts2 , function ( err , tx ) {
should . not . exist ( err ) ;
should . exist ( tx ) ;
@ -994,11 +1028,11 @@ describe('Copay server', function() {
it ( 'should fail to create tx when there is a pending tx and not enough UTXOs' , function ( done ) {
helpers . stubUtxos ( server , wallet , [ 10.1 , 10.2 , 10.3 ] , function ( ) {
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 12 , null , TestData . copayers [ 0 ] . privKey ) ;
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 12 , null , TestData . copayers [ 0 ] . privKey_1H_0 ) ;
server . createTx ( txOpts , function ( err , tx ) {
should . not . exist ( err ) ;
should . exist ( tx ) ;
var txOpts2 = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 24 , null , TestData . copayers [ 0 ] . privKey ) ;
var txOpts2 = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 24 , null , TestData . copayers [ 0 ] . privKey_1H_0 ) ;
server . createTx ( txOpts2 , function ( err , tx ) {
err . code . should . equal ( 'INSUFFICIENTFUNDS' ) ;
err . message . should . equal ( 'Insufficient funds' ) ;
@ -1025,7 +1059,7 @@ describe('Copay server', function() {
should . not . exist ( err ) ;
balance . totalAmount . should . equal ( helpers . toSatoshi ( N * 100 ) ) ;
balance . lockedAmount . should . equal ( helpers . toSatoshi ( 0 ) ) ;
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 80 , null , TestData . copayers [ 0 ] . privKey ) ;
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 80 , null , TestData . copayers [ 0 ] . privKey_1H_0 ) ;
async . map ( _ . range ( N ) , function ( i , cb ) {
server . createTx ( txOpts , function ( err , tx ) {
cb ( err , tx ) ;
@ -1056,7 +1090,7 @@ describe('Copay server', function() {
server = s ;
wallet = w ;
helpers . stubUtxos ( server , wallet , _ . range ( 1 , 9 ) , function ( ) {
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 10 , null , TestData . copayers [ 0 ] . privKey ) ;
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 10 , null , TestData . copayers [ 0 ] . privKey_1H_0 ) ;
server . createTx ( txOpts , function ( err , tx ) {
should . not . exist ( err ) ;
should . exist ( tx ) ;
@ -1146,7 +1180,7 @@ describe('Copay server', function() {
server = s ;
wallet = w ;
helpers . stubUtxos ( server , wallet , _ . range ( 1 , 9 ) , function ( ) {
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 10 , null , TestData . copayers [ 0 ] . privKey ) ;
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 10 , null , TestData . copayers [ 0 ] . privKey_1H_0 ) ;
server . createTx ( txOpts , function ( err , tx ) {
should . not . exist ( err ) ;
should . exist ( tx ) ;
@ -1162,7 +1196,7 @@ describe('Copay server', function() {
var tx = txs [ 0 ] ;
tx . id . should . equal ( txid ) ;
var signatures = helpers . clientSign ( tx , TestData . copayers [ 0 ] . xPrivKey ) ;
var signatures = helpers . clientSign ( tx , TestData . copayers [ 0 ] . xPrivKey_45H ) ;
server . signTx ( {
txProposalId : txid ,
signatures : signatures ,
@ -1189,7 +1223,7 @@ describe('Copay server', function() {
server . getPendingTxs ( { } , function ( err , txs ) {
var tx = txs [ 0 ] ;
tx . id . should . equal ( txid ) ;
var signatures = helpers . clientSign ( tx , TestData . copayers [ 1 ] . xPrivKey ) ;
var signatures = helpers . clientSign ( tx , TestData . copayers [ 1 ] . xPrivKey_45H ) ;
server . signTx ( {
txProposalId : txid ,
signatures : signatures ,
@ -1205,7 +1239,7 @@ describe('Copay server', function() {
var tx = txs [ 0 ] ;
tx . id . should . equal ( txid ) ;
var signatures = helpers . clientSign ( tx , TestData . copayers [ 0 ] . xPrivKey ) ;
var signatures = helpers . clientSign ( tx , TestData . copayers [ 0 ] . xPrivKey_45H ) ;
signatures [ 0 ] = 1 ;
server . signTx ( {
@ -1240,7 +1274,7 @@ describe('Copay server', function() {
var tx = txs [ 0 ] ;
tx . id . should . equal ( txid ) ;
var signatures = _ . take ( helpers . clientSign ( tx , TestData . copayers [ 0 ] . xPrivKey ) , 2 ) ;
var signatures = _ . take ( helpers . clientSign ( tx , TestData . copayers [ 0 ] . xPrivKey_45H ) , 2 ) ;
server . signTx ( {
txProposalId : txid ,
signatures : signatures ,
@ -1257,7 +1291,7 @@ describe('Copay server', function() {
var tx = txs [ 0 ] ;
tx . id . should . equal ( txid ) ;
var signatures = helpers . clientSign ( tx , TestData . copayers [ 0 ] . xPrivKey ) ;
var signatures = helpers . clientSign ( tx , TestData . copayers [ 0 ] . xPrivKey_45H ) ;
server . signTx ( {
txProposalId : txid ,
signatures : signatures ,
@ -1280,7 +1314,7 @@ describe('Copay server', function() {
server . rejectTx ( {
txProposalId : txid ,
} , function ( err ) {
var signatures = helpers . clientSign ( tx , TestData . copayers [ 0 ] . xPrivKey ) ;
var signatures = helpers . clientSign ( tx , TestData . copayers [ 0 ] . xPrivKey_45H ) ;
server . signTx ( {
txProposalId : txid ,
signatures : signatures ,
@ -1328,7 +1362,7 @@ describe('Copay server', function() {
txProposalId : txid
} , function ( err , tx ) {
should . not . exist ( err ) ;
var signatures = helpers . clientSign ( tx , TestData . copayers [ 2 ] . xPrivKey ) ;
var signatures = helpers . clientSign ( tx , TestData . copayers [ 2 ] . xPrivKey_45H ) ;
server . signTx ( {
txProposalId : txid ,
signatures : signatures ,
@ -1351,11 +1385,11 @@ describe('Copay server', function() {
server = s ;
wallet = w ;
helpers . stubUtxos ( server , wallet , [ 10 , 10 ] , function ( ) {
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 9 , 'some message' , TestData . copayers [ 0 ] . privKey ) ;
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 9 , 'some message' , TestData . copayers [ 0 ] . privKey_1H_0 ) ;
server . createTx ( txOpts , function ( err , txp ) {
should . not . exist ( err ) ;
should . exist ( txp ) ;
var signatures = helpers . clientSign ( txp , TestData . copayers [ 0 ] . xPrivKey ) ;
var signatures = helpers . clientSign ( txp , TestData . copayers [ 0 ] . xPrivKey_45H ) ;
server . signTx ( {
txProposalId : txp . id ,
signatures : signatures ,
@ -1410,7 +1444,7 @@ describe('Copay server', function() {
it ( 'should fail to brodcast a not yet accepted tx' , function ( done ) {
helpers . stubBroadcast ( '999' ) ;
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 9 , 'some other message' , TestData . copayers [ 0 ] . privKey ) ;
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 9 , 'some other message' , TestData . copayers [ 0 ] . privKey_1H_0 ) ;
server . createTx ( txOpts , function ( err , txp ) {
should . not . exist ( err ) ;
should . exist ( txp ) ;
@ -1458,7 +1492,7 @@ describe('Copay server', function() {
} ) ;
it ( 'other copayers should see pending proposal created by one copayer' , function ( done ) {
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 10 , 'some message' , TestData . copayers [ 0 ] . privKey ) ;
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 10 , 'some message' , TestData . copayers [ 0 ] . privKey_1H_0 ) ;
server . createTx ( txOpts , function ( err , txp ) {
should . not . exist ( err ) ;
should . exist ( txp ) ;
@ -1479,7 +1513,7 @@ describe('Copay server', function() {
async . waterfall ( [
function ( next ) {
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 10 , 'some message' , TestData . copayers [ 0 ] . privKey ) ;
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 10 , 'some message' , TestData . copayers [ 0 ] . privKey_1H_0 ) ;
server . createTx ( txOpts , function ( err , txp ) {
txpId = txp . id ;
should . not . exist ( err ) ;
@ -1497,7 +1531,7 @@ describe('Copay server', function() {
} ) ;
} ,
function ( txp , next ) {
var signatures = helpers . clientSign ( txp , TestData . copayers [ 0 ] . xPrivKey ) ;
var signatures = helpers . clientSign ( txp , TestData . copayers [ 0 ] . xPrivKey_45H ) ;
server . signTx ( {
txProposalId : txpId ,
signatures : signatures ,
@ -1528,7 +1562,7 @@ describe('Copay server', function() {
} ,
function ( txp , next ) {
helpers . getAuthServer ( wallet . copayers [ 1 ] . id , function ( server , wallet ) {
var signatures = helpers . clientSign ( txp , TestData . copayers [ 1 ] . xPrivKey ) ;
var signatures = helpers . clientSign ( txp , TestData . copayers [ 1 ] . xPrivKey_45H ) ;
server . signTx ( {
txProposalId : txpId ,
signatures : signatures ,
@ -1565,7 +1599,7 @@ describe('Copay server', function() {
async . waterfall ( [
function ( next ) {
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 10 , 'some message' , TestData . copayers [ 0 ] . privKey ) ;
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 10 , 'some message' , TestData . copayers [ 0 ] . privKey_1H_0 ) ;
server . createTx ( txOpts , function ( err , txp ) {
txpId = txp . id ;
should . not . exist ( err ) ;
@ -1647,7 +1681,7 @@ describe('Copay server', function() {
server = s ;
wallet = w ;
helpers . stubUtxos ( server , wallet , 10 , function ( ) {
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 9 , 'some message' , TestData . copayers [ 0 ] . privKey ) ;
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 9 , 'some message' , TestData . copayers [ 0 ] . privKey_1H_0 ) ;
server . createTx ( txOpts , function ( err , txp ) {
should . not . exist ( err ) ;
should . exist ( txp ) ;
@ -1706,7 +1740,7 @@ describe('Copay server', function() {
server = s ;
wallet = w ;
helpers . stubUtxos ( server , wallet , _ . range ( 10 ) , function ( ) {
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 0.1 , null , TestData . copayers [ 0 ] . privKey ) ;
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 0.1 , null , TestData . copayers [ 0 ] . privKey_1H_0 ) ;
async . eachSeries ( _ . range ( 10 ) , function ( i , next ) {
clock . tick ( 10000 ) ;
server . createTx ( txOpts , function ( err , tx ) {
@ -1788,7 +1822,7 @@ describe('Copay server', function() {
server = s ;
wallet = w ;
helpers . stubUtxos ( server , wallet , helpers . toSatoshi ( _ . range ( 4 ) ) , function ( ) {
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 0.01 , null , TestData . copayers [ 0 ] . privKey ) ;
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 0.01 , null , TestData . copayers [ 0 ] . privKey_1H_0 ) ;
async . eachSeries ( _ . range ( 3 ) , function ( i , next ) {
server . createTx ( txOpts , function ( err , tx ) {
should . not . exist ( err ) ;
@ -1843,7 +1877,7 @@ describe('Copay server', function() {
server . getPendingTxs ( { } , function ( err , txs ) {
helpers . stubBroadcastFail ( ) ;
var tx = txs [ 0 ] ;
var signatures = helpers . clientSign ( tx , TestData . copayers [ 0 ] . xPrivKey ) ;
var signatures = helpers . clientSign ( tx , TestData . copayers [ 0 ] . xPrivKey_45H ) ;
server . signTx ( {
txProposalId : tx . id ,
signatures : signatures ,
@ -1885,7 +1919,7 @@ describe('Copay server', function() {
it ( 'should notify sign, acceptance, and broadcast, and emit' , function ( done ) {
server . getPendingTxs ( { } , function ( err , txs ) {
var tx = txs [ 2 ] ;
var signatures = helpers . clientSign ( tx , TestData . copayers [ 0 ] . xPrivKey ) ;
var signatures = helpers . clientSign ( tx , TestData . copayers [ 0 ] . xPrivKey_45H ) ;
sinon . spy ( server , 'emit' ) ;
server . signTx ( {
txProposalId : tx . id ,
@ -2004,7 +2038,7 @@ describe('Copay server', function() {
server = s ;
wallet = w ;
helpers . stubUtxos ( server , wallet , [ 100 , 200 ] , function ( ) {
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 80 , 'some message' , TestData . copayers [ 0 ] . privKey ) ;
var txOpts = helpers . createProposalOpts ( '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' , 80 , 'some message' , TestData . copayers [ 0 ] . privKey_1H_0 ) ;
server . createTx ( txOpts , function ( err , tx ) {
server . getPendingTxs ( { } , function ( err , txs ) {
txp = txs [ 0 ] ;
@ -2028,7 +2062,7 @@ describe('Copay server', function() {
} ) ;
it ( 'should allow creator to remove an signed TX by himself' , function ( done ) {
var signatures = helpers . clientSign ( txp , TestData . copayers [ 0 ] . xPrivKey ) ;
var signatures = helpers . clientSign ( txp , TestData . copayers [ 0 ] . xPrivKey_45H ) ;
server . signTx ( {
txProposalId : txp . id ,
signatures : signatures ,
@ -2050,7 +2084,7 @@ describe('Copay server', function() {
async . waterfall ( [
function ( next ) {
var signatures = helpers . clientSign ( txp , TestData . copayers [ 0 ] . xPrivKey ) ;
var signatures = helpers . clientSign ( txp , TestData . copayers [ 0 ] . xPrivKey_45H ) ;
server . signTx ( {
txProposalId : txp . id ,
signatures : signatures ,
@ -2114,7 +2148,7 @@ describe('Copay server', function() {
it ( 'should not allow creator copayer to remove an TX signed by other copayer' , function ( done ) {
helpers . getAuthServer ( wallet . copayers [ 1 ] . id , function ( server2 ) {
var signatures = helpers . clientSign ( txp , TestData . copayers [ 1 ] . xPrivKey ) ;
var signatures = helpers . clientSign ( txp , TestData . copayers [ 1 ] . xPrivKey_45H ) ;
server2 . signTx ( {
txProposalId : txp . id ,
signatures : signatures ,
@ -2246,12 +2280,12 @@ describe('Copay server', function() {
server . _ normalizeTxHistory = sinon . stub ( ) . returnsArg ( 0 ) ;
helpers . stubUtxos ( server , wallet , [ 100 , 200 ] , function ( utxos ) {
var txOpts = helpers . createProposalOpts ( mainAddresses [ 0 ] . address , 80 , 'some message' , TestData . copayers [ 0 ] . privKey ) ;
var txOpts = helpers . createProposalOpts ( mainAddresses [ 0 ] . address , 80 , 'some message' , TestData . copayers [ 0 ] . privKey_1H_0 ) ;
server . createTx ( txOpts , function ( err , tx ) {
should . not . exist ( err ) ;
should . exist ( tx ) ;
var signatures = helpers . clientSign ( tx , TestData . copayers [ 0 ] . xPrivKey ) ;
var signatures = helpers . clientSign ( tx , TestData . copayers [ 0 ] . xPrivKey_45H ) ;
server . signTx ( {
txProposalId : tx . id ,
signatures : signatures ,