mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
feat: implementation of RPC 'protx register' for descriptor wallets
This commit is contained in:
parent
d44b0d5dcb
commit
5ab108c982
@ -776,18 +776,23 @@ static UniValue protx_register_common_wrapper(const JSONRPCRequest& request,
|
|||||||
ret.pushKV("signMessage", ptx.MakeSignString());
|
ret.pushKV("signMessage", ptx.MakeSignString());
|
||||||
return ret;
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
// lets prove we own the collateral
|
{
|
||||||
// TODO: make collateral works with Descriptor wallets too
|
LOCK(wallet->cs_wallet);
|
||||||
const LegacyScriptPubKeyMan* spk_man = wallet->GetLegacyScriptPubKeyMan();
|
// lets prove we own the collateral
|
||||||
if (!spk_man) {
|
CScript scriptPubKey = GetScriptForDestination(txDest);
|
||||||
throw JSONRPCError(RPC_WALLET_ERROR, "This type of wallet does not support this command");
|
std::unique_ptr<SigningProvider> provider = wallet->GetSolvingProvider(scriptPubKey);
|
||||||
}
|
|
||||||
|
|
||||||
CKey key;
|
std::string signed_payload;
|
||||||
if (!spk_man->GetKey(ToKeyID(*pkhash), key)) {
|
SigningResult err = wallet->SignMessage(ptx.MakeSignString(), *pkhash, signed_payload);
|
||||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("collateral key not in wallet: %s", EncodeDestination(txDest)));
|
if (err == SigningResult::SIGNING_FAILED) {
|
||||||
}
|
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, SigningResultString(err));
|
||||||
SignSpecialTxPayloadByString(tx, ptx, key);
|
} else if (err != SigningResult::OK){
|
||||||
|
throw JSONRPCError(RPC_WALLET_ERROR, SigningResultString(err));
|
||||||
|
}
|
||||||
|
bool invalid = false;
|
||||||
|
ptx.vchSig = DecodeBase64(signed_payload.c_str(), &invalid);
|
||||||
|
if (invalid) throw JSONRPCError(RPC_INTERNAL_ERROR, "failed to decode base64 ready signature for protx");
|
||||||
|
} // cs_wallet
|
||||||
SetTxPayload(tx, ptx);
|
SetTxPayload(tx, ptx);
|
||||||
return SignAndSendSpecialTx(request, chain_helper, chainman, tx, fSubmit);
|
return SignAndSendSpecialTx(request, chain_helper, chainman, tx, fSubmit);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user