[RPC] Add utility signinput #11666

pull NicolasDorier wants to merge 1 commits into bitcoin:master from NicolasDorier:signinput changing 7 files +182 −13
  1. NicolasDorier commented at 5:09 AM on November 12, 2017: contributor

    An alternative to #11653 , an utility to sign an input. This is very useful when dealing with several bitcoin-based crypto currencies (typically a cross chain swap tool), as several crypto currencies signs in different ways.

  2. NicolasDorier force-pushed on Nov 12, 2017
  3. fanquake added the label RPC/REST/ZMQ on Nov 12, 2017
  4. jonasschnelli commented at 8:37 PM on November 13, 2017: contributor

    I agree it could be useful and I once did a similar thing for debugging. It's pretty expertish, though very useful. This is pure utility (right?) so the question comes up why not to add this into bitcoin-tx.

  5. NicolasDorier commented at 1:25 AM on November 14, 2017: contributor

    @jonasschnelli, maybe I misunderstand the purpose of bitcoin-tx, but I need it to be a RPC method so I can easily make a cross chain swap tool across bitcoin like currencies without knowing the specific way of signing or how to serialize a transaction on each chain.

    My tool has already RPC access to each chain configured. Using this utility via bitcoin-tx programmatically make things harder, as I then need to ask users to not only configure RPC settings in my tool, but also the path to bitcoin-tx utility. bitcoin-tx is adapted for making a transaction manually. This is not what I am looking for.

  6. dcousens commented at 1:41 AM on November 14, 2017: contributor

    Is this simply signrawtransaction, but only returning the signature(s) instead of the transaction hex? (and I suppose an added inputindex restriction per key?)

  7. NicolasDorier commented at 2:39 AM on November 14, 2017: contributor

    signrawtransaction works only if you sign well known scripts as it use ProduceSignature. So in my case (HTLC), it does not returns me the signature, not even in the tx hex it returns me.

  8. in src/rpc/server.cpp:147 in c0271a6307 outdated
     142 | +        { std::string("NONE|ANYONECANPAY"), int(SIGHASH_NONE | SIGHASH_ANYONECANPAY) },
     143 | +        { std::string("SINGLE"), int(SIGHASH_SINGLE) },
     144 | +        { std::string("SINGLE|ANYONECANPAY"), int(SIGHASH_SINGLE | SIGHASH_ANYONECANPAY) },
     145 | +    };
     146 | +    auto it = mapSigHashValues.find(sigHash);
     147 | +    if (it != mapSigHashValues.end())
    


    promag commented at 12:08 PM on November 15, 2017:

    Early return (throw):

    if (it == end) throw ...;
    
    return it->second;
    

    This way nHashType can be removed.

  9. in src/rpc/server.cpp:138 in c0271a6307 outdated
     130 | @@ -131,6 +131,30 @@ uint256 ParseHashV(const UniValue& v, std::string strName)
     131 |      result.SetHex(strHex);
     132 |      return result;
     133 |  }
     134 | +
     135 | +int ParseSigHash(const std::string& sigHash, const std::string& parameterName)
     136 | +{
     137 | +    int nHashType = 0;
     138 | +    static std::map<std::string, int> mapSigHashValues = {
    


    promag commented at 12:12 PM on November 15, 2017:

    Const and snake case:

    static const std::map<std::string, int> sighash_values = ...
    
  10. in src/rpc/server.cpp:135 in c0271a6307 outdated
     130 | @@ -131,6 +131,30 @@ uint256 ParseHashV(const UniValue& v, std::string strName)
     131 |      result.SetHex(strHex);
     132 |      return result;
     133 |  }
     134 | +
     135 | +int ParseSigHash(const std::string& sigHash, const std::string& parameterName)
    


    promag commented at 12:12 PM on November 15, 2017:

    Nit, snake case:

    int ParseSigHash(const std::string& sighash, const std::string& parameter_name)
    
  11. in src/rpc/misc.cpp:361 in c0271a6307 outdated
     356 | +        UniValue::VSTR, // tx
     357 | +        UniValue::VSTR, // scriptCode
     358 | +        UniValue::VNUM, // amount
     359 | +        UniValue::VSTR, // sigVersion
     360 | +        UniValue::VNUM, // inputIndex
     361 | +        UniValue::VSTR // privatekey
    


    promag commented at 12:38 PM on November 15, 2017:

    Nit, align comments?

  12. promag commented at 12:39 PM on November 15, 2017: member

    The code could be updated according to dev notes.

  13. [RPC] Add utility signinput 5da5e788c8
  14. NicolasDorier force-pushed on Nov 20, 2017
  15. NicolasDorier commented at 10:16 AM on November 20, 2017: contributor

    nits addressed

  16. NicolasDorier commented at 5:26 PM on March 6, 2018: contributor

    will reopen the day I need it again. I workedaround this for now.

  17. NicolasDorier closed this on Mar 6, 2018

  18. MarcoFalke locked this on Sep 8, 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