{"action":"created","issue":{"url":"https://api.github.com/repos/bitcoinjs/bitcoinjs-lib/issues/1022","repository_url":"https://api.github.com/repos/bitcoinjs/bitcoinjs-lib","labels_url":"https://api.github.com/repos/bitcoinjs/bitcoinjs-lib/issues/1022/labels{/name}","comments_url":"https://api.github.com/repos/bitcoinjs/bitcoinjs-lib/issues/1022/comments","events_url":"https://api.github.com/repos/bitcoinjs/bitcoinjs-lib/issues/1022/events","html_url":"https://github.com/bitcoinjs/bitcoinjs-lib/issues/1022","id":306528857,"number":1022,"title":"RawTransaction send return mandatory-script-verify-flag-failed (Non-canonical DER signature)","user":{"login":"Vutov","id":9143601,"avatar_url":"https://avatars1.githubusercontent.com/u/9143601?v=4","gravatar_id":"","url":"https://api.github.com/users/Vutov","html_url":"https://github.com/Vutov","followers_url":"https://api.github.com/users/Vutov/followers","following_url":"https://api.github.com/users/Vutov/following{/other_user}","gists_url":"https://api.github.com/users/Vutov/gists{/gist_id}","starred_url":"https://api.github.com/users/Vutov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Vutov/subscriptions","organizations_url":"https://api.github.com/users/Vutov/orgs","repos_url":"https://api.github.com/users/Vutov/repos","events_url":"https://api.github.com/users/Vutov/events{/privacy}","received_events_url":"https://api.github.com/users/Vutov/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-03-19T16:10:19Z","updated_at":"2018-03-19T18:48:25Z","closed_at":null,"author_association":"NONE","body":"I'm using bitcoinjs-lib 3.3.2 and running 2 bitcoin-qt nodes 0.16 on -regtest . I have tried to sign transaction using bitcoinjs and run it in bitcoin-qt console with sendrawtransaction but receive \"16: mandatory-script-verify-flag-failed (Non-canonical DER signature) (code -26)\"\r\n\r\nThere is unspent transaction : \r\n```\r\n{\r\n    \"txid\": \"77d0b6383f93b528333b0f0bd68aab33a3d08cdd05c50e258a7b775d7bfd2527\",\r\n    \"vout\": 0,\r\n    \"address\": \"mhZ1A3Cyqg9XQnRpmYkqjdTzL8yTaBpFf2\",\r\n    \"scriptPubKey\": \"21039a0c9cb7c374df809965e4cfeb109ee0e1c7f3a0ee4b4f0cea04eebf25a27ee7ac\",\r\n    \"amount\": 50.00000000,\r\n    \"confirmations\": 101,\r\n    \"spendable\": true,\r\n    \"solvable\": true,\r\n    \"safe\": true\r\n  }\r\n```\r\n\r\nI use dumpprivkey to get fromWIF value and getnewaccount for the receiver account\r\n\r\nThe code I'm using:\r\n\r\n```\r\nvar testnet = bitcoin.networks.testnet\r\nvar value = 50 * 10e7 - 10000;\r\nvar key = bitcoin.ECPair.fromWIF(\"cMrFVDpeP3wvmNRpHLerhtwPY1mwHN3BTYCV1vNtP4zSvvZm11KN\", testnet);\r\nvar tx = new bitcoin.TransactionBuilder(testnet);\r\ntx.addInput(\"77d0b6383f93b528333b0f0bd68aab33a3d08cdd05c50e258a7b775d7bfd2527\", 0);\r\ntx.addOutput(\"2N9W57WJHgh8Yiev6s5he1Qn99DkZyKSkYg\", value);\r\ntx.sign(0, key);\r\nconsole.log(tx.build().toHex());\r\n```\r\n\r\nIve tried with sigwit as well - same result:\r\n```\r\nvar keyPair = bitcoin.ECPair.fromWIF('cPzku2sUaQacgoKNjmS3FZtVrFxB4JtHFiS8y44g9Dr4rMMNn9Di', testnet)\r\nvar pubKey = keyPair.getPublicKeyBuffer()\r\nvar pubKeyHash = bitcoin.crypto.hash160(pubKey)\r\n\r\nvar redeemScript = bitcoin.script.witnessPubKeyHash.output.encode(pubKeyHash)\r\nvar redeemScriptHash = bitcoin.crypto.hash160(redeemScript)\r\n\r\nvar scriptPubKey = bitcoin.script.scriptHash.output.encode(redeemScriptHash)\r\nvar address = bitcoin.address.fromOutputScript(scriptPubKey, testnet)\r\n\r\nvar txb = new bitcoin.TransactionBuilder(testnet)\r\ntxb.addInput(\"77d0b6383f93b528333b0f0bd68aab33a3d08cdd05c50e258a7b775d7bfd2527\", 0);\r\ntxb.addOutput(\"2MxSE48F9ZgsTghEgNjzNEDZoZbQnR4fcfh\", value);\r\ntxb.sign(0, keyPair, redeemScript, null, value)\r\n\r\nconsole.log(txb.build().toHex());\r\n```\r\n\r\nAny advice would be greatly appriciated\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/bitcoinjs/bitcoinjs-lib/issues/comments/374323872","html_url":"https://github.com/bitcoinjs/bitcoinjs-lib/issues/1022#issuecomment-374323872","issue_url":"https://api.github.com/repos/bitcoinjs/bitcoinjs-lib/issues/1022","id":374323872,"user":{"login":"afk11","id":5617245,"avatar_url":"https://avatars3.githubusercontent.com/u/5617245?v=4","gravatar_id":"","url":"https://api.github.com/users/afk11","html_url":"https://github.com/afk11","followers_url":"https://api.github.com/users/afk11/followers","following_url":"https://api.github.com/users/afk11/following{/other_user}","gists_url":"https://api.github.com/users/afk11/gists{/gist_id}","starred_url":"https://api.github.com/users/afk11/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/afk11/subscriptions","organizations_url":"https://api.github.com/users/afk11/orgs","repos_url":"https://api.github.com/users/afk11/repos","events_url":"https://api.github.com/users/afk11/events{/privacy}","received_events_url":"https://api.github.com/users/afk11/received_events","type":"User","site_admin":false},"created_at":"2018-03-19T18:48:25Z","updated_at":"2018-03-19T18:48:25Z","author_association":"MEMBER","body":"Could you paste the fully signed transaction?"}}
{"actor":{"display_login":"afk11"}}