Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpcclient: signrawtransaction method is deprecated in bitcoin core, but not updated in btcd #1722

Closed
ghost opened this issue May 25, 2021 · 5 comments

Comments

@ghost
Copy link

ghost commented May 25, 2021

i modify signrawtransaction method in btcd to use signrawtransactionwithkey. please update it.

@Roasbeef
Copy link
Member

The new command was added in this PR: #1642

btcd doesn't implement the new command, so we'll still keep it around for the rpcclient.

@galileo-pkm
Copy link

galileo-pkm commented Sep 6, 2022

It seems that you missed the point:
for bitcoind there are signrawtransactionwithkey and signrawtransactionwithwallet commands.
Rpcclient library methods SignRawTransaction2,3 etc all use the depreciated signrawtransaction but should be using
the new signrawtransactionwithkey.
If you want to maintain the compatibility with bitcoind the easiest route is to update both the rpclient library and btcd.

Edit: Also the new (signrawtransactionwithkey) RPC method is slightly different.
Old one:


1. "hexstring"     (string, required) The transaction hex string
2. "prevtxs"       (string, optional) An json array of previous dependent transaction outputs
     [               (json array of json objects, or 'null' if none provided)
       {
         "txid":"id",             (string, required) The transaction id
         "vout":n,                  (numeric, required) The output number
         "scriptPubKey": "hex",   (string, required) script key
         "redeemScript": "hex",   (string, required for P2SH or P2WSH) redeem script
         "amount": value            (numeric, required) The amount spent
       }
       ,...
    ]
3. "privkeys"     (string, optional) A json array of base58-encoded private keys for signing
    [                  (json array of strings, or 'null' if none provided)
      "privatekey"   (string) private key in base58-encoding
      ,...
    ]
4. "sighashtype"     (string, optional, default=ALL) The signature hash type. Must be one of
       "ALL"
       "NONE"
       "SINGLE"
       "ALL|ANYONECANPAY"
       "NONE|ANYONECANPAY"
       "SINGLE|ANYONECANPAY"


New one:

Arguments:
1. hexstring                        (string, required) The transaction hex string
2. privkeys                         (json array, required) The base58-encoded private keys for signing
     [
       "privatekey",                (string) private key in base58-encoding
       ...
     ]
3. prevtxs                          (json array, optional) The previous dependent transaction outputs
     [
       {                            (json object)
         "txid": "hex",             (string, required) The transaction id
         "vout": n,                 (numeric, required) The output number
         "scriptPubKey": "hex",     (string, required) script key
         "redeemScript": "hex",     (string) (required for P2SH) redeem script
         "witnessScript": "hex",    (string) (required for P2WSH or P2SH-P2WSH) witness script
         "amount": amount,          (numeric or string) (required for Segwit inputs) the amount spent
       },
       ...
     ]
4. sighashtype                      (string, optional, default="DEFAULT for Taproot, ALL otherwise") The signature hash type. Must be one of:
                                    "DEFAULT"
                                    "ALL"
                                    "NONE"
                                    "SINGLE"
                                    "ALL|ANYONECANPAY"
                                    "NONE|ANYONECANPAY"
                                    "SINGLE|ANYONECANPAY"
                                    

       


signrawtransaction has been deprecated since 0.17 (at least) so I have no idea how this went unnoticed.

@Roasbeef
Copy link
Member

Roasbeef commented Sep 6, 2022

@galileo-pkm I think I understood the OP. If you'd like to add a new command for signrawtransactionwithkey then we'd review the PR. Generally we stopped keeping up in lock step w/ bitcoind since for example: we don't package a wallet within this project, so the commands are never used in line or tested in the project.

If you take a look at the way the RPC client works, it's relatively straight forward to add a new command externally: https://github.com/btcsuite/btcd/blob/v0.23.1/rpcclient/examples/customcommand/main.go

This gives projects everything they need to keep up with the bitcoind API changes/breakages they'd like to keep up with.

@galileo-pkm
Copy link

Thank you, I will take a look at the example provided.

@galileo-pkm
Copy link

PR submitted: #1885

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants