{"action":"created","issue":{"url":"https://api.github.com/repos/stellar/js-stellar-base/issues/27","labels_url":"https://api.github.com/repos/stellar/js-stellar-base/issues/27/labels{/name}","comments_url":"https://api.github.com/repos/stellar/js-stellar-base/issues/27/comments","events_url":"https://api.github.com/repos/stellar/js-stellar-base/issues/27/events","html_url":"https://github.com/stellar/js-stellar-base/issues/27","id":103645670,"number":27,"title":"Problem signing transactions with sign()","user":{"login":"dydt","id":305198,"avatar_url":"https://avatars.githubusercontent.com/u/305198?v=3","gravatar_id":"","url":"https://api.github.com/users/dydt","html_url":"https://github.com/dydt","followers_url":"https://api.github.com/users/dydt/followers","following_url":"https://api.github.com/users/dydt/following{/other_user}","gists_url":"https://api.github.com/users/dydt/gists{/gist_id}","starred_url":"https://api.github.com/users/dydt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dydt/subscriptions","organizations_url":"https://api.github.com/users/dydt/orgs","repos_url":"https://api.github.com/users/dydt/repos","events_url":"https://api.github.com/users/dydt/events{/privacy}","received_events_url":"https://api.github.com/users/dydt/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-08-28T04:36:54Z","updated_at":"2015-08-28T09:31:41Z","closed_at":"2015-08-28T09:31:41Z","body":"If I try to sign a transaction outside of the `TransactionBuilder`, it fails.  That is, this code:\r\n\r\n```\r\nvar money_account = new StellarLib.Account(\"GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ\", 27);\r\nvar transaction = new StellarLib.TransactionBuilder(money_account)\r\n    .addOperation(StellarLib.Operation.payment({\r\n      destination: \"GASOCNHNNLYFNMDJYQ3XFMI7BYHIOCFW3GJEOWRPEGK2TDPGTG2E5EDW\",\r\n      asset: StellarLib.Asset.native(),\r\n      amount: \"40000000\"\r\n    }))\r\n    // .addSigner(StellarLib.Keypair.fromSeed(rootSeedString))\r\n    .build();\r\nvar signer = StellarLib.Keypair.fromSeed(rootSeedString);\r\ntransaction.sign([signer]);\r\nserver.submitTransaction(transaction)\r\n  .catch(function (err){\r\n    console.log(err);\r\n  });\r\n```\r\n\r\nfailed with this error:\r\n```\r\ndydt:workspace diyang$ node client_endpoints_examples.js \r\n\r\n/Users/diyang/workspace/js-stellar-lib/node_modules/stellar-base/lib/transaction.js:82\r\n                    var sig = kp.signDecorated(txHash);\r\n                                 ^\r\nTypeError: Object [object Object] has no method 'signDecorated'\r\n    at /Users/diyang/workspace/js-stellar-lib/node_modules/stellar-base/lib/transaction.js:82:34\r\n    at arrayEach (/Users/diyang/workspace/js-stellar-lib/node_modules/lodash/index.js:1289:13)\r\n    at /Users/diyang/workspace/js-stellar-lib/node_modules/lodash/index.js:3345:13\r\n    at Transaction.sign (/Users/diyang/workspace/js-stellar-lib/node_modules/stellar-base/lib/transaction.js:81:31)\r\n    at Object.<anonymous> (/Users/diyang/workspace/client_endpoints_examples.js:158:13)\r\n    ...\r\n```\r\n\r\nBut this:\r\n```\r\nvar money_account = new StellarLib.Account(\"GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ\", 26);\r\nvar transaction = new StellarLib.TransactionBuilder(money_account)\r\n    .addOperation(StellarLib.Operation.payment({\r\n      destination: \"GASOCNHNNLYFNMDJYQ3XFMI7BYHIOCFW3GJEOWRPEGK2TDPGTG2E5EDW\",\r\n      asset: StellarLib.Asset.native(),\r\n      amount: \"40000000\"\r\n    }))\r\n    .addSigner(StellarLib.Keypair.fromSeed(rootSeedString))\r\n    .build();\r\n// var signer = StellarLib.Keypair.fromSeed(rootSeedString);\r\n// transaction.sign([signer]);\r\nserver.submitTransaction(transaction)\r\n  .catch(function (err){\r\n    console.log(err);\r\n  });\r\n``` \r\n\r\nsucceeded.\r\n"},"comment":{"url":"https://api.github.com/repos/stellar/js-stellar-base/issues/comments/135713198","html_url":"https://github.com/stellar/js-stellar-base/issues/27#issuecomment-135713198","issue_url":"https://api.github.com/repos/stellar/js-stellar-base/issues/27","id":135713198,"user":{"login":"bartekn","id":464938,"avatar_url":"https://avatars.githubusercontent.com/u/464938?v=3","gravatar_id":"","url":"https://api.github.com/users/bartekn","html_url":"https://github.com/bartekn","followers_url":"https://api.github.com/users/bartekn/followers","following_url":"https://api.github.com/users/bartekn/following{/other_user}","gists_url":"https://api.github.com/users/bartekn/gists{/gist_id}","starred_url":"https://api.github.com/users/bartekn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bartekn/subscriptions","organizations_url":"https://api.github.com/users/bartekn/orgs","repos_url":"https://api.github.com/users/bartekn/repos","events_url":"https://api.github.com/users/bartekn/events{/privacy}","received_events_url":"https://api.github.com/users/bartekn/received_events","type":"User","site_admin":false},"created_at":"2015-08-28T09:31:41Z","updated_at":"2015-08-28T09:31:41Z","body":"It should be:\r\n```js\r\ntransaction.sign(signer);\r\n```\r\nLet's say you have 2 signers:\r\n```js\r\ntransaction.sign(signer1, signer2);\r\n```\r\nAnd in case you have an array of signers:\r\n```js\r\ntransaction.sign(...arrayOfSigners);\r\n```\r\nMore info [here](https://github.com/lukehoban/es6features#default--rest--spread)."}}