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.
[RPC] Add utility signinput #11666
pull NicolasDorier wants to merge 1 commits into bitcoin:master from NicolasDorier:signinput changing 7 files +182 −13-
NicolasDorier commented at 5:09 AM on November 12, 2017: contributor
- NicolasDorier force-pushed on Nov 12, 2017
- fanquake added the label RPC/REST/ZMQ on Nov 12, 2017
-
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. -
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-txprogrammatically make things harder, as I then need to ask users to not only configure RPC settings in my tool, but also the path tobitcoin-txutility.bitcoin-txis adapted for making a transaction manually. This is not what I am looking for. -
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 addedinputindexrestriction perkey?) -
NicolasDorier commented at 2:39 AM on November 14, 2017: contributor
signrawtransactionworks only if you sign well known scripts as it useProduceSignature. So in my case (HTLC), it does not returns me the signature, not even in the tx hex it returns me. -
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
nHashTypecan be removed.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 = ...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)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?
promag commented at 12:39 PM on November 15, 2017: memberThe code could be updated according to dev notes.
[RPC] Add utility signinput 5da5e788c8NicolasDorier force-pushed on Nov 20, 2017NicolasDorier commented at 10:16 AM on November 20, 2017: contributornits addressed
NicolasDorier commented at 5:26 PM on March 6, 2018: contributorwill reopen the day I need it again. I workedaround this for now.
NicolasDorier closed this on Mar 6, 2018MarcoFalke locked this on Sep 8, 2021ContributorsLabels
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