@ -18,45 +18,7 @@ var Wallet = require('../lib/model/wallet');
var Address = require ( '../lib/model/address' ) ;
var Copayer = require ( '../lib/model/copayer' ) ;
var CopayServer = require ( '../lib/server' ) ;
var keyPair = {
priv : '0dea92f1df6675085b5cdd965487bb862f84f2755bcb56fa45dbf5b387a6c4a0' ,
pub : '026092daeed8ecb2212869395770e956ffc9bf453f803e700f64ffa70c97a00d80' ,
} ;
var aPubKey = '042F65F56A6C06C2B651C473AC221B2460DA57859AFB72564E9781B655EBC0AFAF322B9A732324ECC92A3319DFB1F0D53F0CB7E6620C98BD1EF53106A7CF3F6DB9' ;
var aXPubKey = 'xpub661MyMwAqRbcFHFFvUP6HaKdd2FYzNcZCGagxMzQEf1J3x2DeASBW2JWox7ToGwPM7V2yRzQAxcD6MdPid9C8kwhKkVWBxQ3dMo8zu3pub7' ;
var aXPubKeySignature = '3045022100f988737147894bbfdc196c1289e4d970b391c0d8e9d1fcc0397f16e6a31c9df2022014d9af9aceccb540f4a5a2680e2aebb1f3df55bcf3778599b78314a02064c592' ; // with keyPair.priv
// Copayers
var someXPrivKey = [
'xprv9s21ZrQH143K2rMHbXTJmWTuFx6ssqn1vyRoZqPkCXYchBSkp5ey8kMJe84sxfXq5uChWH4gk94rWbXZt2opN9kg4ufKGvUM7HQSLjnoh7e' ,
] ;
var someXPubKeys = [
'xpub661MyMwAqRbcFLRkhYzK8eQdoywNHJVsJCMQNDoMks5bZymuMcyDgYfnVQYq2Q9npnVmdTAthYGc3N3uxm5sEdnTpSqBc4YYTAhNnoSxCm9' ,
'xpub661MyMwAqRbcEzHgVwwxoXksq21rRNsJsn7AFy4VD4PzsEmjjWwsyEiTjsdQviXbqZ5yHVWJR8zFUDgUKkq4R97su3UyNo36Z8hSaCPrv6o' ,
'xpub661MyMwAqRbcFXUfkjfSaRwxJbAPpzNUvTiNFjgZwDJ8sZuhyodkP24L4LvsrgThYAAwKkVVSSmL7Ts7o9EHEHPB3EE89roAra7njoSeiMd' ,
'xpub661MyMwAqRbcGpExxHEzAWxBQX3k76NyerSpjqucSXXfTqH6Wq9sUVRwTjpHZHwapDbG16KEB9w9r3LT2jKYqU9xJf1YBAaZFikbUHiV1tg' ,
'xpub661MyMwAqRbcEvKQnt9ELHHcangXssm174sWr5gNTSmQYsAtvQJNUpLETDTm1vDxwtABvB4SRjGkNMm37NnMerKg4e3ygqmWEr75Fka4dK7' ,
'xpub661MyMwAqRbcG67ioS7rz3fFg7EDQNLJ9m1etAPwBecZhL5kKAKe4JU5jCTzRcEWp28XCYA1gKh7jyficSr97gcR2pjDL5jbWua1CwTKWV4' ,
] ;
// with keyPair.priv
var someXPubKeysSignatures = [
'30440220192ae7345d980f45f908bd63ccad60ce04270d07b91f1a9d92424a07a38af85202201591f0f71dd4e79d9206d2306862e6b8375e13a62c193953d768e884b6fb5a46' ,
'30440220134d13139323ba16ff26471c415035679ee18b2281bf85550ccdf6a370899153022066ef56ff97091b9be7dede8e40f50a3a8aad8205f2e3d8e194f39c20f3d15c62' ,
'304402207a4e7067d823a98fa634f9c9d991b8c42cd0f82da24f686992acf96cdeb5e387022021ceba729bf763fc8e4277f6851fc2b856a82a22b35f20d2eeb23d99c5f5a41c' ,
'304402203ae5bf7fa8935b8ab2ac33724dbb191356cecb47c8371d2c9389e918a3600918022073b48705306730c8fe4ab22d5f6ed3ca3def27eb6e8c5cc8f53e23c11fa5e5ef' ,
'3045022100eabd2a605403b377a8db9eec57726da0309a7eb385e7e4e5273b9862046f25ef02204d18755a90580a98f45e162ae5d5dc39aa3aa708a0d79433ed259e70a832b49c' ,
'3045022100c282254773c65025054e18a61ee550cbf78b88fc72ef66770050815b62502d9c02206e0df528203c9201c144f865df71f5d2471668f4ed8387979fcee20f6fa121a9' ,
] ;
//Copayer signature
var aText = 'hello world' ;
var aTextSignature = '3045022100addd20e5413865d65d561ad2979f2289a40d52594b1f804840babd9a63e4ebbf02204b86285e1fcab02df772e7a1325fc4b511ecad79a8f80a2bd1ad8bfa858ac3d4' ; // with someXPrivKey[0].derive('m/1/0')=5c0e043a513032907d181325a8e7990b076c0af15ed13dc5e611cda9bb3ae52a;
var TestData = require ( './testdata' ) ;
var helpers = { } ;
@ -82,18 +44,17 @@ helpers.createAndJoinWallet = function(m, n, cb) {
name : 'a wallet' ,
m : m ,
n : n ,
pubKey : keyPair . pub ,
pubKey : TestData . keyPair . pub ,
} ;
server . createWallet ( walletOpts , function ( err , walletId ) {
if ( err ) return cb ( err ) ;
async . each ( _ . range ( 1 , n + 1 ) , function ( i , cb ) {
async . each ( _ . range ( n ) , function ( i , cb ) {
var copayerOpts = {
walletId : walletId ,
name : 'copayer ' + i ,
xPubKey : someXPubKeys [ i - 1 ] ,
xPubKeySignature : someXPubKeysSignatures [ i - 1 ] ,
name : 'copayer ' + ( i + 1 ) ,
xPubKey : TestData . copayers [ i ] . xPubKey ,
xPubKeySignature : TestData . copayers [ i ] . xPubKeySignature ,
} ;
server . joinWallet ( copayerOpts , function ( err , copayerId ) {
@ -105,7 +66,7 @@ helpers.createAndJoinWallet = function(m, n, cb) {
helpers . getAuthServer ( copayerIds [ 0 ] , function ( s ) {
s . getWallet ( { } , function ( err , w ) {
cb ( s , w ) ;
cb ( s , w , _ . take ( TestData . copayers , w . n ) ) ;
} ) ;
} ) ;
} ) ;
@ -173,7 +134,7 @@ helpers.clientSign = function(tx, xpriv, n) {
//Derive proper key to sign, for each input
var privs = [ ] ,
derived = { } ;
var xpriv = new Bitcore . HDPrivateKey ( someXPrivKey [ 0 ] ) ;
var xpriv = new Bitcore . HDPrivateKey ( TestData . copayers [ 0 ] . xPrivKey ) ;
_ . each ( tx . inputs , function ( i ) {
if ( ! derived [ i . path ] ) {
@ -201,10 +162,9 @@ helpers.clientSign = function(tx, xpriv, n) {
return signatures ;
} ;
helpers . addProposalSignature = function ( server , wallet , txOpts ) {
helpers . addProposalSignature = function ( txOpts , privKey ) {
var msg = txOpts . toAddress + '|' + txOpts . amount + '|' + txOpts . message ;
var copayer = wallet . getCopayer ( server . copayerId ) ;
txOpts . proposalSignature = SignUtils . sign ( msg , copayer . signingPubKey ) ;
txOpts . proposalSignature = SignUtils . sign ( msg , privKey ) ;
} ;
var db , storage ;
@ -244,7 +204,7 @@ describe('Copay server', function() {
name : 'my wallet' ,
m : 2 ,
n : 3 ,
pubKey : aPubKey ,
pubKey : TestD ata . key Pair . p ub,
} ;
server . createWallet ( opts , function ( err , walletId ) {
should . not . exist ( err ) ;
@ -262,7 +222,7 @@ describe('Copay server', function() {
name : '' ,
m : 2 ,
n : 3 ,
pubKey : aPubKey ,
pubKey : TestD ata . key Pair . p ub,
} ;
server . createWallet ( opts , function ( err , walletId ) {
should . not . exist ( walletId ) ;
@ -295,7 +255,7 @@ describe('Copay server', function() {
var opts = {
id : '123' ,
name : 'my wallet' ,
pubKey : aPubKey ,
pubKey : TestD ata . key Pair . p ub,
} ;
async . each ( invalidPairs , function ( pair , cb ) {
opts . m = pair . m ;
@ -319,7 +279,7 @@ describe('Copay server', function() {
name : 'my wallet' ,
m : 2 ,
n : 3 ,
pubKey : keyPair . pub ,
pubKey : TestData . keyPair . pub ,
} ;
server . createWallet ( walletOpts , function ( err , wId ) {
should . not . exist ( err ) ;
@ -333,8 +293,8 @@ describe('Copay server', function() {
var copayerOpts = {
walletId : walletId ,
name : 'me' ,
xPubKey : aX PubKey,
xPubKeySignature : aX PubKeySignature,
xPubKey : TestData . copayers [ 0 ] . x PubKey,
xPubKeySignature : TestData . copayers [ 0 ] . x PubKeySignature,
} ;
server . joinWallet ( copayerOpts , function ( err , copayerId ) {
should . not . exist ( err ) ;
@ -355,8 +315,8 @@ describe('Copay server', function() {
var copayerOpts = {
walletId : walletId ,
name : '' ,
xPubKey : someXPubKey s[ 0 ] ,
xPubKeySignature : someXPubKeysSignature s[ 0 ] ,
xPubKey : TestData . copayer s[ 0 ] . xPubKey ,
xPubKeySignature : TestData . copayer s[ 0 ] . xPubKeySignature ,
} ;
server . joinWallet ( copayerOpts , function ( err , copayerId ) {
should . not . exist ( copayerId ) ;
@ -384,8 +344,8 @@ describe('Copay server', function() {
var copayerOpts = {
walletId : wallet . id ,
name : 'me' ,
xPubKey : someXPubKey s[ 1 ] ,
xPubKeySignature : someXPubKeysSignature s[ 1 ] ,
xPubKey : TestData . copayer s[ 1 ] . xPubKey ,
xPubKeySignature : TestData . copayer s[ 1 ] . xPubKeySignature ,
} ;
server . joinWallet ( copayerOpts , function ( err ) {
should . exist ( err ) ;
@ -400,8 +360,8 @@ describe('Copay server', function() {
var copayerOpts = {
walletId : walletId ,
name : 'me' ,
xPubKey : someXPubKey s[ 0 ] ,
xPubKeySignature : someXPubKeysSignature s[ 0 ] ,
xPubKey : TestData . copayer s[ 0 ] . xPubKey ,
xPubKeySignature : TestData . copayer s[ 0 ] . xPubKeySignature ,
} ;
server . joinWallet ( copayerOpts , function ( err ) {
should . not . exist ( err ) ;
@ -418,7 +378,7 @@ describe('Copay server', function() {
var copayerOpts = {
walletId : walletId ,
name : 'me' ,
xPubKey : someXPubKey s[ 0 ] ,
xPubKey : TestData . copayer s[ 0 ] . xPubKey ,
xPubKeySignature : 'bad sign' ,
} ;
server . joinWallet ( copayerOpts , function ( err ) {
@ -431,7 +391,7 @@ describe('Copay server', function() {
var copayerOpts = {
walletId : walletId ,
name : 'me' ,
xPubKey : someXPubKeys [ 0 ] ,
xPubKey : TestData . copayers [ 0 ] . xPubKey [ 0 ] ,
} ;
server . joinWallet ( copayerOpts , function ( err ) {
err . should . exist ;
@ -444,8 +404,8 @@ describe('Copay server', function() {
var copayerOpts = {
walletId : walletId ,
name : 'me' ,
xPubKey : someXPubKey s[ 0 ] ,
xPubKeySignature : someXPubKeysSignature s[ 1 ] ,
xPubKey : TestData . copayer s[ 0 ] . xPubKey ,
xPubKeySignature : TestData . copayer s[ 1 ] . xPubKeySignature ,
} ;
server . joinWallet ( copayerOpts , function ( err ) {
err . message . should . equal ( 'Bad request' ) ;
@ -478,8 +438,8 @@ describe('Copay server', function() {
it ( 'should successfully verify message signature' , function ( done ) {
var opts = {
message : aT ext,
signature : aTextS ignature,
message : TestData . message . t ext,
signature : TestData . message . s ignature,
} ;
server . verifyMessageSignature ( opts , function ( err , isValid ) {
should . not . exist ( err ) ;
@ -490,8 +450,8 @@ describe('Copay server', function() {
it ( 'should fail to verify message signature for different copayer' , function ( done ) {
var opts = {
message : aT ext,
signature : aTextS ignature,
message : TestData . message . t ext,
signature : TestData . message . s ignature,
} ;
helpers . getAuthServer ( wallet . copayers [ 1 ] . id , function ( server ) {
server . verifyMessageSignature ( opts , function ( err , isValid ) {
@ -517,7 +477,7 @@ describe('Copay server', function() {
server . createAddress ( { } , function ( err , address ) {
should . not . exist ( err ) ;
address . should . exist ;
address . address . should . equal ( '36JdLEUDa6UwCfMhhkdZ2VFnDrGUoLedsR ' ) ;
address . address . should . equal ( '38Jf1QE7ddXscW76ACgJrNkMWBwDAgMm6M ' ) ;
address . path . should . equal ( 'm/2147483647/0/0' ) ;
done ( ) ;
} ) ;
@ -529,15 +489,15 @@ describe('Copay server', function() {
name : 'my wallet' ,
m : 2 ,
n : 3 ,
pubKey : keyPair . pub ,
pubKey : TestData . keyPair . pub ,
} ;
server . createWallet ( walletOpts , function ( err , walletId ) {
should . not . exist ( err ) ;
var copayerOpts = {
walletId : walletId ,
name : 'me' ,
xPubKey : aX PubKey,
xPubKeySignature : aX PubKeySignature,
xPubKey : TestData . copayers [ 0 ] . x PubKey,
xPubKeySignature : TestData . copayers [ 0 ] . x PubKeySignature,
} ;
server . joinWallet ( copayerOpts , function ( err , copayerId ) {
should . not . exist ( err ) ;
@ -581,7 +541,7 @@ describe('Copay server', function() {
server . createAddress ( { } , function ( err , address ) {
should . not . exist ( err ) ;
address . should . exist ;
address . address . should . equal ( '36JdLEUDa6UwCfMhhkdZ2VFnDrGUoLedsR ' ) ;
address . address . should . equal ( '38Jf1QE7ddXscW76ACgJrNkMWBwDAgMm6M ' ) ;
address . path . should . equal ( 'm/2147483647/0/0' ) ;
done ( ) ;
} ) ;
@ -591,18 +551,19 @@ describe('Copay server', function() {
} ) ;
describe ( '#createTx' , function ( ) {
var server , wallet ;
var server , wallet , copayerPriv ;
beforeEach ( function ( done ) {
helpers . createAndJoinWallet ( 2 , 2 , function ( s , w ) {
helpers . createAndJoinWallet ( 2 , 2 , function ( s , w , c ) {
server = s ;
wallet = w ;
copayerPriv = c ;
server . createAddress ( { } , function ( err , address ) {
done ( ) ;
} ) ;
} ) ;
} ) ;
it . only ( 'should create a tx' , function ( done ) {
it ( 'should create a tx' , function ( done ) {
helpers . createUtxos ( server , wallet , helpers . toSatoshi ( [ 100 , 200 ] ) , function ( utxos ) {
helpers . stubBlockExplorer ( server , utxos ) ;
var txOpts = {
@ -610,10 +571,9 @@ describe('Copay server', function() {
amount : helpers . toSatoshi ( 80 ) ,
message : 'some message' ,
} ;
helpers . addProposalSignature ( txOpts , ) ;
console . log ( txOpts ) ;
helpers . addProposalSignature ( txOpts , copayerPriv [ 0 ] . privKey ) ;
server . createTx ( txOpts , function ( err , tx ) {
console . log ( err ) ;
should . not . exist ( err ) ;
tx . should . exist ;
tx . message . should . equal ( 'some message' ) ;
@ -639,15 +599,15 @@ describe('Copay server', function() {
name : 'my wallet' ,
m : 2 ,
n : 3 ,
pubKey : keyPair . pub ,
pubKey : TestData . keyPair . pub ,
} ;
server . createWallet ( walletOpts , function ( err , walletId ) {
should . not . exist ( err ) ;
var copayerOpts = {
walletId : walletId ,
name : 'me' ,
xPubKey : aX PubKey,
xPubKeySignature : aX PubKeySignature,
xPubKey : TestData . copayers [ 0 ] . x PubKey,
xPubKeySignature : TestData . copayers [ 0 ] . x PubKeySignature,
} ;
server . joinWallet ( copayerOpts , function ( err , copayerId ) {
should . not . exist ( err ) ;
@ -655,8 +615,8 @@ describe('Copay server', function() {
var txOpts = {
toAddress : '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' ,
amount : helpers . toSatoshi ( 80 ) ,
proposalSignature : 'dummy' ,
} ;
helpers . addProposalSignature ( txOpts , copayerPriv [ 0 ] . privKey ) ;
server . createTx ( txOpts , function ( err , tx ) {
should . not . exist ( tx ) ;
err . should . exist ;
@ -674,8 +634,8 @@ describe('Copay server', function() {
var txOpts = {
toAddress : 'invalid address' ,
amount : helpers . toSatoshi ( 80 ) ,
proposalSignature : 'dummy' ,
} ;
helpers . addProposalSignature ( txOpts , copayerPriv [ 0 ] . privKey ) ;
server . createTx ( txOpts , function ( err , tx ) {
should . not . exist ( tx ) ;
@ -693,8 +653,8 @@ describe('Copay server', function() {
var txOpts = {
toAddress : 'myE38JHdxmQcTJGP1ZiX4BiGhDxMJDvLJD' , // testnet
amount : helpers . toSatoshi ( 80 ) ,
proposalSignature : 'dummy' ,
} ;
helpers . addProposalSignature ( txOpts , copayerPriv [ 0 ] . privKey ) ;
server . createTx ( txOpts , function ( err , tx ) {
should . not . exist ( tx ) ;
@ -712,8 +672,8 @@ describe('Copay server', function() {
var txOpts = {
toAddress : '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' ,
amount : helpers . toSatoshi ( 120 ) ,
proposalSignature : 'dummy' ,
} ;
helpers . addProposalSignature ( txOpts , copayerPriv [ 0 ] . privKey ) ;
server . createTx ( txOpts , function ( err , tx ) {
err . code . should . equal ( 'INSUFFICIENTFUNDS' ) ;
@ -742,8 +702,8 @@ describe('Copay server', function() {
var txOpts = {
toAddress : '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' ,
amount : helpers . toSatoshi ( 12 ) ,
proposalSignature : 'dummy' ,
} ;
helpers . addProposalSignature ( txOpts , copayerPriv [ 0 ] . privKey ) ;
server . createTx ( txOpts , function ( err , tx ) {
should . not . exist ( err ) ;
tx . should . exist ;
@ -751,8 +711,8 @@ describe('Copay server', function() {
var txOpts2 = {
toAddress : '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' ,
amount : 8 ,
proposalSignature : 'dummy' ,
} ;
helpers . addProposalSignature ( txOpts2 , copayerPriv [ 0 ] . privKey ) ;
server . createTx ( txOpts2 , function ( err , tx ) {
should . not . exist ( err ) ;
tx . should . exist ;
@ -777,8 +737,8 @@ describe('Copay server', function() {
var txOpts = {
toAddress : '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' ,
amount : helpers . toSatoshi ( 12 ) ,
proposalSignature : 'dummy' ,
} ;
helpers . addProposalSignature ( txOpts , copayerPriv [ 0 ] . privKey ) ;
server . createTx ( txOpts , function ( err , tx ) {
should . not . exist ( err ) ;
tx . should . exist ;
@ -786,8 +746,8 @@ describe('Copay server', function() {
var txOpts2 = {
toAddress : '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' ,
amount : helpers . toSatoshi ( 24 ) ,
proposalSignature : 'dummy' ,
} ;
helpers . addProposalSignature ( txOpts2 , copayerPriv [ 0 ] . privKey ) ;
server . createTx ( txOpts2 , function ( err , tx ) {
err . code . should . equal ( 'INSUFFICIENTFUNDS' ) ;
err . message . should . equal ( 'Insufficient funds' ) ;
@ -821,8 +781,8 @@ describe('Copay server', function() {
var txOpts = {
toAddress : '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' ,
amount : helpers . toSatoshi ( 80 ) ,
proposalSignature : 'dummy' ,
} ;
helpers . addProposalSignature ( txOpts , copayerPriv [ 0 ] . privKey ) ;
async . map ( _ . range ( N ) , function ( i , cb ) {
server . createTx ( txOpts , function ( err , tx ) {
cb ( err , tx ) ;
@ -846,20 +806,21 @@ describe('Copay server', function() {
} ) ;
describe ( '#signTx' , function ( ) {
var server , wallet , txid ;
var server , wallet , copayerPriv , txid ;
beforeEach ( function ( done ) {
helpers . createAndJoinWallet ( 2 , 2 , function ( s , w ) {
helpers . createAndJoinWallet ( 2 , 2 , function ( s , w , c ) {
server = s ;
wallet = w ;
copayerPriv = c ;
server . createAddress ( { } , function ( err , address ) {
helpers . createUtxos ( server , wallet , helpers . toSatoshi ( [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ] ) , function ( utxos ) {
helpers . stubBlockExplorer ( server , utxos ) ;
var txOpts = {
toAddress : '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' ,
amount : helpers . toSatoshi ( 10 ) ,
proposalSignature : 'dummy' ,
} ;
helpers . addProposalSignature ( txOpts , copayerPriv [ 0 ] . privKey ) ;
server . createTx ( txOpts , function ( err , tx ) {
should . not . exist ( err ) ;
tx . should . exist ;
@ -876,7 +837,7 @@ describe('Copay server', function() {
var tx = txs [ 0 ] ;
tx . id . should . equal ( txid ) ;
var signatures = helpers . clientSign ( tx , someXPrivKey [ 0 ] , wallet . n ) ;
var signatures = helpers . clientSign ( tx , TestData . copayers [ 0 ] . xPrivKey , wallet . n ) ;
server . signTx ( {
txProposalId : txid ,
signatures : signatures ,
@ -892,7 +853,7 @@ describe('Copay server', function() {
var tx = txs [ 0 ] ;
tx . id . should . equal ( txid ) ;
var signatures = helpers . clientSign ( tx , someXPrivKey [ 0 ] , wallet . n ) ;
var signatures = helpers . clientSign ( tx , TestData . copayers [ 0 ] . xPrivKey , wallet . n ) ;
signatures [ 0 ] = 1 ;
server . signTx ( {
@ -923,11 +884,12 @@ describe('Copay server', function() {
describe ( '#signTx and broadcast' , function ( ) {
var server , wallet , utxos ;
var server , wallet , copayerPriv , utxos ;
beforeEach ( function ( done ) {
helpers . createAndJoinWallet ( 1 , 1 , function ( s , w ) {
helpers . createAndJoinWallet ( 1 , 1 , function ( s , w , c ) {
server = s ;
wallet = w ;
copayerPriv = c ;
server . createAddress ( { } , function ( err , address ) {
helpers . createUtxos ( server , wallet , helpers . toSatoshi ( [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ] ) , function ( inutxos ) {
utxos = inutxos ;
@ -943,6 +905,7 @@ describe('Copay server', function() {
toAddress : '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' ,
amount : helpers . toSatoshi ( 10 ) ,
} ;
helpers . addProposalSignature ( txOpts , copayerPriv [ 0 ] . privKey ) ;
server . createTx ( txOpts , function ( err , txp ) {
should . not . exist ( err ) ;
txp . should . exist ;
@ -951,7 +914,7 @@ describe('Copay server', function() {
server . getPendingTxs ( { } , function ( err , txps ) {
var txp = txps [ 0 ] ;
txp . id . should . equal ( txpid ) ;
var signatures = helpers . clientSign ( txp , someXPrivKey [ 0 ] , wallet . n ) ;
var signatures = helpers . clientSign ( txp , TestData . copayers [ 0 ] . xPrivKey , wallet . n ) ;
server . signTx ( {
txProposalId : txpid ,
signatures : signatures ,
@ -972,6 +935,7 @@ describe('Copay server', function() {
toAddress : '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' ,
amount : helpers . toSatoshi ( 10 ) ,
} ;
helpers . addProposalSignature ( txOpts , copayerPriv [ 0 ] . privKey ) ;
server . createTx ( txOpts , function ( err , txp ) {
should . not . exist ( err ) ;
txp . should . exist ;
@ -980,7 +944,7 @@ describe('Copay server', function() {
server . getPendingTxs ( { } , function ( err , txps ) {
var txp = txps [ 0 ] ;
txp . id . should . equal ( txpid ) ;
var signatures = helpers . clientSign ( txp , someXPrivKey [ 0 ] , wallet . n ) ;
var signatures = helpers . clientSign ( txp , TestData . copayers [ 0 ] . xPrivKey , wallet . n ) ;
server . signTx ( {
txProposalId : txpid ,
signatures : signatures ,
@ -1002,11 +966,12 @@ describe('Copay server', function() {
} ) ;
describe ( 'Tx proposal workflow' , function ( ) {
var server , wallet , utxos ;
var server , wallet , copayerPriv , utxos ;
beforeEach ( function ( done ) {
helpers . createAndJoinWallet ( 2 , 3 , function ( s , w ) {
helpers . createAndJoinWallet ( 2 , 3 , function ( s , w , c ) {
server = s ;
wallet = w ;
copayerPriv = c ;
server . createAddress ( { } , function ( err , address ) {
helpers . createUtxos ( server , wallet , helpers . toSatoshi ( [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ] ) , function ( inutxos ) {
utxos = inutxos ;
@ -1022,8 +987,8 @@ describe('Copay server', function() {
toAddress : '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' ,
amount : helpers . toSatoshi ( 10 ) ,
message : 'some message' ,
proposalSignature : 'dummy' ,
} ;
helpers . addProposalSignature ( txOpts , copayerPriv [ 0 ] . privKey ) ;
server . createTx ( txOpts , function ( err , txp ) {
should . not . exist ( err ) ;
should . exist . txp ;
@ -1049,7 +1014,7 @@ describe('Copay server', function() {
} ) ;
describe ( '#getTxs' , function ( ) {
var server , wallet , clock ;
var server , wallet , copayerPriv , c lock ;
beforeEach ( function ( done ) {
if ( server )
@ -1058,9 +1023,10 @@ describe('Copay server', function() {
this . timeout ( 5000 ) ;
console . log ( '\tCreating TXS...' ) ;
clock = sinon . useFakeTimers ( ) ;
helpers . createAndJoinWallet ( 1 , 1 , function ( s , w ) {
helpers . createAndJoinWallet ( 1 , 1 , function ( s , w , c ) {
server = s ;
wallet = w ;
copayerPriv = c ;
server . createAddress ( { } , function ( err , address ) {
helpers . createUtxos ( server , wallet , helpers . toSatoshi ( _ . range ( 10 ) ) , function ( utxos ) {
helpers . stubBlockExplorer ( server , utxos ) ;
@ -1068,6 +1034,7 @@ describe('Copay server', function() {
toAddress : '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7' ,
amount : helpers . toSatoshi ( 0.1 ) ,
} ;
helpers . addProposalSignature ( txOpts , copayerPriv [ 0 ] . privKey ) ;
async . eachSeries ( _ . range ( 10 ) , function ( i , next ) {
clock . tick ( 10000 ) ;
server . createTx ( txOpts , function ( err , tx ) {