package Ġcom . r 3 . cord a . lib . accounts . workflows . flows Ċ Ċ import Ġco . parallel universe . fib ers . Suspend able Ċ import Ġcom . r 3 . cord a . lib . accounts . contracts . states . Account Info Ċ import Ġnet . cord a . core . contracts . State And Ref Ċ import Ġnet . cord a . core . flows .* Ċ import Ġnet . cord a . core . identity . Party Ċ import Ġnet . cord a . core . node . States To Record Ċ Ċ /** Ċ Ġ* ĠSh ares Ġan Ġ[ Account Info ] Ġ[ State And Ref ] Ġwith Ġthe Ġparties Ġrepresented Ġby Ġthe Ġspecified Ġ[ Flow Session ] s . ĠThe Ġ[ Account Info ] Ċ Ġ* Ġis Ġalways Ġstored Ġusing Ġ[ States To Record . ALL _ VISIBLE ]. Ċ Ġ* Ċ Ġ* Ġ@ property Ġaccount Info Ġthe Ġstate Ġand Ġref Ġof Ġthe Ġaccount Ġinfo Ġto Ġshare . ĠIt Ġmust Ġbe Ġlooked - up Ġbefore Ġhand . Ċ Ġ* Ġ@ property Ġrecipients Ġthe Ġflow Ġsessions Ġfor Ġthe Ġparties Ġto Ġreceive Ġthe Ġ[ Account Info ] Ġ[ State And Ref ]. Ċ Ġ*/ Ċ class ĠShare Account Info Flow ( ĊĠĠĠĠĠĠĠ Ġval Ġaccount Info : ĠState And Ref < Account Info >, ĊĠĠĠĠĠĠĠ Ġval Ġrecipients : ĠList < Flow Session > Ċ ) Ġ: ĠFlow Logic < Unit >() Ġ{ ĊĠĠĠ Ġ@ Suspend able ĊĠĠĠ Ġoverride Ġfun Ġcall () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġtx Hash Ġ= Ġaccount Info . ref . tx hash ĊĠĠĠĠĠĠĠ Ġ// ĠWe Ġmust Ġuse ĠSend Transaction Flow Ġas ĠSend State And Ref Flow Ġdoesn 't Ġlet Ġus Ġoverride ĠStates To Record . ĊĠĠĠĠĠĠĠ Ġval Ġtransaction ToSend Ġ= Ġservice Hub . validated Transactions . getTransaction ( tx Hash ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ?: Ġthrow ĠFlow Exception (" Can 't Ġfind Ġtransaction Ġwith Ġhash Ġ$ tx Hash ") ĊĠĠĠĠĠĠĠ Ġrecipients . forEach Ġ{ Ġsession Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsub Flow ( Send Transaction Flow ( session , Ġtransaction ToSend )) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ Ċ /** Ċ Ġ* ĠRes pon der Ġflow Ġfor Ġ[ Share Account Info Flow ]. Ċ Ġ*/ Ċ class ĠShare Account Info Handler Flow ( val Ġother Session : ĠFlow Session ) Ġ: ĠFlow Logic < Account Info >() Ġ{ ĊĠĠĠ Ġ@ Suspend able ĊĠĠĠ Ġoverride Ġfun Ġcall (): ĠAccount Info Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġtransaction Ġ= Ġsub Flow ( Receive Transaction Flow ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġother Side Session Ġ= Ġother Session , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġstates To Record Ġ= ĠStates To Record . ALL _ VISIBLE ĊĠĠĠĠĠĠĠ Ġ)) ĊĠĠĠĠĠĠĠ Ġreturn Ġtransaction . core Transaction . outputs OfType ( Account Info :: class . java ). single () ĊĠĠĠ Ġ} Ċ } Ċ Ċ // ĠInit i ating Ġversions Ġof Ġthe Ġabove Ġflows . Ċ Ċ /** Ċ Ġ* ĠSh ares Ġan Ġ[ Account Info ] Ġ[ State And Ref ] Ġwith Ġthe Ġsupplied Ġ[ Party ] s . ĠThe Ġ[ Account Info ] Ġis Ġalways Ġstored Ġusing Ċ Ġ* Ġ[ States To Record . ALL _ VISIBLE ]. Ċ Ġ* Ċ Ġ* Ġ@ property Ġaccount Info Ġthe Ġstate Ġand Ġref Ġof Ġthe Ġaccount Ġinfo Ġto Ġshare . ĠIt Ġmust Ġbe Ġlooked - up Ġbefore Ġhand . Ċ Ġ* Ġ@ property Ġrecipients Ġthe Ġparties Ġto Ġreceive Ġthe Ġ[ Account Info ] Ġ[ State And Ref ]. Ċ Ġ*/ Ċ @ Start able By RPC Ċ @ Start able By Service Ċ @ Initi ating Flow Ċ class ĠShare Account Info ( val Ġaccount Info : ĠState And Ref < Account Info >, Ġval Ġrecipients : ĠList < Party >) Ġ: ĠFlow Logic < Unit >() Ġ{ ĊĠĠĠ Ġ@ Suspend able ĊĠĠĠ Ġoverride Ġfun Ġcall () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġsessions Ġ= Ġrecipients . map Ġ{ Ġrecipient Ġ-> Ġinitiate Flow ( recipient ) Ġ} ĊĠĠĠĠĠĠĠ Ġreturn Ġsub Flow ( Share Account Info Flow ( account Info , Ġsessions )) ĊĠĠĠ Ġ} Ċ } Ċ Ċ /** Ċ Ġ* ĠRes pon der Ġflow Ġfor Ġ[ Share Account Info ]. Ċ Ġ*/ Ċ @ Initi ated By ( Share Account Info :: class ) Ċ class ĠShare Account Info Handler ( val Ġother Session : ĠFlow Session ) Ġ: ĠFlow Logic < Unit >() Ġ{ ĊĠĠĠ Ġ@ Suspend able ĊĠĠĠ Ġoverride Ġfun Ġcall () Ġ{ ĊĠĠĠĠĠĠĠ Ġsub Flow ( Share Account Info Handler Flow ( other Session )) ĊĠĠĠ Ġ} Ċ } Ċ