Fix createrawtransaction multi op return - issue #14868 #14888

pull isghe wants to merge 5 commits into bitcoin:master from isghe:fix-createrawtransaction-multi-OP_RETURN changing 1 files +14 −10
  1. isghe commented at 6:22 PM on December 6, 2018: contributor
  2. fix-createrawtransaction issue 14868
    ```
    $ ./src/bitcoin-cli createrawtransaction "[]" "{\"data\":\"ee\", \"data\":\"ff\"}"
    0200000000020000000000000000036a01ee0000000000000000036a01ff00000000
    ```
    ```
    $ ./src/bitcoin-cli createrawtransaction "[]" "[{\"data\":\"ee\"}, {\"data\":\"ff\"}]"
    0200000000020000000000000000036a01ee0000000000000000036a01ff00000000
    ```
    
    https://github.com/bitcoin/bitcoin/issues/14868
    e53af5a6c9
  3. fix-createrawtransaction: const 1105ae8899
  4. fix-createrawtransaction: shared valStr 2fd66aa5a5
  5. fix-createrawtransaction:moved getKeys out of loop f80915c2c2
  6. fix-createrawtransaction: rename 'name_' to 'name' 8c65693c21
  7. gmaxwell commented at 7:07 PM on December 6, 2018: contributor

    NAK. Network IsStandard rules prohibit multiple op_returns (https://github.com/bitcoin/bitcoin/blob/master/src/policy/policy.cpp#L135), additional bloat on the blockchain is also not desired. The inputs to this RPC are also an array, so duplicating inputs is also pretty broken.

  8. isghe commented at 7:17 PM on December 6, 2018: contributor

    @gmaxwell so maybe we should raise an error? Because actually it's producing a strange thing

    bitcoin-cli createrawtransaction "[]" "{\"data\":\"ee\", \"data\":\"ff\"}"
    0200000000020000000000000000036a01ee0000000000000000036a01ee00000000
    
  9. fanquake added the label RPC/REST/ZMQ on Dec 6, 2018
  10. Empact commented at 9:08 PM on December 6, 2018: member

    @isghe you can help review by making your PR minimal:

    Patchsets should always be focused. For example, a pull request could add a feature, fix a bug, or refactor code; but not a mixture. https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#pull-request-philosophy

  11. DrahtBot commented at 9:34 PM on December 6, 2018: member

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #14890 (rpc: Avoid creating non-standard raw transactions by MarcoFalke)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  12. isghe referenced this in commit 5987b7cadd on Dec 6, 2018
  13. isghe commented at 11:08 PM on December 6, 2018: contributor

    https://github.com/isghe/bitcoin/commits/raise-error-createrawtransaction-multi-OP_RETURN just adding on this PR

        const CTransaction rawTxCopy (rawTx);
        std::string error;
        if (!IsStandardTx (rawTxCopy, error)) {
            throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter combination: " + error);
        }
    

    obtaining:

    $ ./src/bitcoin-cli createrawtransaction "[]" "[{\"mguLQ6eGCHpnmRrDwAjbPpYAHjxY6GneeQ\":\"0.1\"}, {\"data\":\"ee\"}, {\"muLYgM1L3gCzLs1bPX5cVzx3ax1f4vBcpN\":\"0.2\"},{\"data\":\"ff\"}]" | xargs ./src/bitcoin-cli decoderawtransaction
    error code: -8
    error message:
    Invalid parameter combination: multi-op-return
    
  14. Empact commented at 11:23 PM on December 6, 2018: member

    5987b7cadd15cd1b524fec430868ee0c174f06da makes sense to me, independent of this issue. Calls for another PR IMO.

  15. isghe commented at 11:42 PM on December 6, 2018: contributor

    @Empact my idea, is that createrawtransaction should check if a transaction is standard or not, just delegating to IsStandardTx function. If not, we are spreading the rules in the source code, and doesn't sound good. At this point I think it would be better to create a PR removing hard-coded rules written in createrawtransaction, delegating the all things to IsStandardTx. I'll work on it, in the weekend.

  16. isghe commented at 1:38 AM on December 7, 2018: contributor

    anyway, createrawtransaction could be created as an external tool, without affecting the consensus rules

  17. Empact commented at 2:07 AM on December 7, 2018: member

    @isghe to get this done safely and most easily, I recommend approaching this incrementally, e.g.:

    1. fixing the immediate issue
    2. applying the IsStandardTx check to createrawtransaction
    3. removing the then-redundant checks
  18. gmaxwell commented at 9:26 AM on December 7, 2018: contributor

    Rejecting duplicate data fields instead of mangling them is the right thing to do regardless of standardness rules: as I pointed out, the input is a dictionary... and also even if standardness permitted multiple op_returns we probably would not support it.

    IsStandard probably shouldn't be run on non-final/signed transactions so it isn't a solution here. (It might actually work, but if so that's largely an accident.) The standardness behaviour of the wallet and the network are disjoint in any case: lets imagine that the network standardness rule changed, we still wouldn't want the wallet creating things the old behaviour would reject until the new behaviour were widely deployed. Sometimes code/behavior that looks the same isn't really the same and isn't a duplicate due to how the code needs to be maintained or modified.

  19. promag commented at 9:48 AM on December 7, 2018: member

    NACK, this changes nothing.

  20. DrahtBot added the label Needs rebase on Dec 7, 2018
  21. DrahtBot commented at 4:45 PM on December 7, 2018: member

    <!--cf906140f33d8803c4a75a2196329ecb-->Needs rebase

  22. isghe commented at 6:36 PM on December 7, 2018: contributor

    @gmaxwell thanks for the explanation. I think we can close this PR.

  23. jnewbery closed this on Dec 7, 2018

  24. laanwj removed the label Needs rebase on Oct 24, 2019
  25. DrahtBot locked this on Dec 16, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me