Add owner_funds to subscription streams (RIPD-377)

This commit is contained in:
Miguel Portilla
2014-07-21 13:09:33 -04:00
committed by Vinnie Falco
parent af7cd3cc04
commit 8368798ad2
2 changed files with 19 additions and 4 deletions

View File

@@ -94,7 +94,7 @@ void AcceptedLedgerTx::buildJson ()
LedgerEntrySet les (mLedger, tapNONE, true);
auto const ownerFunds (les.accountFunds (account, amount, fhIGNORE_FREEZE));
mJson[jss::owner_funds] = ownerFunds.getText ();
mJson[jss::transaction][jss::owner_funds] = ownerFunds.getText ();
}
}
}

View File

@@ -2619,12 +2619,12 @@ void NetworkOPsImp::reportFeeChange ()
std::bind (&NetworkOPsImp::pubServer, this));
}
Json::Value NetworkOPsImp::transJson (
// This routine should only be used to publish accepted or validated
// transactions.
Json::Value NetworkOPsImp::transJson(
const SerializedTransaction& stTxn, TER terResult, bool bValidated,
Ledger::ref lpCurrent)
{
// This routine should only be used to publish accepted or validated
// transactions.
Json::Value jvObj (Json::objectValue);
std::string sToken;
std::string sHuman;
@@ -2655,6 +2655,21 @@ Json::Value NetworkOPsImp::transJson (
jvObj[jss::engine_result_code] = terResult;
jvObj[jss::engine_result_message] = sHuman;
if (stTxn.getTxnType() == ttOFFER_CREATE)
{
auto const account (stTxn.getSourceAccount ().getAccountID ());
auto const amount (stTxn.getFieldAmount (sfTakerGets));
// If the offer create is not self funded then add the owner balance
if (account != amount.issue ().account)
{
LedgerEntrySet les (lpCurrent, tapNONE, true);
auto const ownerFunds (les.accountFunds (account, amount, fhIGNORE_FREEZE));
jvObj[jss::transaction][jss::owner_funds] = ownerFunds.getText ();
}
}
return jvObj;
}