[{"data":1,"prerenderedAt":390},["ShallowReactive",2],{"docs-\u002Fdocs\u002Fcore-tech\u002Fprogramming-beam-wallet-transactions":3,"docs-surround-\u002Fdocs\u002Fcore-tech\u002Fprogramming-beam-wallet-transactions":381},{"id":4,"title":5,"body":6,"description":12,"extension":374,"image":375,"meta":376,"navTitle":375,"navigation":153,"path":377,"seo":378,"stem":379,"__hash__":380},"docs\u002Fdocs\u002Fcore-tech\u002FProgramming-Beam-Wallet-Transactions.md","Programming Beam Wallet Transactions",{"type":7,"value":8,"toc":360},"minimark",[9,13,18,21,31,43,47,56,69,72,131,141,144,160,164,172,182,185,189,192,336,346,353,356],[10,11,12],"p",{},"This section describes the structure of Beam transactions. Transactions are created and managed locally in the Beam wallet.",[14,15,17],"h2",{"id":16},"transaction-parameters","Transaction parameters",[10,19,20],{},"Transactions are defined and stored in the database as a set of transaction parameters, thus allowing a lot of flexibility.",[10,22,23,24],{},"The complete list of transaction parameters is defined ",[25,26,30],"a",{"href":27,"rel":28},"https:\u002F\u002Fgithub.com\u002FBeamMW\u002Fbeam\u002Fblob\u002Fedf0bb8a16626f6e1160bc09a7af4e0a40adb813\u002Fwallet\u002Fcommon.h#L226",[29],"nofollow","here",[10,32,33,34,38,39,42],{},"Transaction parameters are divided into two groups. ",[35,36,37],"strong",{},"Public"," parameters can be set during the interaction between wallets. Once public parameter is set, it can not be changed. ",[35,40,41],{},"Private"," parameters, can be set and reset at any time within the wallet and are not sent outside the wallet. The reason for this separation is to maintain a clear distinction between the parameters that are revealed to or received from the other wallet and can thus irreversibly affect the state of negotiation between the wallets creating the transaction.",[14,44,46],{"id":45},"transaction-id","Transaction id",[10,48,49,50,55],{},"TxID, ",[25,51,54],{"href":52,"rel":53},"https:\u002F\u002Fgithub.com\u002FBeamMW\u002Fbeam\u002Fblob\u002Fedf0bb8a16626f6e1160bc09a7af4e0a40adb813\u002Fwallet\u002Fcommon.h#L37",[29],"defined here"," is the unique id of the transaction",[14,57,59,60],{"id":58},"itransaction-interface-definition","ITransaction interface ",[61,62,63,64],"span",{}," ",[25,65,68],{"href":66,"rel":67},"https:\u002F\u002Fgithub.com\u002FBeamMW\u002Fbeam\u002Fblob\u002Fedf0bb8a16626f6e1160bc09a7af4e0a40adb813\u002Fwallet\u002Fbase_transaction.h#L28",[29],"definition",[10,70,71],{},"Defines basic set of operations for each transaction, Update, Cancel and Rollback",[73,74,79],"pre",{"className":75,"code":76,"language":77,"meta":78,"style":78},"language-c++ shiki shiki-themes github-dark","struct ITransaction\n    {\n        using Ptr = std::shared_ptr\u003CITransaction>;\n        virtual TxType GetType() const = 0;\n        virtual void Update() = 0;\n        virtual void Cancel() = 0;\n        virtual bool Rollback(Height height) = 0;\n    };\n\n","c++","",[80,81,82,89,95,101,107,113,119,125],"code",{"__ignoreMap":78},[61,83,86],{"class":84,"line":85},"line",1,[61,87,88],{},"struct ITransaction\n",[61,90,92],{"class":84,"line":91},2,[61,93,94],{},"    {\n",[61,96,98],{"class":84,"line":97},3,[61,99,100],{},"        using Ptr = std::shared_ptr\u003CITransaction>;\n",[61,102,104],{"class":84,"line":103},4,[61,105,106],{},"        virtual TxType GetType() const = 0;\n",[61,108,110],{"class":84,"line":109},5,[61,111,112],{},"        virtual void Update() = 0;\n",[61,114,116],{"class":84,"line":115},6,[61,117,118],{},"        virtual void Cancel() = 0;\n",[61,120,122],{"class":84,"line":121},7,[61,123,124],{},"        virtual bool Rollback(Height height) = 0;\n",[61,126,128],{"class":84,"line":127},8,[61,129,130],{},"    };\n",[14,132,134,135],{"id":133},"basetransaction-definition","BaseTransaction ",[61,136,63,137],{},[25,138,68],{"href":139,"rel":140},"https:\u002F\u002Fgithub.com\u002FBeamMW\u002Fbeam\u002Fblob\u002Fedf0bb8a16626f6e1160bc09a7af4e0a40adb813\u002Fwallet\u002Fbase_transaction.h#L55",[29],[10,142,143],{},"Implements the ITransaction interface and provides the state machine for creation of transactions. Constructor for BaseTransaction receives three parameters:",[73,145,147],{"className":75,"code":146,"language":77,"meta":78,"style":78},"\nBaseTransaction(INegotiatorGateway& gateway, beam::IWalletDB::Ptr walletDB, const TxID& txID);\n\n",[80,148,149,155],{"__ignoreMap":78},[61,150,151],{"class":84,"line":85},[61,152,154],{"emptyLinePlaceholder":153},true,"\n",[61,156,157],{"class":84,"line":91},[61,158,159],{},"BaseTransaction(INegotiatorGateway& gateway, beam::IWalletDB::Ptr walletDB, const TxID& txID);\n",[14,161,163],{"id":162},"basetxbuilder","BaseTxBuilder",[10,165,166,167,171],{},"This class encapsulates all the methods necessary for transaction creation following the protocol described ",[25,168,30],{"href":169,"rel":170},"https:\u002F\u002Fgithub.com\u002FBeamMW\u002Fbeam\u002Fwiki\u002FTransaction-creation-protocol",[29],".",[14,173,175,176],{"id":174},"inegotiatorgateway-definition","INegotiatorGateway ",[61,177,63,178],{},[25,179,68],{"href":180,"rel":181},"https:\u002F\u002Fgithub.com\u002FBeamMW\u002Fbeam\u002Fblob\u002Fedf0bb8a16626f6e1160bc09a7af4e0a40adb813\u002Fwallet\u002Fcommon.h#L409",[29],[10,183,184],{},"Negotiator Gateway provides an abstraction of the messaging between the node or another wallet during the transaction creation. The INegotiatorGateway interface is implemented by the Wallet class.",[14,186,188],{"id":187},"basetransactionupdate-method","BaseTransaction::Update method",[10,190,191],{},"The Update method describes generic logic of asynchronous transaction update. The update logic is implemented in the UpdateImpl method described below.",[73,193,195],{"className":75,"code":194,"language":77,"meta":78,"style":78},"\nvoid BaseTransaction::Update()\n    {\n        AsyncContextHolder async(m_Gateway);\n        try\n        {\n            if (CheckExternalFailures())\n            {\n                return;\n            }\n\n            UpdateImpl();\n\n            CheckExpired();\n        }\n        catch (const TransactionFailedException& ex)\n        {\n            LOG_ERROR() \u003C\u003C GetTxID() \u003C\u003C \" exception msg: \" \u003C\u003C ex.what();\n            OnFailed(ex.GetReason(), ex.ShouldNofify());\n        }\n        catch (const exception& ex)\n        {\n            LOG_ERROR() \u003C\u003C GetTxID() \u003C\u003C \" exception msg: \" \u003C\u003C ex.what();\n            OnFailed(TxFailureReason::Unknown);\n        }\n    }\n\n",[80,196,197,201,206,210,215,220,225,230,235,241,247,252,258,263,269,275,281,286,292,298,303,309,314,319,325,330],{"__ignoreMap":78},[61,198,199],{"class":84,"line":85},[61,200,154],{"emptyLinePlaceholder":153},[61,202,203],{"class":84,"line":91},[61,204,205],{},"void BaseTransaction::Update()\n",[61,207,208],{"class":84,"line":97},[61,209,94],{},[61,211,212],{"class":84,"line":103},[61,213,214],{},"        AsyncContextHolder async(m_Gateway);\n",[61,216,217],{"class":84,"line":109},[61,218,219],{},"        try\n",[61,221,222],{"class":84,"line":115},[61,223,224],{},"        {\n",[61,226,227],{"class":84,"line":121},[61,228,229],{},"            if (CheckExternalFailures())\n",[61,231,232],{"class":84,"line":127},[61,233,234],{},"            {\n",[61,236,238],{"class":84,"line":237},9,[61,239,240],{},"                return;\n",[61,242,244],{"class":84,"line":243},10,[61,245,246],{},"            }\n",[61,248,250],{"class":84,"line":249},11,[61,251,154],{"emptyLinePlaceholder":153},[61,253,255],{"class":84,"line":254},12,[61,256,257],{},"            UpdateImpl();\n",[61,259,261],{"class":84,"line":260},13,[61,262,154],{"emptyLinePlaceholder":153},[61,264,266],{"class":84,"line":265},14,[61,267,268],{},"            CheckExpired();\n",[61,270,272],{"class":84,"line":271},15,[61,273,274],{},"        }\n",[61,276,278],{"class":84,"line":277},16,[61,279,280],{},"        catch (const TransactionFailedException& ex)\n",[61,282,284],{"class":84,"line":283},17,[61,285,224],{},[61,287,289],{"class":84,"line":288},18,[61,290,291],{},"            LOG_ERROR() \u003C\u003C GetTxID() \u003C\u003C \" exception msg: \" \u003C\u003C ex.what();\n",[61,293,295],{"class":84,"line":294},19,[61,296,297],{},"            OnFailed(ex.GetReason(), ex.ShouldNofify());\n",[61,299,301],{"class":84,"line":300},20,[61,302,274],{},[61,304,306],{"class":84,"line":305},21,[61,307,308],{},"        catch (const exception& ex)\n",[61,310,312],{"class":84,"line":311},22,[61,313,224],{},[61,315,317],{"class":84,"line":316},23,[61,318,291],{},[61,320,322],{"class":84,"line":321},24,[61,323,324],{},"            OnFailed(TxFailureReason::Unknown);\n",[61,326,328],{"class":84,"line":327},25,[61,329,274],{},[61,331,333],{"class":84,"line":332},26,[61,334,335],{},"    }\n",[14,337,339,340,345],{"id":338},"simpletransaction-wallet_transactionh","SimpleTransaction ( ",[25,341,344],{"href":342,"rel":343},"https:\u002F\u002Fgithub.com\u002FBeamMW\u002Fbeam\u002Fblob\u002Fedf0bb8a16626f6e1160bc09a7af4e0a40adb813\u002Fwallet\u002Fwallet_transaction.h#L1",[29],"wallet_transaction.h"," )",[10,347,348,349,352],{},"SimpleTransaction extends BaseTransaction and provides an implementation of the basic confidential transaction between two wallets. The key part of the implementation is the ",[80,350,351],{},"void SimpleTransaction::UpdateImpl()"," method that provides the state machine for the transaction creation logic.",[10,354,355],{},"\u002F\u002FTODO: Add detailed explanation for the transaction creation logic",[357,358,359],"style",{},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":78,"searchDepth":91,"depth":91,"links":361},[362,363,364,366,368,369,371,372],{"id":16,"depth":91,"text":17},{"id":45,"depth":91,"text":46},{"id":58,"depth":91,"text":365},"ITransaction interface  definition",{"id":133,"depth":91,"text":367},"BaseTransaction  definition",{"id":162,"depth":91,"text":163},{"id":174,"depth":91,"text":370},"INegotiatorGateway  definition",{"id":187,"depth":91,"text":188},{"id":338,"depth":91,"text":373},"SimpleTransaction ( wallet_transaction.h )","md",null,{},"\u002Fdocs\u002Fcore-tech\u002Fprogramming-beam-wallet-transactions",{"description":12},"docs\u002Fcore-tech\u002FProgramming-Beam-Wallet-Transactions","BSSvVzHpkIlin_bHZG-CAYy4hqtMYyXHB3ZVRIfQ5U0",[382,386],{"title":383,"path":384,"stem":385,"description":78,"children":-1},"Programming Beam Wallet","\u002Fdocs\u002Fcore-tech\u002Fprogramming-beam-wallet","docs\u002Fcore-tech\u002FProgramming-Beam-Wallet",{"title":387,"path":388,"stem":389,"description":78,"children":-1},"Proposal For I O Layer And P2P","\u002Fdocs\u002Fcore-tech\u002Fproposal-for-i-o-layer-and-p2p","docs\u002Fcore-tech\u002FProposal-for-I-O-layer-and-P2P",1783006082256]