@@ -982,131 +982,6 @@ static UniValue addmultisigaddress(const JSONRPCRequest& request)
982
982
return result;
983
983
}
984
984
985
- class Witnessifier : public boost ::static_visitor<bool >
986
- {
987
- public:
988
- CWallet * const pwallet;
989
- CTxDestination result;
990
- bool already_witness;
991
-
992
- explicit Witnessifier (CWallet *_pwallet) : pwallet(_pwallet), already_witness(false ) {}
993
-
994
- bool operator ()(const CKeyID &keyID) {
995
- if (pwallet) {
996
- CScript basescript = GetScriptForDestination (keyID);
997
- CScript witscript = GetScriptForWitness (basescript);
998
- if (!IsSolvable (*pwallet, witscript)) {
999
- return false ;
1000
- }
1001
- return ExtractDestination (witscript, result);
1002
- }
1003
- return false ;
1004
- }
1005
-
1006
- bool operator ()(const CScriptID &scriptID) {
1007
- CScript subscript;
1008
- if (pwallet && pwallet->GetCScript (scriptID, subscript)) {
1009
- int witnessversion;
1010
- std::vector<unsigned char > witprog;
1011
- if (subscript.IsWitnessProgram (witnessversion, witprog)) {
1012
- ExtractDestination (subscript, result);
1013
- already_witness = true ;
1014
- return true ;
1015
- }
1016
- CScript witscript = GetScriptForWitness (subscript);
1017
- if (!IsSolvable (*pwallet, witscript)) {
1018
- return false ;
1019
- }
1020
- return ExtractDestination (witscript, result);
1021
- }
1022
- return false ;
1023
- }
1024
-
1025
- bool operator ()(const WitnessV0KeyHash& id)
1026
- {
1027
- already_witness = true ;
1028
- result = id;
1029
- return true ;
1030
- }
1031
-
1032
- bool operator ()(const WitnessV0ScriptHash& id)
1033
- {
1034
- already_witness = true ;
1035
- result = id;
1036
- return true ;
1037
- }
1038
-
1039
- template <typename T>
1040
- bool operator ()(const T& dest) { return false ; }
1041
- };
1042
-
1043
- static UniValue addwitnessaddress (const JSONRPCRequest& request)
1044
- {
1045
- std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest (request);
1046
- CWallet* const pwallet = wallet.get ();
1047
-
1048
- if (!EnsureWalletIsAvailable (pwallet, request.fHelp )) {
1049
- return NullUniValue;
1050
- }
1051
-
1052
- if (request.fHelp || request.params .size () < 1 || request.params .size () > 2 )
1053
- {
1054
- std::string msg = " addwitnessaddress \" address\" ( p2sh )\n "
1055
- " \n DEPRECATED: set the address_type argument of getnewaddress, or option -addresstype=[bech32|p2sh-segwit] instead.\n "
1056
- " Add a witness address for a script (with pubkey or redeemscript known). Requires a new wallet backup.\n "
1057
- " It returns the witness script.\n "
1058
-
1059
- " \n Arguments:\n "
1060
- " 1. \" address\" (string, required) An address known to the wallet\n "
1061
- " 2. p2sh (bool, optional, default=true) Embed inside P2SH\n "
1062
-
1063
- " \n Result:\n "
1064
- " \" witnessaddress\" , (string) The value of the new address (P2SH or BIP173).\n "
1065
- " }\n "
1066
- ;
1067
- throw std::runtime_error (msg);
1068
- }
1069
-
1070
- if (!IsDeprecatedRPCEnabled (" addwitnessaddress" )) {
1071
- throw JSONRPCError (RPC_METHOD_DEPRECATED, " addwitnessaddress is deprecated and will be fully removed in v0.17. "
1072
- " To use addwitnessaddress in v0.16, restart bitcoind with -deprecatedrpc=addwitnessaddress.\n "
1073
- " Projects should transition to using the address_type argument of getnewaddress, or option -addresstype=[bech32|p2sh-segwit] instead.\n " );
1074
- }
1075
-
1076
- CTxDestination dest = DecodeDestination (request.params [0 ].get_str ());
1077
- if (!IsValidDestination (dest)) {
1078
- throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY, " Invalid Bitcoin address" );
1079
- }
1080
-
1081
- bool p2sh = true ;
1082
- if (!request.params [1 ].isNull ()) {
1083
- p2sh = request.params [1 ].get_bool ();
1084
- }
1085
-
1086
- Witnessifier w (pwallet);
1087
- bool ret = boost::apply_visitor (w, dest);
1088
- if (!ret) {
1089
- throw JSONRPCError (RPC_WALLET_ERROR, " Public key or redeemscript not known to wallet, or the key is uncompressed" );
1090
- }
1091
-
1092
- CScript witprogram = GetScriptForDestination (w.result );
1093
-
1094
- if (p2sh) {
1095
- w.result = CScriptID (witprogram);
1096
- }
1097
-
1098
- if (w.already_witness ) {
1099
- if (!(dest == w.result )) {
1100
- throw JSONRPCError (RPC_WALLET_ERROR, " Cannot convert between witness address types" );
1101
- }
1102
- } else {
1103
- pwallet->AddCScript (witprogram); // Implicit for single-key now, but necessary for multisig and for compatibility with older software
1104
- pwallet->SetAddressBook (w.result , " " , " receive" );
1105
- }
1106
-
1107
- return EncodeDestination (w.result );
1108
- }
1109
-
1110
985
struct tallyitem
1111
986
{
1112
987
CAmount nAmount;
@@ -4097,7 +3972,6 @@ static const CRPCCommand commands[] =
4097
3972
{ // category name actor (function) argNames
4098
3973
// --------------------- ------------------------ ----------------------- ----------
4099
3974
{ " generating" , " generate" , &generate, {" nblocks" ," maxtries" } },
4100
- { " hidden" , " addwitnessaddress" , &addwitnessaddress, {" address" ," p2sh" } },
4101
3975
{ " hidden" , " resendwallettransactions" , &resendwallettransactions, {} },
4102
3976
{ " rawtransactions" , " fundrawtransaction" , &fundrawtransaction, {" hexstring" ," options" ," iswitness" } },
4103
3977
{ " wallet" , " abandontransaction" , &abandontransaction, {" txid" } },
0 commit comments