2424#include " wallet/transactions/swaps/swap_tx_description.h"
2525#endif // BEAM_ATOMIC_SWAP_SUPPORT
2626#include < regex>
27+ #include < string_view>
2728
2829namespace beam ::wallet {
2930 namespace {
@@ -145,6 +146,10 @@ void GetStatusResponseJson(const TxDescription& tx,
145146 };
146147 statusInterpreter = std::make_unique<AssetTxStatusInterpreter>(tx);
147148 }
149+ else if (tx.m_txType == TxType::PushTransaction)
150+ {
151+ statusInterpreter = std::make_unique<MaxPrivacyTxStatusInterpreter>(tx);
152+ }
148153 else if (tx.m_txType == TxType::AtomicSwap)
149154 {
150155 #ifdef BEAM_ATOMIC_SWAP_SUPPORT
@@ -156,8 +161,8 @@ void GetStatusResponseJson(const TxDescription& tx,
156161 {" txId" , TxIDToString (tx.m_txId )},
157162 {" status" , tx.m_status },
158163 {" status_string" , statusInterpreter ? statusInterpreter->getStatus () : " unknown" },
159- {" sender" , std::to_string ( tx.m_sender ? tx. m_myId : tx. m_peerId )},
160- {" receiver" , std::to_string ( tx.m_sender ? tx. m_peerId : tx. m_myId )},
164+ {" sender" , tx.getAddressFrom ( )},
165+ {" receiver" , tx.getAddressTo ( )},
161166 {" value" , tx.m_amount },
162167 {" comment" , std::string{ tx.m_message .begin (), tx.m_message .end () }},
163168 {" create_time" , tx.m_createTime },
@@ -849,7 +854,37 @@ OfferInput collectOfferInput(const JsonRpcId& id, const json& params)
849854 void WalletApi::onCreateAddressMessage (const JsonRpcId& id, const json& params)
850855 {
851856 CreateAddress createAddress;
857+
852858 FillAddressData (id, params, createAddress);
859+
860+ auto it = params.find (" type" );
861+ if (it != params.end ())
862+ {
863+ static constexpr std::array<std::pair<std::string_view, TxAddressType>, 4 > types =
864+ {
865+ {
866+ {" regular" , TxAddressType::Regular},
867+ {" offline" , TxAddressType::Offline},
868+ {" max_privacy" , TxAddressType::MaxPrivacy},
869+ {" public_offline" , TxAddressType::PublicOffline}
870+ }
871+ };
872+ auto t = std::find_if (types.begin (), types.end (), [&](const auto & p) { return p.first == it->get <std::string>(); });
873+ if (t != types.end ())
874+ {
875+ createAddress.type = t->second ;
876+ }
877+ }
878+ it = params.find (" new_style_regular" );
879+ if (it != params.end ())
880+ {
881+ createAddress.newStyleRegular = it->get <bool >();
882+ }
883+ it = params.find (" offline_payments" );
884+ if (it != params.end ())
885+ {
886+ createAddress.offlinePayments = it->get <uint32_t >();
887+ }
853888 getHandler ().onMessage (id, createAddress);
854889 }
855890
@@ -930,21 +965,18 @@ OfferInput collectOfferInput(const JsonRpcId& id, const json& params)
930965 auto txParams = ParseParameters (addressOrToken);
931966 if (!txParams)
932967 {
933- throw jsonrpc_exception{ ApiError::InvalidAddress , " Invalid receiver address or token ." , id };
968+ throw jsonrpc_exception{ ApiError::InvalidAddress , " Invalid receiver address." , id };
934969 }
935- send.txParameters = *txParams;
936-
937- if (auto peerID = send. txParameters . GetParameter <WalletID>(TxParameterID::PeerID); peerID)
970+ send.txParameters = std::move ( *txParams) ;
971+ auto peerID = send. txParameters . GetParameter <WalletID>(beam::wallet::TxParameterID::PeerID);
972+ if (peerID)
938973 {
939974 send.address = *peerID;
940- if (std::to_string (*peerID) != addressOrToken)
941- {
942- send.txParameters .SetParameter (beam::wallet::TxParameterID::OriginalToken, addressOrToken);
943- }
944975 }
945- else
976+
977+ if (!peerID || std::to_string (*peerID) != addressOrToken)
946978 {
947- throw jsonrpc_exception{ ApiError::InvalidAddress , " Invalid receiver address. " , id } ;
979+ send. txParameters . SetParameter (beam::wallet::TxParameterID::OriginalToken, addressOrToken) ;
948980 }
949981
950982 if (existsJsonParam (params, " from" ))
@@ -1487,7 +1519,7 @@ OfferInput collectOfferInput(const JsonRpcId& id, const json& params)
14871519 {
14881520 {JsonRpcHrd, JsonRpcVerHrd},
14891521 {" id" , id},
1490- {" result" , std::to_string ( res.address ) }
1522+ {" result" , res.address }
14911523 };
14921524 }
14931525
@@ -1760,7 +1792,8 @@ OfferInput collectOfferInput(const JsonRpcId& id, const json& params)
17601792 resItem.tx ,
17611793 item,
17621794 resItem.txHeight ,
1763- resItem.systemHeight );
1795+ resItem.systemHeight ,
1796+ true );
17641797 msg[" result" ].push_back (item);
17651798 }
17661799 }
0 commit comments