コード例 #1
0
bool STAccount::getValueH160 (uint160& v) const
{
    if (!isValueH160 ()) return false;

    memcpy (v.begin (), & (peekValue ().front ()), (160 / 8));
    return true;
}
コード例 #2
0
void RippleAddress::setAccountID(const uint160& hash160)
{
    SetData(VER_ACCOUNT_ID, hash160.begin(), 20);
}
コード例 #3
0
void STAccount::setValueH160(const uint160& v)
{
	peekValue().clear();
	peekValue().insert(peekValue().end(), v.begin(), v.end());
	assert(peekValue().size() == (160/8));
}
コード例 #4
0
STAccount::STAccount(SField::ref n, const uint160& v) : STVariableLength(n)
{
	peekValue().insert(peekValue().end(), v.begin(), v.end());
}
コード例 #5
0
TER WalletAddTransactor::doApply ()
{
    std::uint32_t const uTxFlags = mTxn.getFlags ();

    if (uTxFlags & tfUniversalMask)
    {
        m_journal.trace <<
            "Malformed transaction: Invalid flags set.";

        return temINVALID_FLAG;
    }

    Blob const vucPubKey    = mTxn.getFieldVL (sfPublicKey);
    Blob const vucSignature = mTxn.getFieldVL (sfSignature);

    uint160 const uAuthKeyID (mTxn.getFieldAccount160 (sfRegularKey));
    RippleAddress const naMasterPubKey (
        RippleAddress::createAccountPublic (vucPubKey));
    uint160 const uDstAccountID (naMasterPubKey.getAccountID ());

    // FIXME: This should be moved to the transaction's signature check logic and cached
	if (!naMasterPubKey.verifySignature(
        Serializer::getSHA512Half (uAuthKeyID.begin (), uAuthKeyID.size ()), 
        vucSignature))
    {
        m_journal.trace <<
            "Unauthorized: bad signature ";
        return tefBAD_ADD_AUTH;
    }

    SLE::pointer sleDst (mEngine->entryCache (
        ltACCOUNT_ROOT, Ledger::getAccountRootIndex (uDstAccountID)));

    if (sleDst)
    {
        m_journal.trace <<
            "account already created";
        return tefCREATED;
    }

    // Direct STR payment.

    STAmount saDstAmount = mTxn.getFieldAmount (sfAmount);
    STAmount saPaid = mTxn.getTransactionFee ();
    STAmount const saSrcBalance = mTxnAccount->getFieldAmount (sfBalance);
    std::uint32_t const uOwnerCount = mTxnAccount->getFieldU32 (sfOwnerCount);
    std::uint64_t const uReserve = mEngine->getLedger ()->getReserve (uOwnerCount);
    

    // Make sure have enough reserve to send. Allow final spend to use reserve
    // for fee.
    // Note: Reserve is not scaled by fee.
    if (saSrcBalance + saPaid < saDstAmount + uReserve)
    {
        // Vote no. However, transaction might succeed, if applied in a
        // different order.
        m_journal.trace <<
            "Delay transaction: Insufficient funds: %s / %s (%d)" <<
            saSrcBalance.getText () << " / " <<
            (saDstAmount + uReserve).getText () << " with reserve = " <<
            uReserve;
        return tecUNFUNDED_ADD;
    }

    // Deduct initial balance from source account.
    mTxnAccount->setFieldAmount (sfBalance, saSrcBalance - saDstAmount);

    // Create the account.
    sleDst  = mEngine->entryCreate (ltACCOUNT_ROOT,
        Ledger::getAccountRootIndex (uDstAccountID));

    sleDst->setFieldAccount (sfAccount, uDstAccountID);
    sleDst->setFieldU32 (sfSequence, 1);
    sleDst->setFieldAmount (sfBalance, saDstAmount);
    sleDst->setFieldAccount (sfRegularKey, uAuthKeyID);

    return tesSUCCESS;
}