Bitcoin Core  0.20.99
P2P Digital Currency
Functions | Variables
message.cpp File Reference
#include <hash.h>
#include <key.h>
#include <key_io.h>
#include <pubkey.h>
#include <script/standard.h>
#include <serialize.h>
#include <util/message.h>
#include <util/strencodings.h>
#include <string>
#include <vector>
Include dependency graph for message.cpp:

Go to the source code of this file.

Functions

MessageVerificationResult MessageVerify (const std::string &address, const std::string &signature, const std::string &message)
 Verify a signed message. More...
 
bool MessageSign (const CKey &privkey, const std::string &message, std::string &signature)
 Sign a message. More...
 
uint256 MessageHash (const std::string &message)
 Hashes a message for signing and verification in a manner that prevents inadvertently signing a transaction. More...
 
std::string SigningResultString (const SigningResult res)
 

Variables

const std::string MESSAGE_MAGIC = "Bitcoin Signed Message:\n"
 Text used to signify that a signed message follows and to prevent inadvertently signing a transaction. More...
 

Function Documentation

◆ MessageHash()

uint256 MessageHash ( const std::string &  message)

Hashes a message for signing and verification in a manner that prevents inadvertently signing a transaction.

Definition at line 72 of file message.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MessageSign()

bool MessageSign ( const CKey privkey,
const std::string &  message,
std::string &  signature 
)

Sign a message.

Parameters
[in]privkeyPrivate key to sign with.
[in]messageThe message to sign.
[out]signatureSignature, base64 encoded, only set if true is returned.
Returns
true if signing was successful.

Definition at line 56 of file message.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MessageVerify()

MessageVerificationResult MessageVerify ( const std::string &  address,
const std::string &  signature,
const std::string &  message 
)

Verify a signed message.

Parameters
[in]addressSigner's bitcoin address, it must refer to a public key.
[in]signatureThe signature in base64 format.
[in]messageThe message that was signed.
Returns
result code

Definition at line 24 of file message.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SigningResultString()

std::string SigningResultString ( const SigningResult  res)

Definition at line 80 of file message.cpp.

Here is the caller graph for this function:

Variable Documentation

◆ MESSAGE_MAGIC

const std::string MESSAGE_MAGIC = "Bitcoin Signed Message:\n"

Text used to signify that a signed message follows and to prevent inadvertently signing a transaction.

Definition at line 22 of file message.cpp.