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
):
13 self
.setup_clean_chain
= True
17 message
= 'This is just a test message'
19 # Test the signing with a privkey
20 privKey
= 'cUeKHd5orzT3mz8P9pxyREHfsWtVfgsfDjiZZBcjUBAaGk1BTj7N'
21 address
= 'mpLQjfK79b7CCV4VMJWEWAj5Mpx8Up5zxB'
22 signature
= self
.nodes
[0].signmessagewithprivkey(privKey
, message
)
25 assert(self
.nodes
[0].verifymessage(address
, signature
, message
))
27 # Test the signing with an address with wallet
28 address
= self
.nodes
[0].getnewaddress()
29 signature
= self
.nodes
[0].signmessage(address
, message
)
32 assert(self
.nodes
[0].verifymessage(address
, signature
, message
))
34 if __name__
== '__main__':
35 SignMessagesTest().main()