mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Make accounts there own type
so we can add new functionality and so they can display properly. Cleanups and missing helper function.
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "SerializedTypes.h"
|
||||
#include "SerializedObject.h"
|
||||
#include "TransactionFormats.h"
|
||||
#include "NewcoinAddress.h"
|
||||
|
||||
std::string SerializedType::getFullText() const
|
||||
{
|
||||
@@ -104,6 +105,44 @@ int STVariableLength::getLength() const
|
||||
return Serializer::encodeLengthLength(value.size()) + value.size();
|
||||
}
|
||||
|
||||
std::string STAccount::getText() const
|
||||
{
|
||||
uint160 u;
|
||||
NewcoinAddress a;
|
||||
if(!getValueH160(u)) return STVariableLength::getText();
|
||||
a.setAccountID(u);
|
||||
return a.humanAccountPublic();
|
||||
}
|
||||
|
||||
STAccount* STAccount::construct(SerializerIterator& u, const char *name)
|
||||
{
|
||||
STAccount *ret=new STAccount(u.getVL());
|
||||
if(!ret->isValueH160())
|
||||
{
|
||||
delete ret;
|
||||
throw(std::runtime_error("invalid account in transaction"));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool STAccount::isValueH160() const
|
||||
{
|
||||
return peekValue().size() == (160/8);
|
||||
}
|
||||
|
||||
void STAccount::setValueH160(const uint160& v)
|
||||
{
|
||||
peekValue().empty();
|
||||
peekValue().insert(peekValue().end(), v.begin(), v.end());
|
||||
}
|
||||
|
||||
bool STAccount::getValueH160(uint160& v) const
|
||||
{
|
||||
if(!isValueH160()) return false;
|
||||
memcpy(v.begin(), &(peekValue().front()), 32);
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string STTaggedList::getText() const
|
||||
{
|
||||
std::string ret;
|
||||
@@ -128,3 +167,4 @@ int STTaggedList::getLength() const
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user