Revised payment request handling to use genesis block hash instead of network name.

This commit is contained in:
Ross Nicoll 2014-06-19 22:30:41 +01:00
parent a2d69c73ba
commit 01c7b32219
No known key found for this signature in database
GPG key ID: 9142E5F7E533CE3B
2 changed files with 20 additions and 14 deletions

View file

@ -1,22 +1,23 @@
//
// Simple Bitcoin Payment Protocol messages
// Simple Dogecoin Payment Protocol messages
// Derived fromthe Bitcoin Payment Protocol
//
// Use fields 100+ for extensions;
// to avoid conflicts, register extensions at:
// https://en.bitcoin.it/wiki/Payment_Request
// to avoid conflicts, register extensions via pull-req at:
// https://github.com/dogecoin/dips
//
package payments;
option java_package = "org.bitcoin.protocols.payments";
option java_package = "com.dogecoin.protocols.payments";
option java_outer_classname = "Protos";
// Generalized form of "send payment to this/these bitcoin addresses"
// Generalized form of "send payment to this/these dogecoin addresses"
message Output {
optional uint64 amount = 1 [default = 0]; // amount is integer-number-of-satoshis
required bytes script = 2; // usually one of the standard Script forms
optional uint64 amount = 1 [default = 0]; // amount is integer-number-of-satoshis
required bytes script = 2; // usually one of the standard Script forms
}
message PaymentDetails {
optional string network = 1 [default = "main"]; // "main" or "test"
optional string genesis = 1 [default = "1a91e3dace36e2be3bf030a65679fe821aa1d6ef92e7c9902eb318182c355691"]; // Hash of the network genesis block
repeated Output outputs = 2; // Where payment should be sent
required uint64 time = 3; // Timestamp; when payment request created
optional uint64 expires = 4; // Timestamp; when this request should be considered invalid

View file

@ -208,14 +208,19 @@ bool PaymentServer::ipcParseCommandLine(int argc, char* argv[])
else if (QFile::exists(arg)) // Filename
{
savedPaymentRequests.append(arg);
PaymentRequestPlus request;
if (readPaymentRequest(arg, request))
{
if (request.getDetails().network() == "main")
if (request.getDetails().genesis() == "1a91e3dace36e2be3bf030a65679fe821aa1d6ef92e7c9902eb318182c355691")
{
SelectParams(CChainParams::MAIN);
else
}
else if (request.getDetails().genesis() == "bb0a78264637406b6360aad926284d544d7049f45189db5664f3c4d07350559e")
{
SelectParams(CChainParams::TESTNET);
}
}
}
else
@ -497,10 +502,10 @@ bool PaymentServer::processPaymentRequest(PaymentRequestPlus& request, SendCoins
if (request.IsInitialized()) {
const payments::PaymentDetails& details = request.getDetails();
// Payment request network matches client network?
if ((details.network() == "main" && TestNet()) ||
(details.network() == "test" && !TestNet()))
if ((details.genesis() == "1a91e3dace36e2be3bf030a65679fe821aa1d6ef92e7c9902eb318182c355691" && TestNet()) ||
(details.genesis() == "bb0a78264637406b6360aad926284d544d7049f45189db5664f3c4d07350559e" && !TestNet()))
{
emit message(tr("Payment request rejected"), tr("Payment request network doesn't match client network."),
CClientUIInterface::MSG_ERROR);