package Ġcom . template . flows Ċ Ċ import Ġco . parallel universe . fib ers . Suspend able Ċ import Ġcom . template . contracts . Property Contract Ċ import Ġcom . template . states . Property State Ċ import Ġnet . cord a . core . contracts . Command Ċ import Ġnet . cord a . core . contracts . Unique Identifier Ċ import Ġnet . cord a . core . flows .* Ċ import Ġnet . cord a . core . identity . Party Ċ import Ġnet . cord a . core . node . services . query By Ċ import Ġnet . cord a . core . node . services . vault . Query Criteria Ċ import Ġnet . cord a . core . transactions . Signed Transaction Ċ import Ġnet . cord a . core . transactions . Transaction Builder Ċ import Ġnet . cord a . core . utilities . Progress Tracker Ċ Ċ // Ġ********* Ċ // Ġ* ĠFlow s Ġ* Ċ // Ġ********* Ċ @ Initi ating Flow Ċ @ Start able By RPC Ċ class ĠS ell Property Flow Init iator ( ĊĠĠĠ Ġprivate Ġval Ġbuy ers : ĠList < Party >, ĊĠĠĠ Ġprivate Ġval Ġnot ary ToUse : ĠParty , ĊĠĠĠ Ġprivate Ġval Ġlinear Id Ġ: ĠUnique Identifier Ċ ) Ġ: ĠFlow Logic < Signed Transaction >() Ġ{ ĊĠĠĠ Ġoverride Ġval Ġprogress Tracker Ġ= ĠProgress Tracker () ĊĊĠĠĠ Ġ@ Suspend able ĊĠĠĠ Ġoverride Ġfun Ġcall (): ĠSigned Transaction Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġquery Criteria Ġ= ĠQuery Criteria . Linear State Query Criteria ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlinear Id Ġ= ĠlistOf ( linear Id )) ĊĊĠĠĠĠĠĠĠ Ġval Ġresults Ġ= Ġservice Hub . vault Service . query By < Property State >( query Criteria ) ĊĠĠĠĠĠĠĠ Ġval Ġinput Property Ġ= Ġresults . states . single OrNull () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ?: Ġthrow ĠFlow Exception (" No Ġsuch Ġstate ") ĊĊĠĠĠĠĠĠĠ Ġval Ġoutput Property Ġ= Ġinput Property . state . data . copy ( owners Ġ= Ġbuy ers ) ĊĊĠĠĠĠĠĠĠ Ġval Ġinput State Ġ= Ġinput Property . state . data ĊĊĠĠĠĠĠĠĠ Ġval Ġparticipants Ġ= Ġ( input State . participants Ġ+ Ġoutput Property . participants ). toSet () ĊĠĠĠĠĠĠĠ Ġval Ġsign ers Ġ= Ġparticipants . map Ġ{ Ġit . own ing Key Ġ} ĊĊĠĠĠĠĠĠĠ Ġval Ġsell Property Command Ġ= ĠCommand ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠProperty Contract . Commands . Sell (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsign ers ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġtransaction Builder Ġ= ĠTransaction Builder ( not ary ToUse ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Input State ( input Property ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Output State ( output Property , ĠProperty Contract . ID ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Command ( sell Property Command ) ĊĊĠĠĠĠĠĠĠ Ġtransaction Builder . verify ( service Hub ) ĊĊĠĠĠĠĠĠĠ Ġval Ġpartially Signed Transaction Ġ= Ġservice Hub . sign Initial Transaction ( transaction Builder ) ĊĊĠĠĠĠĠĠĠ Ġval Ġsessions Ġ= Ġ( participants Ġ- Ġour Identity ). map Ġ{ Ġinitiate Flow ( it ) Ġ}. toSet () ĊĊĠĠĠĠĠĠĠ Ġval Ġfully Signed Transaction Ġ= Ġsub Flow ( Collect Signatures Flow ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpartially Signed Transaction , Ġsessions ĊĠĠĠĠĠĠĠ Ġ)) ĊĠĠĠĠĠĠĠ Ġreturn Ġsub Flow ( Final ity Flow ( fully Signed Transaction , Ġsessions )) ĊĊĠĠĠ Ġ} Ċ } Ċ Ċ @ Initi ated By ( Sell Property Flow Init iator :: class ) Ċ class ĠS ell Property Flow Responder ( val Ġcounter party Session : ĠFlow Session ) Ġ: ĠFlow Logic < Signed Transaction >() Ġ{ ĊĠĠĠ Ġ@ Suspend able ĊĠĠĠ Ġoverride Ġfun Ġcall (): ĠSigned Transaction Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġsign Transaction Flow Ġ= Ġobject Ġ: ĠSign Transaction Flow ( counter party Session ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġoverride Ġfun Ġcheck Transaction ( st x : ĠSigned Transaction ) Ġ{} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġval Ġtx Id Ġ= Ġsub Flow ( sign Transaction Flow ). id ĊĊĠĠĠĠĠĠĠ Ġreturn Ġsub Flow ( Receive Final ity Flow ( counter party Session , Ġexpected Tx Id Ġ= Ġtx Id )) ĊĠĠĠ Ġ} Ċ } Ċ