@@ -1085,7 +1085,9 @@ bool CheckOfferInputs(CBlockIndex *pindexBlock, const CTransaction &tx,
10851085
10861086 if (fBlock && !fJustCheck ) {
10871087 // Check hash
1088+ const vector<unsigned char > &vchOffer = vvchArgs[0 ];
10881089 const vector<unsigned char > &vchAcceptRand = vvchArgs[1 ];
1090+ nPrevHeight = GetOfferHeight (vchOffer);
10891091
10901092 // check for existence of offeraccept in txn offer obj
10911093 if (!theOffer.GetAcceptByHash (vchAcceptRand, theOfferAccept))
@@ -1928,21 +1930,35 @@ Value offerinfo(const Array& params, bool fHelp) {
19281930 }
19291931 int nHeight;
19301932 uint256 offerHash;
1933+ int expired;
1934+ int expires_in;
1935+ int expired_block;
1936+
1937+ expired = 0 ;
1938+ expires_in = 0 ;
1939+ expired_block = 0 ;
19311940 if (GetValueOfOfferTxHash (txHash, vchValue, offerHash, nHeight)) {
19321941 oOffer.push_back (Pair (" id" , offer));
19331942 oOffer.push_back (Pair (" txid" , tx.GetHash ().GetHex ()));
19341943 oOffer.push_back (Pair (" service_fee" , ValueFromAmount (theOffer.nFee )));
19351944 string strAddress = " " ;
19361945 GetOfferAddress (tx, strAddress);
19371946 oOffer.push_back (Pair (" address" , strAddress));
1938- oOffer.push_back (
1939- Pair (" expires_in" ,
1940- nHeight + GetOfferExpirationDepth (nHeight)
1941- - pindexBest->nHeight ));
1942- if (nHeight + GetOfferExpirationDepth (nHeight)
1943- - pindexBest->nHeight <= 0 ) {
1944- oOffer.push_back (Pair (" expired" , 1 ));
1947+
1948+ if (nHeight + GetOfferDisplayExpirationDepth (nHeight) - pindexBest->nHeight <= 0 )
1949+ {
1950+ expired = 1 ;
1951+ expired_block = nHeight + GetOfferDisplayExpirationDepth (nHeight);
1952+ }
1953+ if (expired == 0 )
1954+ {
1955+ expires_in = nHeight + GetOfferDisplayExpirationDepth (nHeight) - pindexBest->nHeight ;
19451956 }
1957+ oOffer.push_back (Pair (" expires_in" , expires_in));
1958+ oOffer.push_back (Pair (" expired_block" , expired_block));
1959+ oOffer.push_back (Pair (" expired" , expired));
1960+
1961+
19461962 oOffer.push_back (Pair (" payment_address" , stringFromVch (theOffer.vchPaymentAddress )));
19471963 oOffer.push_back (Pair (" category" , stringFromVch (theOffer.sCategory )));
19481964 oOffer.push_back (Pair (" title" , stringFromVch (theOffer.sTitle )));
@@ -1985,15 +2001,14 @@ Value offerlist(const Array& params, bool fHelp) {
19852001 int pending;
19862002 int expires_in;
19872003 int expired_block;
1988- vector<unsigned char > vchValue;
19892004 int nHeight;
19902005
19912006 BOOST_FOREACH (PAIRTYPE (const uint256, CWalletTx)& item, pwalletMain->mapWallet )
19922007 {
19932008 expired = 0 ;
19942009 pending = 0 ;
1995- expires_in = - 1 ;
1996- expired_block - 1 ;
2010+ expires_in = 0 ;
2011+ expired_block = 0 ;
19972012 // get txn hash, read txn index
19982013 hash = item.second .GetHash ();
19992014
@@ -2023,41 +2038,33 @@ Value offerlist(const Array& params, bool fHelp) {
20232038 if (vchNameUniq.size () > 0 && vchNameUniq != vchName)
20242039 continue ;
20252040
2026- // get the value of the alias txn
2027- if (!GetValueOfOfferTx (tx, vchValue))
2028- continue ;
2029-
2030- uint64 nQty;
20312041 vector<COffer> vtxPos;
2042+ COffer theOfferA;
20322043 if (!pofferdb->ReadOffer (vchName, vtxPos))
2044+ {
20332045 pending = 1 ;
2046+ theOfferA = COffer (tx);
2047+ }
20342048 if (vtxPos.size () < 1 )
2049+ {
20352050 pending = 1 ;
2036-
2037- COffer theOfferA (tx);
2038- if (pending == 1 ) {
2039- nQty = theOfferA.nQty ;
2040- } else {
2041- nQty = vtxPos.back ().nQty ;
2051+ theOfferA = COffer (tx);
2052+ }
2053+ if (pending != 1 )
2054+ {
2055+ theOfferA = vtxPos.back ();
20422056 }
2043-
2057+
20442058 // build the output object
20452059 Object oName;
20462060 oName.push_back (Pair (" name" , stringFromVch (vchName)));
2047- oName.push_back (Pair (" value" , stringFromVch (vchValue)));
2048-
2049-
20502061 oName.push_back (Pair (" category" , stringFromVch (theOfferA.sCategory )));
20512062 oName.push_back (Pair (" description" , stringFromVch (theOfferA.sDescription )));
20522063 oName.push_back (Pair (" price" , ValueFromAmount (theOfferA.nPrice ) ) );
2053- oName.push_back (Pair (" quantity" , strprintf (" %llu" , nQty)));
2054-
2055- string strAddress = " " ;
2056- GetOfferAddress (tx, strAddress);
2057- oName.push_back (Pair (" address" , strAddress));
2058-
2059-
2064+ oName.push_back (Pair (" quantity" , strprintf (" %llu" , theOfferA.nQty )));
2065+ oName.push_back (Pair (" address" , stringFromVch (theOfferA.vchPaymentAddress )));
20602066
2067+
20612068 if (pending == 0 && (nHeight + GetOfferDisplayExpirationDepth (nHeight) - pindexBest->nHeight <= 0 ))
20622069 {
20632070 expired = 1 ;
0 commit comments