Browse Source

create CScript overload for << string

miguelfreitas
Miguel Freitas 11 years ago
parent
commit
fe01fd01cb
  1. 4
      src/bitcoind.cpp
  2. 4
      src/main.cpp
  3. 7
      src/script.h

4
src/bitcoind.cpp

@ -130,7 +130,7 @@ static bool TestCreateSpamMsgTx()
{ {
CTransaction txNew; CTransaction txNew;
txNew.message = CScript() << vector<unsigned char>((const unsigned char*)strSpamMessage.data(), (const unsigned char*)strSpamMessage.data() + strSpamMessage.size()); txNew.message = CScript() << strSpamMessage;
CBitcoinSecret bsecret1; CBitcoinSecret bsecret1;
bsecret1.SetString (strSecret1C); bsecret1.SetString (strSecret1C);
@ -169,7 +169,7 @@ static bool TestCreateSpamMsgTx()
hashMsg.ToString().c_str(), EncodeBase64(&vchSig[0], vchSig.size()).c_str() ); hashMsg.ToString().c_str(), EncodeBase64(&vchSig[0], vchSig.size()).c_str() );
// add username and signature // add username and signature
txNew.userName = CScript() << vector<unsigned char>((const unsigned char*)strSpamUser.data(), (const unsigned char*)strSpamUser.data() + strSpamUser.size()); txNew.userName = CScript() << strSpamUser;
txNew.userName += CScript() << vchSig; txNew.userName += CScript() << vchSig;
txNew.pubKey.clear(); // pubKey will be updated to include extranonce txNew.pubKey.clear(); // pubKey will be updated to include extranonce
txNew.nNonce = 0; // no update needed for spamMessage's nonce. txNew.nNonce = 0; // no update needed for spamMessage's nonce.

4
src/main.cpp

@ -3511,7 +3511,7 @@ public:
static bool CreateSpamMsgTx(CTransaction &txNew) static bool CreateSpamMsgTx(CTransaction &txNew)
{ {
txNew.message = CScript() << vector<unsigned char>((const unsigned char*)strSpamMessage.data(), (const unsigned char*)strSpamMessage.data() + strSpamMessage.size()); txNew.message = CScript() << strSpamMessage;
// get keyid from wallet (hopefully this is pubkey of strSpamUser) // get keyid from wallet (hopefully this is pubkey of strSpamUser)
CKeyID defaultKeyId( pwalletMain->vchDefaultKey.GetID() ); CKeyID defaultKeyId( pwalletMain->vchDefaultKey.GetID() );
@ -3539,7 +3539,7 @@ static bool CreateSpamMsgTx(CTransaction &txNew)
hashMsg.ToString().c_str(), EncodeBase64(&vchSig[0], vchSig.size()).c_str() ); hashMsg.ToString().c_str(), EncodeBase64(&vchSig[0], vchSig.size()).c_str() );
// add username and signature // add username and signature
txNew.userName = CScript() << vector<unsigned char>((const unsigned char*)strSpamUser.data(), (const unsigned char*)strSpamUser.data() + strSpamUser.size()); txNew.userName = CScript() << strSpamUser;
txNew.userName += CScript() << vchSig; txNew.userName += CScript() << vchSig;
txNew.pubKey.clear(); // pubKey will be updated to include extranonce txNew.pubKey.clear(); // pubKey will be updated to include extranonce
txNew.nNonce = 0; // no update needed for spamMessage's nonce. txNew.nNonce = 0; // no update needed for spamMessage's nonce.

7
src/script.h

@ -387,6 +387,13 @@ public:
return *this; return *this;
} }
CScript& operator<<(const std::string &s)
{
const std::vector<unsigned char> b((const unsigned char*)s.data(),
(const unsigned char*)s.data() + s.size());
return operator<<(b);
}
CScript& operator<<(const CScript& b) CScript& operator<<(const CScript& b)
{ {
// I'm not sure if this should push the script or concatenate scripts. // I'm not sure if this should push the script or concatenate scripts.

Loading…
Cancel
Save