Skip to content

Conversation

@sipa
Copy link
Member

@sipa sipa commented Apr 25, 2018

Reported by arubi on IRC.

@laanwj
Copy link
Member

laanwj commented Apr 26, 2018

Needs a unit test, I think.

@laanwj laanwj added the Wallet label Apr 26, 2018
@maflcko
Copy link
Member

maflcko commented Apr 26, 2018

Yeah, a test makes sense for this function, since it is not particularly well covered: https://marcofalke.github.io/btc_cov/total.coverage/src/script/sign.cpp.gcov.html

@fivepiece
Copy link
Contributor

ACK on the fix!
Many thanks for looking into it :)

Before :

$ bitcoin-cli -regtest signrawtransactionwithwallet \
0200000001FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000044F024F9CFDFFFFFF01F0B9F505000000002321027777777777777777777777777777777777777777777777777777777777777777AC66030000 \
'[{"txid":"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF","vout":0,"scriptPubKey":"A914AE44AB6E9AA0B71F1CD2B453B69340E9BFBAEF6087","redeemScript":"4F9C","amount":1}]'

{                                                                                             VVVV
  "hex": "0200000001ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000050181024f9cfdffffff01f0b9f505000000002321027777777777777777777777777777777777777777777777777777777777777777ac66030000",
  "complete": false,
  "errors": [
    {
      "txid": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
      "vout": 0,
      "witness": [
      ],
      "scriptSig": "0181024f9c",
      "sequence": 4294967293,
      "error": "Data push larger than necessary"
    }
  ]
}

After:

$ bitcoin-cli -regtest signrawtransactionwithwallet \
0200000001FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000044F024F9CFDFFFFFF01F0B9F505000000002321027777777777777777777777777777777777777777777777777777777777777777AC66030000 \
'[{"txid":"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF","vout":0,"scriptPubKey":"A914AE44AB6E9AA0B71F1CD2B453B69340E9BFBAEF6087","redeemScript":"4F9C","amount":1}]' \

{                                                                                             VV
  "hex": "0200000001ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000044f024f9cfdffffff01f0b9f505000000002321027777777777777777777777777777777777777777777777777777777777777777ac66030000",
  "complete": true
}

@laanwj
Copy link
Member

laanwj commented Apr 27, 2018

Thanks for testing @fivepiece

@laanwj
Copy link
Member

laanwj commented May 7, 2018

It looks like there is a copy of this function in src/test/transaction_tests.cpp: static CScript PushAll(const std::vector<valtype>& values) used in ReplaceRedeemScript. Does this need update as well?

@fanquake
Copy link
Member

@sipa Would this be good to get into 0.17.0?

@DrahtBot DrahtBot closed this Jul 22, 2018
@DrahtBot DrahtBot reopened this Jul 22, 2018
@meshcollider
Copy link
Contributor

utACK 5af7625 but as @laanwj says, looks like transaction_tests.cpp also needs updating

@laanwj
Copy link
Member

laanwj commented Jan 9, 2019

looks like transaction_tests.cpp also needs updating

Can you please at least comment on this @sipa?
If the answer is no that's fine and this can be merged.

@DrahtBot DrahtBot closed this Apr 28, 2019
@DrahtBot
Copy link
Contributor

The last travis run for this pull request was 279 days ago and is thus outdated. To trigger a fresh travis build, this pull request should be closed and re-opened.

@meshcollider
Copy link
Contributor

meshcollider commented Oct 21, 2019

Re-opened in #17204

laanwj added a commit that referenced this pull request Aug 14, 2020
… in signing code (sipa)

dca2863 test: ensure OP_1NEGATE satisfies BIP62 minimal push rule (Jon Atack)
e629d07 Do not turn OP_1NEGATE in scriptSig into 0x0181 in signing code (Pieter Wuille)

Pull request description:

  A rebase of #13084 which additionally modifies the test code (unaddressed in the original, assuming sipa is too busy to deal with this at the moment).

  Relatively simple bugfix so it'd be good to have merged soon.

  Turning OP_1NEGATE into 0x0181 results in a larger-than-necessary data push instead of just actually using the OP_1NEGATE opcode (0x4f). This fails the minimal push rule of BIP 62 and makes the result non-standard.

ACKs for top commit:
  fjahr:
    Code review ACK dca2863
  luke-jr:
    ACK dca2863
  jonatack:
    ACK dca2863

Tree-SHA512: 706d9a2ef20c809dea923e477a873e2fd60db8d0ae64289e510b766a38005c1f31ab0b5883f16b9c7863ff0d3f705e8e413f6121320028ac196b79c3184a4113
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Aug 16, 2020
… 0x0181 in signing code (sipa)

dca2863 test: ensure OP_1NEGATE satisfies BIP62 minimal push rule (Jon Atack)
e629d07 Do not turn OP_1NEGATE in scriptSig into 0x0181 in signing code (Pieter Wuille)

Pull request description:

  A rebase of bitcoin#13084 which additionally modifies the test code (unaddressed in the original, assuming sipa is too busy to deal with this at the moment).

  Relatively simple bugfix so it'd be good to have merged soon.

  Turning OP_1NEGATE into 0x0181 results in a larger-than-necessary data push instead of just actually using the OP_1NEGATE opcode (0x4f). This fails the minimal push rule of BIP 62 and makes the result non-standard.

ACKs for top commit:
  fjahr:
    Code review ACK dca2863
  luke-jr:
    ACK dca2863
  jonatack:
    ACK dca2863

Tree-SHA512: 706d9a2ef20c809dea923e477a873e2fd60db8d0ae64289e510b766a38005c1f31ab0b5883f16b9c7863ff0d3f705e8e413f6121320028ac196b79c3184a4113
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants