mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-01-15 01:20:24 +00:00
[wallet] getreceivedbyaddress should return error if address is not mine
This commit is contained in:
parent
ea0cd24f7d
commit
5e0ba8f8cd
@ -654,7 +654,7 @@ UniValue getreceivedbyaddress(const JSONRPCRequest& request)
|
|||||||
}
|
}
|
||||||
CScript scriptPubKey = GetScriptForDestination(dest);
|
CScript scriptPubKey = GetScriptForDestination(dest);
|
||||||
if (!IsMine(*pwallet, scriptPubKey)) {
|
if (!IsMine(*pwallet, scriptPubKey)) {
|
||||||
return ValueFromAmount(0);
|
throw JSONRPCError(RPC_WALLET_ERROR, "Address not found in wallet");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Minimum confirmations
|
// Minimum confirmations
|
||||||
|
@ -6,7 +6,10 @@
|
|||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|
||||||
from test_framework.test_framework import BitcoinTestFramework
|
from test_framework.test_framework import BitcoinTestFramework
|
||||||
from test_framework.util import assert_array_result, assert_equal
|
from test_framework.util import (assert_array_result,
|
||||||
|
assert_equal,
|
||||||
|
assert_raises_rpc_error,
|
||||||
|
)
|
||||||
|
|
||||||
class ReceivedByTest(BitcoinTestFramework):
|
class ReceivedByTest(BitcoinTestFramework):
|
||||||
def set_test_params(self):
|
def set_test_params(self):
|
||||||
@ -68,6 +71,9 @@ class ReceivedByTest(BitcoinTestFramework):
|
|||||||
balance = self.nodes[1].getreceivedbyaddress(addr)
|
balance = self.nodes[1].getreceivedbyaddress(addr)
|
||||||
assert_equal(balance, Decimal("0.1"))
|
assert_equal(balance, Decimal("0.1"))
|
||||||
|
|
||||||
|
# Trying to getreceivedby for an address the wallet doesn't own should return an error
|
||||||
|
assert_raises_rpc_error(-4, "Address not found in wallet", self.nodes[0].getreceivedbyaddress, addr)
|
||||||
|
|
||||||
self.log.info("listreceivedbyaccount + getreceivedbyaccount Test")
|
self.log.info("listreceivedbyaccount + getreceivedbyaccount Test")
|
||||||
|
|
||||||
# set pre-state
|
# set pre-state
|
||||||
|
Loading…
x
Reference in New Issue
Block a user