Skip to content

Add witness option to input-set command. #644

Open

Description

@praveenbm5

I am able to generate signatures using input-sign for a segwit transaction created using bitcoin-cli

HEX: 0200000001a7be5c74cb963c426e295a3f145bf397d8d7c12711bbb2bb6dcb318a505465de0000000000ffffffff01c0e4022a0100000017a9140a37ed6a88d66dc102bde8a6a299b44c81daa7178700000000

{
  "txid": "9a79c646e3105742b815d14f107c61e5d067c271c41dc246e925351bfa529b15",
  "hash": "9a79c646e3105742b815d14f107c61e5d067c271c41dc246e925351bfa529b15",
  "version": 2,
  "size": 83,
  "vsize": 83,
  "weight": 332,
  "locktime": 0,
  "vin": [
    {
      "txid": "de6554508a31cb6dbbb2bb1127c1d7d897f35b143f5a296e423c96cb745cbea7",
      "vout": 0,
      "scriptSig": {
        "asm": "",
        "hex": ""
      },
      "sequence": 4294967295
    }
  ],
  "vout": [
    {
      "value": 49.99800000,
      "n": 0,
      "scriptPubKey": {
        "asm": "OP_HASH160 0a37ed6a88d66dc102bde8a6a299b44c81daa717 OP_EQUAL",
        "hex": "a9140a37ed6a88d66dc102bde8a6a299b44c81daa71787",
        "reqSigs": 1,
        "type": "scripthash",
        "addresses": [
          "2MtBFk78tB3awCMREc2KBy93WAUT9ZxGc2Y"
        ]
      }
    }
  ]
}

But not able to add them in a segwit compatible way using input-set. This is what I am getting after constructing and adding the endorsement script which does not look like a segwit transaction.

{
  "txid": "26c5f52031ef5d52c0ad80b79b6c77ac002101a68472a33f235b7b9223756901",
  "hash": "26c5f52031ef5d52c0ad80b79b6c77ac002101a68472a33f235b7b9223756901",
  "version": 2,
  "size": 410,
  "vsize": 410,
  "weight": 1640,
  "locktime": 0,
  "vin": [
    {
      "txid": "de6554508a31cb6dbbb2bb1127c1d7d897f35b143f5a296e423c96cb745cbea7",
      "vout": 0,
      "scriptSig": {
        "asm": "0 30440220031b6c1d27081b2bcca3fff39f58680571e831b25df8758aa579cca00cdc26b9022063d3ace4c054418a17fae96d55a9b52cefbf2f6518cbab99a051f87cecf1c3ca[ALL] 304402206cf1e786996efbc8a7f2d91ad6d3d4d7b005ba38e98af2e2c6b08b5eb75388d40220478aeac95e98999d11b559ec07ee68e5664b95ecbfedad6f63165c983497cd0a[ALL] 3045022100e7388fb90144c31f0a2a24c5dc81104a9f199781db9713f591140a108dc7ae5a02201b8a70e7eddc0c6c513044b453f0bd0e67c80e6866e21a95e1f216696ba17393[ALL] 532103cb7ef39e4bf4e487f73dd8c0ac6f0ef112a6ac7b3fa09546007121605bfa7c7b21032aa651b6e0064cf4ddc0230e5cf37496d32e7970e9221f0d16d7afefd2be245121023320c921fb86d276cf996c97a3f3893e5da2c03926acd1d5160d0ccdb582f41653ae",
        "hex": "004730440220031b6c1d27081b2bcca3fff39f58680571e831b25df8758aa579cca00cdc26b9022063d3ace4c054418a17fae96d55a9b52cefbf2f6518cbab99a051f87cecf1c3ca0147304402206cf1e786996efbc8a7f2d91ad6d3d4d7b005ba38e98af2e2c6b08b5eb75388d40220478aeac95e98999d11b559ec07ee68e5664b95ecbfedad6f63165c983497cd0a01483045022100e7388fb90144c31f0a2a24c5dc81104a9f199781db9713f591140a108dc7ae5a02201b8a70e7eddc0c6c513044b453f0bd0e67c80e6866e21a95e1f216696ba17393014c69532103cb7ef39e4bf4e487f73dd8c0ac6f0ef112a6ac7b3fa09546007121605bfa7c7b21032aa651b6e0064cf4ddc0230e5cf37496d32e7970e9221f0d16d7afefd2be245121023320c921fb86d276cf996c97a3f3893e5da2c03926acd1d5160d0ccdb582f41653ae"
      },
      "sequence": 4294967295
    }
  ],
  "vout": [
    {
      "value": 49.99800000,
      "n": 0,
      "scriptPubKey": {
        "asm": "OP_HASH160 0a37ed6a88d66dc102bde8a6a299b44c81daa717 OP_EQUAL",
        "hex": "a9140a37ed6a88d66dc102bde8a6a299b44c81daa71787",
        "reqSigs": 1,
        "type": "scripthash",
        "addresses": [
          "2MtBFk78tB3awCMREc2KBy93WAUT9ZxGc2Y"
        ]
      }
    }
  ]
}

Is it even supported? I built bx by checking out the master branch today.

Activity

  1. evoskuil commented on Oct 25, 2019

    @evoskuil
    Member

    Original tx:

    $ bx tx-decode 0200000001a7be5c74cb963c426e295a3f145bf397d8d7c12711bbb2bb6dcb318a505465de0000000000ffffffff01c0e4022a0100000017a9140a37ed6a88d66dc102bde8a6a299b44c81daa7178700000000
    
    transaction
    {
        hash 9a79c646e3105742b815d14f107c61e5d067c271c41dc246e925351bfa529b15
        inputs
        {
            input
            {
                previous_output
                {
                    hash de6554508a31cb6dbbb2bb1127c1d7d897f35b143f5a296e423c96cb745cbea7
                    index 0
                }
                script ""
                sequence 4294967295
            }
        }
        lock_time 0
        outputs
        {
            output
            {
                address_hash 0a37ed6a88d66dc102bde8a6a299b44c81daa717
                script "hash160 [0a37ed6a88d66dc102bde8a6a299b44c81daa717] equal"
                value 4999800000
            }
        }
        version 2
    }
    
  2. evoskuil commented on Oct 25, 2019

    @evoskuil
    Member

    Desired script:

    $ bx script-decode 004730440220031b6c1d27081b2bcca3fff39f58680571e831b25df8758aa579cca00cdc26b9022063d3ace4c054418a17fae96d55a9b52cefbf2f6518cbab99a051f87cecf1c3ca0147304402206cf1e786996efbc8a7f2d91ad6d3d4d7b005ba38e98af2e2c6b08b5eb75388d40220478aeac95e98999d11b559ec07ee68e5664b95ecbfedad6f63165c983497cd0a01483045022100e7388fb90144c31f0a2a24c5dc81104a9f199781db9713f591140a108dc7ae5a02201b8a70e7eddc0c6c513044b453f0bd0e67c80e6866e21a95e1f216696ba17393014c69532103cb7ef39e4bf4e487f73dd8c0ac6f0ef112a6ac7b3fa09546007121605bfa7c7b21032aa651b6e0064cf4ddc0230e5cf37496d32e7970e9221f0d16d7afefd2be245121023320c921fb86d276cf996c97a3f3893e5da2c03926acd1d5160d0ccdb582f41653ae
    
    zero [30440220031b6c1d27081b2bcca3fff39f58680571e831b25df8758aa579cca00cdc26b9022063d3ace4c054418a17fae96d55a9b52cefbf2f6518cbab99a051f87cecf1c3ca01] [304402206cf1e786996efbc8a7f2d91ad6d3d4d7b005ba38e98af2e2c6b08b5eb75388d40220478aeac95e98999d11b559ec07ee68e5664b95ecbfedad6f63165c983497cd0a01] [3045022100e7388fb90144c31f0a2a24c5dc81104a9f199781db9713f591140a108dc7ae5a02201b8a70e7eddc0c6c513044b453f0bd0e67c80e6866e21a95e1f216696ba1739301] [532103cb7ef39e4bf4e487f73dd8c0ac6f0ef112a6ac7b3fa09546007121605bfa7c7b21032aa651b6e0064cf4ddc0230e5cf37496d32e7970e9221f0d16d7afefd2be245121023320c921fb86d276cf996c97a3f3893e5da2c03926acd1d5160d0ccdb582f41653ae]
    
  3. evoskuil commented on Oct 25, 2019

    @evoskuil
    Member

    Explorer's input-set command only adds the script to the input, which appears to be happening as designed. There is not yet support for adding the witness via input-set, which is all that is required to produce the desired serialization.

  4. added this to the 4.0 milestone on Oct 25, 2019
  5. changed the title [-]Segwit Compatability[/-] [+]Add witness option to input-set command.[/+] on Oct 25, 2019
  6. evoskuil commented on Oct 25, 2019

    @evoskuil
    Member

    The multi-token nature of the input-set ENDORSEMENT_SCRIPT parameter complicates backward compatible extension of the command, as it cannot be added cleanly as a colon-delimited portion of the script (e.g. as in tx-encode). As an additional parameter it must be required (not backward compatible) and as an option it's a little clunky, but it would appear that an additional --witness (-w) option is most appropriate.

  7. evoskuil commented on Oct 25, 2019

    @evoskuil
    Member

    For consistency the witness should be provided unencoded, as a set of bracketed data tokens (without prefix). This is the canonical textual serialization provided by system::chain::witness.

  8. praveenbm5 commented on Oct 26, 2019

    @praveenbm5
    Author

    Thank you for looking into this issue and taking it up as an enhancement.

    --witness (-w) is the cleanest way as far as I can see too.

    Lack of this feature in bx is a deal breaker for people relying on bx and still wanting to try Segwit and second level protocols that are now possible.

    I understand you are pushing it as an enhancement for next release and 4.0 has a lot of Segwit related enhancements as I can see. Any time line you are thinking of for this so that I can help test etc.

  9. praveenbm5 commented on Nov 19, 2019

    @praveenbm5
    Author

    I am waiting for this issue to be resolved and I also want to help with the development of such a useful tool.

    Adding a bounty :-)

    Anyone... please make this happen!

    /boss $1000

  10. praveenbm5 commented on Nov 19, 2019

    @praveenbm5
    Author

    I am not sure why this Bounty app is not working... sorry for posting multiple times...

    The promise holds good if this enhancement is committed in the next 7 days. I can do PayPal.

    Thank you for understanding.

  11. evoskuil commented on Nov 19, 2019

    @evoskuil
    Member

    I thought it was 1000 sats :). I am tempted to raise a little money for the Libbitcoin Institute. Maybe tonight when I finish up with taproot signature hashing, unless someone else wants to take it.

  12. praveenbm5 commented on Nov 19, 2019

    @praveenbm5
    Author

    Also... do we need any changes to bx input-sign to generate segwit compatible signatures...

    As far as I know and understanding, no changes are required but some one more knowledgeable in this can clarify please...

  13. praveenbm5 commented on Nov 22, 2019

    @praveenbm5
    Author

    Any updates? @evoskuil Eric are you attempting this enhancement?

  14. evoskuil commented on Nov 22, 2019

    @evoskuil
    Member

    Sorry, got a little sidetracked, and now I’m traveling for a few days. I decided to finish up taproot before taking on something new. Bu if nobody grabs this I’ll pick it up.

  15. j1warren commented on Jul 7, 2020

    @j1warren

    @evoskuil, hi, do you still have plans on implementing it sometimes?

    And if it's backlogged what is the best alternative to bx to generate segwit transactions currently?

  16. evoskuil commented on Jul 8, 2020

    @evoskuil
    Member

    Hi @j1warren - I’m not up on alternative tooling, sorry. It is definitely planned, and also a bit backlogged while I get my shit together, and while other contributors are busy making money.

  17. praveenbm5 commented on Oct 28, 2020

    @praveenbm5
    Author

    @evoskuil Hello Eric...

    Any updates on this enhancement?

  18. evoskuil commented on Oct 28, 2020

    @evoskuil
    Member

    No :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions