2 # Copyright (c) 2016 The Bitcoin Core developers
3 # Distributed under the MIT software license, see the accompanying
4 # file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 """Test RPC commands for signing and verifying messages."""
7 from test_framework
.test_framework
import BitcoinTestFramework
9 class SignMessagesTest(BitcoinTestFramework
):
10 def set_test_params(self
):
11 self
.setup_clean_chain
= True
15 message
= 'This is just a test message'
17 # Test the signing with a privkey
18 privKey
= 'cUeKHd5orzT3mz8P9pxyREHfsWtVfgsfDjiZZBcjUBAaGk1BTj7N'
19 address
= 'mpLQjfK79b7CCV4VMJWEWAj5Mpx8Up5zxB'
20 signature
= self
.nodes
[0].signmessagewithprivkey(privKey
, message
)
23 assert(self
.nodes
[0].verifymessage(address
, signature
, message
))
25 # Test the signing with an address with wallet
26 address
= self
.nodes
[0].getnewaddress()
27 signature
= self
.nodes
[0].signmessage(address
, message
)
30 assert(self
.nodes
[0].verifymessage(address
, signature
, message
))
32 if __name__
== '__main__':
33 SignMessagesTest().main()