Fix Claim transaction to prove authority.

This commit is contained in:
Arthur Britto
2012-05-15 20:28:29 -07:00
parent f030dc2ca1
commit 9bbbf24f43
5 changed files with 28 additions and 15 deletions

View File

@@ -668,7 +668,9 @@ Json::Value RPCServer::doWalletClaim(Json::Value& params)
else else
{ {
// Trying to build: // Trying to build:
// peer_wallet_claim <account_id> <generator_id> <encrypted_master_public_generator> <account_id_signature> [<source_tag>] [<annotation>] // peer_wallet_claim <account_id> <encrypted_master_public_generator> <generator_pubkey> <generator_signature>
// <source_tag> [<annotation>]
//
// //
// Which has no confidential information. // Which has no confidential information.
@@ -703,13 +705,18 @@ Json::Value RPCServer::doWalletClaim(Json::Value& params)
// hash of regular account #reserved public key. // hash of regular account #reserved public key.
uint160 uGeneratorID = naRegularReservedPublic.getAccountID(); uint160 uGeneratorID = naRegularReservedPublic.getAccountID();
std::vector<unsigned char> vucGeneratorCipher = naRegularReservedPrivate.accountPrivateEncrypt(naRegularReservedPublic, naMasterGenerator.getFamilyGenerator()); std::vector<unsigned char> vucGeneratorCipher = naRegularReservedPrivate.accountPrivateEncrypt(naRegularReservedPublic, naMasterGenerator.getFamilyGenerator());
std::vector<unsigned char> vucGeneratorSig;
// XXX Check result.
naRegularReservedPrivate.accountPrivateSign(Serializer::getSHA512Half(vucGeneratorCipher), vucGeneratorSig);
Transaction::pointer trns = Transaction::sharedClaim( Transaction::pointer trns = Transaction::sharedClaim(
naAccountPublic, naAccountPrivate, naAccountPublic, naAccountPrivate,
naAccountPublic, naAccountPublic,
uSourceTag, uSourceTag,
naRegularReservedPublic, // GeneratorID vucGeneratorCipher,
vucGeneratorCipher); naRegularReservedPublic.getAccountPublic(),
vucGeneratorSig);
(void) theApp->getOPs().processTransaction(trns); (void) theApp->getOPs().processTransaction(trns);

View File

@@ -32,7 +32,7 @@ enum SOE_Field
sfBorrower, sfLender, sfLimit, sfOfferCurrency, sfLedgerHash, sfBorrower, sfLender, sfLimit, sfOfferCurrency, sfLedgerHash,
sfLastReceive, sfLastTxn, sfNextRate, sfNextRateLgr, sfNextRateExp, sfLastReceive, sfLastTxn, sfNextRate, sfNextRateLgr, sfNextRateExp,
sfNickname, sfMinimumOffer, sfNickname, sfMinimumOffer,
sfAuthorizedKey, sfGenerator, sfGeneratorID, sfAccountID, sfAuthorizedKey, sfGenerator, sfPubKey, sfSignature, sfGeneratorID, sfAccountID,
// test fields // test fields
sfTest1, sfTest2, sfTest3, sfTest4 sfTest1, sfTest2, sfTest3, sfTest4

View File

@@ -118,11 +118,13 @@ bool Transaction::sign(const NewcoinAddress& naAccountPrivate)
Transaction::pointer Transaction::setClaim( Transaction::pointer Transaction::setClaim(
const NewcoinAddress& naPrivateKey, const NewcoinAddress& naPrivateKey,
const NewcoinAddress& naGeneratorID, const std::vector<unsigned char>& vucGenerator,
const std::vector<unsigned char>& vucGenerator) const std::vector<unsigned char>& vucPubKey,
const std::vector<unsigned char>& vucSignature)
{ {
mTransaction->setITFieldH160(sfGeneratorID, naGeneratorID.getAccountID());
mTransaction->setITFieldVL(sfGenerator, vucGenerator); mTransaction->setITFieldVL(sfGenerator, vucGenerator);
mTransaction->setITFieldVL(sfPubKey, vucPubKey);
mTransaction->setITFieldVL(sfSignature, vucSignature);
sign(naPrivateKey); sign(naPrivateKey);
@@ -133,8 +135,9 @@ Transaction::pointer Transaction::sharedClaim(
const NewcoinAddress& naPublicKey, const NewcoinAddress& naPrivateKey, const NewcoinAddress& naPublicKey, const NewcoinAddress& naPrivateKey,
const NewcoinAddress& naSourceAccount, const NewcoinAddress& naSourceAccount,
uint32 uSourceTag, uint32 uSourceTag,
const NewcoinAddress& naGeneratorID, const std::vector<unsigned char>& vucGenerator,
const std::vector<unsigned char>& vucGenerator) const std::vector<unsigned char>& vucPubKey,
const std::vector<unsigned char>& vucSignature)
{ {
pointer tResult = boost::make_shared<Transaction>(ttCLAIM, pointer tResult = boost::make_shared<Transaction>(ttCLAIM,
naPublicKey, naSourceAccount, naPublicKey, naSourceAccount,
@@ -142,7 +145,7 @@ Transaction::pointer Transaction::sharedClaim(
0, // Free. 0, // Free.
uSourceTag); uSourceTag);
return tResult->setClaim(naPrivateKey, naGeneratorID, vucGenerator); return tResult->setClaim(naPrivateKey, vucGenerator, vucPubKey, vucSignature);
} }
// //

View File

@@ -55,8 +55,9 @@ private:
Transaction::pointer setClaim( Transaction::pointer setClaim(
const NewcoinAddress& naPrivateKey, const NewcoinAddress& naPrivateKey,
const NewcoinAddress& naGeneratorID, const std::vector<unsigned char>& vucGenerator,
const std::vector<unsigned char>& vucGenerator); const std::vector<unsigned char>& vucPubKey,
const std::vector<unsigned char>& vucSignature);
public: public:
Transaction(const SerializedTransaction::pointer st, bool bValidate); Transaction(const SerializedTransaction::pointer st, bool bValidate);
@@ -85,8 +86,9 @@ public:
const NewcoinAddress& naPublicKey, const NewcoinAddress& naPrivateKey, const NewcoinAddress& naPublicKey, const NewcoinAddress& naPrivateKey,
const NewcoinAddress& naSourceAccount, const NewcoinAddress& naSourceAccount,
uint32 uSourceTag, uint32 uSourceTag,
const NewcoinAddress& naGeneratorID, const std::vector<unsigned char>& vucGenerator,
const std::vector<unsigned char>& vucGenerator); const std::vector<unsigned char>& vucPubKey,
const std::vector<unsigned char>& vucSignature);
#if 0 #if 0
Transaction(const NewcoinAddress& fromID, const NewcoinAddress& toID, Transaction(const NewcoinAddress& fromID, const NewcoinAddress& toID,
CKey::pointer pubKey, uint64 uAmount, uint64 fee, uint32 fromSeq, uint32 fromLedger, CKey::pointer pubKey, uint64 uAmount, uint64 fee, uint32 fromSeq, uint32 fromLedger,

View File

@@ -18,8 +18,9 @@ TransactionFormat InnerTxnFormats[]=
}, },
{ "Claim", ttCLAIM, { { "Claim", ttCLAIM, {
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 }, { S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
{ S_FIELD(GeneratorID), STI_HASH160, SOE_REQUIRED, 0 },
{ S_FIELD(Generator), STI_VL, SOE_REQUIRED, 0 }, { S_FIELD(Generator), STI_VL, SOE_REQUIRED, 0 },
{ S_FIELD(PubKey), STI_VL, SOE_REQUIRED, 0 },
{ S_FIELD(Signature), STI_VL, SOE_REQUIRED, 0 },
{ S_FIELD(SourceTag), STI_UINT32, SOE_IFFLAG, 1 }, { S_FIELD(SourceTag), STI_UINT32, SOE_IFFLAG, 1 },
{ S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 0x02000000 }, { S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 0x02000000 },
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } } { sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }