Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isFullySigned fails on signed transaction #1212

Closed
levino opened this issue May 8, 2015 · 4 comments
Closed

isFullySigned fails on signed transaction #1212

levino opened this issue May 8, 2015 · 4 comments

Comments

@levino
Copy link

levino commented May 8, 2015

Please run the following example to reproduce the error.

var Bitcore = require('bitcore');

var privateKey1 = new Bitcore.PrivateKey({"bn":"99f5083ac9df397dc4ab1c385b8da2f5f1fbdf9522444762e724c3616bb18b0e","compressed":true,"network":"testnet"});
var privateKey2 = new Bitcore.PrivateKey({"bn":"53293d59daf73c95c5a688f5c647a9af9de58a6bec78eb938e4e17f607991808","compressed":true,"network":"testnet"});

var transaction1 = new Bitcore.Transaction({
    "version": 1,
    "inputs": [
        {
            "prevTxId": "0fec8b4636a00304e0dbbbcf21149623eca628bd08e025484871525d6ecc24e4",
            "outputIndex": 1,
            "sequenceNumber": 4294967295,
            "script": "",
            "scriptString": "",
            "output": {
                "satoshis": 74255886,
                "script": "OP_DUP OP_HASH160 20 0xb8189c6889aa0bb8cfd0d2b9b9b0cbdaf60906dc OP_EQUALVERIFY OP_CHECKSIG"
            }
        },
        {
            "prevTxId": "9e93f8ca08841c37d102d74767ba2976c8cd3f5900789494efae6184a74b3386",
            "outputIndex": 1,
            "sequenceNumber": 4294967295,
            "script": "",
            "scriptString": "",
            "output": {
                "satoshis": 80000,
                "script": "OP_DUP OP_HASH160 20 0xb8189c6889aa0bb8cfd0d2b9b9b0cbdaf60906dc OP_EQUALVERIFY OP_CHECKSIG"
            }
        }
    ],
    "outputs": [
        {
            "satoshis": 110000,
            "script": "OP_HASH160 20 0x677f61cb0cbce67a097f08d6129ddff4bb9cfb62 OP_EQUAL"
        },
        {
            "satoshis": 74215886,
            "script": "OP_DUP OP_HASH160 20 0xb8189c6889aa0bb8cfd0d2b9b9b0cbdaf60906dc OP_EQUALVERIFY OP_CHECKSIG"
        }
    ],
    "nLockTime": 0
});

var transaction2 = new Bitcore.Transaction({
    "version": 1,
    "inputs": [
        {
            "prevTxId": "737b57698ab31de2c2055bca1867fe80db1d7f3f5910b3d70d99edcb90ffcf9a",
            "outputIndex": 1,
            "sequenceNumber": 4294967295,
            "script": "",
            "scriptString": "",
            "output": {
                "satoshis": 3549991,
                "script": "OP_DUP OP_HASH160 20 0x987a6dd86d8ff7b2e92edbef1bf10ecd08ff126e OP_EQUALVERIFY OP_CHECKSIG"
            }
        }
    ],
    "outputs": [
        {
            "satoshis": 110000,
            "script": "OP_HASH160 20 0x0f8983527d5a98a4954ecd56e255696e06d0f9b1 OP_EQUAL"
        },
        {
            "satoshis": 3429991,
            "script": "OP_DUP OP_HASH160 20 0x987a6dd86d8ff7b2e92edbef1bf10ecd08ff126e OP_EQUALVERIFY OP_CHECKSIG"
        }
    ],
    "nLockTime": 0
});

console.log('Transaction 1 verify:', transaction1.verify() );
console.log('Transaction 2 verify:', transaction2.verify() );
transaction1.sign(privateKey1);
transaction2.sign(privateKey2);
console.log('Private Key 1 Address:', privateKey1.toAddress().toString() );
console.log('Private Key 2 Address:', privateKey2.toAddress().toString() );
console.log('Transaction 1 fully signed:', transaction1.isFullySigned());
console.log('Transaction 2 fully signed:', transaction2.isFullySigned());
console.log('Transaction 1 as String:', transaction1.toString());
console.log('Transaction 2 as String:', transaction2.toString());

Transaction 2 should be signable by key 2 but the transaction does not get signed.

You can verify that the input is coming from "Address 2" by pasting the String of Transaction 2 for example here: https://live.blockcypher.com/btc-testnet/decodetx/

What am I missing?

@levino
Copy link
Author

levino commented May 8, 2015

@meinharrd Interesting for you.

@braydonf
Copy link
Contributor

braydonf commented May 8, 2015

BTW, you can also get the address for a script with new bitcore.Script('..').toAddress()

Transaction 2 does look like it's being signed, however isFullySigned is returning false.

@levino levino changed the title Signature fails without error isFullySigned fails on signed transaction May 8, 2015
@levino
Copy link
Author

levino commented May 8, 2015

@braydonf You are right, thanks. Changed the title to describe the actual error better.

I think it does not hurt to check with a second source (code), that is why i used blockcypher

@braydonf
Copy link
Contributor

braydonf commented May 9, 2015

This should be fixed with: #1213

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants