@@ -1762,28 +1762,33 @@ RPCHelpMan walletdeniabilizecoin()
1762
1762
1763
1763
std::optional<CTxDestination> shared_address;
1764
1764
std::set<COutPoint> inputs;
1765
- unsigned int deniabilization_cycles = 0 ;
1765
+ unsigned int deniabilization_cycles = UINT_MAX ;
1766
1766
for (const UniValue& input : request.params [0 ].get_array ().getValues ()) {
1767
1767
uint256 txid = ParseHashO (input, " txid" );
1768
1768
1769
1769
const UniValue& vout_v = input.find_value (" vout" );
1770
- if (!vout_v.isNum ())
1770
+ if (!vout_v.isNum ()) {
1771
1771
throw JSONRPCError (RPC_INVALID_PARAMETER, " Invalid parameter, missing vout key" );
1772
+ }
1772
1773
int nOutput = vout_v.getInt <int >();
1773
- if (nOutput < 0 )
1774
+ if (nOutput < 0 ) {
1774
1775
throw JSONRPCError (RPC_INVALID_PARAMETER, " Invalid parameter, vout cannot be negative" );
1776
+ }
1775
1777
1776
1778
COutPoint outpoint (txid, nOutput);
1777
1779
LOCK (pwallet->cs_wallet );
1778
1780
auto walletTx = pwallet->GetWalletTx (outpoint.hash );
1779
1781
if (!walletTx) {
1780
- throw JSONRPCError (RPC_WALLET_ERROR, " Transaction not found." );
1782
+ throw JSONRPCError (RPC_INVALID_PARAMETER, " Invalid parameter, txid not found in wallet." );
1783
+ }
1784
+ if (outpoint.n >= walletTx->tx ->vout .size ()) {
1785
+ throw JSONRPCError (RPC_INVALID_PARAMETER, " Invalid parameter, vout is out of range" );
1781
1786
}
1782
1787
const auto & output = walletTx->tx ->vout [outpoint.n ];
1783
1788
1784
1789
isminetype mine = pwallet->IsMine (output);
1785
1790
if (mine == ISMINE_NO) {
1786
- throw JSONRPCError (RPC_WALLET_ERROR , " Transaction 's output doesn't belong to this wallet." );
1791
+ throw JSONRPCError (RPC_INVALID_PARAMETER , " Invalid parameter, transaction 's output doesn't belong to this wallet." );
1787
1792
}
1788
1793
1789
1794
bool spendable = (mine & ISMINE_SPENDABLE) != ISMINE_NO;
@@ -1794,17 +1799,21 @@ RPCHelpMan walletdeniabilizecoin()
1794
1799
shared_address = address;
1795
1800
}
1796
1801
else if (!(*shared_address == address)) {
1797
- throw JSONRPCError (RPC_INVALID_PARAMETER, " Inputs must share the same address" );
1802
+ throw JSONRPCError (RPC_INVALID_PARAMETER, " Invalid parameter, inputs must share the same address" );
1798
1803
}
1799
1804
} else {
1800
- throw JSONRPCError (RPC_INVALID_PARAMETER, " Inputs must be spendable and have a valid address" );
1805
+ throw JSONRPCError (RPC_INVALID_PARAMETER, " Invalid parameter, inputs must be spendable and have a valid address" );
1801
1806
}
1802
1807
1803
1808
inputs.emplace (outpoint);
1804
1809
auto cycles_res = CalculateDeniabilizationCycles (*pwallet, outpoint);
1805
1810
deniabilization_cycles = std::min (deniabilization_cycles, cycles_res.first );
1806
1811
}
1807
1812
1813
+ if (inputs.empty ()) {
1814
+ throw JSONRPCError (RPC_INVALID_PARAMETER, " Invalid parameter, inputs must not be empty" );
1815
+ }
1816
+
1808
1817
unsigned int confirm_target = !request.params [1 ].isNull () ? request.params [1 ].getInt <unsigned int >() : 6 ;
1809
1818
const bool add_to_wallet = !request.params [2 ].isNull () ? request.params [2 ].get_bool () : true ;
1810
1819
0 commit comments