From fe01fd01cb544c5bb03e681702107f2172a7e85a Mon Sep 17 00:00:00 2001 From: Miguel Freitas Date: Wed, 24 Jul 2013 16:22:18 -0300 Subject: [PATCH] create CScript overload for << string --- src/bitcoind.cpp | 4 ++-- src/main.cpp | 4 ++-- src/script.h | 7 +++++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index a113011f..bf4ade69 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -130,7 +130,7 @@ static bool TestCreateSpamMsgTx() { CTransaction txNew; - txNew.message = CScript() << vector((const unsigned char*)strSpamMessage.data(), (const unsigned char*)strSpamMessage.data() + strSpamMessage.size()); + txNew.message = CScript() << strSpamMessage; CBitcoinSecret bsecret1; bsecret1.SetString (strSecret1C); @@ -169,7 +169,7 @@ static bool TestCreateSpamMsgTx() hashMsg.ToString().c_str(), EncodeBase64(&vchSig[0], vchSig.size()).c_str() ); // add username and signature - txNew.userName = CScript() << vector((const unsigned char*)strSpamUser.data(), (const unsigned char*)strSpamUser.data() + strSpamUser.size()); + txNew.userName = CScript() << strSpamUser; txNew.userName += CScript() << vchSig; txNew.pubKey.clear(); // pubKey will be updated to include extranonce txNew.nNonce = 0; // no update needed for spamMessage's nonce. diff --git a/src/main.cpp b/src/main.cpp index 8cea8450..bff2c90a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3511,7 +3511,7 @@ public: static bool CreateSpamMsgTx(CTransaction &txNew) { - txNew.message = CScript() << vector((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) 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() ); // add username and signature - txNew.userName = CScript() << vector((const unsigned char*)strSpamUser.data(), (const unsigned char*)strSpamUser.data() + strSpamUser.size()); + txNew.userName = CScript() << strSpamUser; txNew.userName += CScript() << vchSig; txNew.pubKey.clear(); // pubKey will be updated to include extranonce txNew.nNonce = 0; // no update needed for spamMessage's nonce. diff --git a/src/script.h b/src/script.h index 8ec8adb6..9956bac9 100644 --- a/src/script.h +++ b/src/script.h @@ -387,6 +387,13 @@ public: return *this; } + CScript& operator<<(const std::string &s) + { + const std::vector b((const unsigned char*)s.data(), + (const unsigned char*)s.data() + s.size()); + return operator<<(b); + } + CScript& operator<<(const CScript& b) { // I'm not sure if this should push the script or concatenate scripts.