package Ġcom . mar cus . flows Ċ Ċ import Ġco . parallel universe . fib ers . Suspend able Ċ import Ġcom . mar cus . contracts . Transfer Contract Ċ import Ġcom . mar cus . states . Account State Ċ import Ġcom . mar cus . states . Transfer State Ċ import Ġcom . mar cus . states . Transfer Status Ċ import Ġcom . mar cus . states . Wallet State Ċ import Ġcom . mar cus . utils .* Ċ import Ġnet . cord a . core . contracts . Amount Ċ import Ġnet . cord a . core . contracts . require That Ċ import Ġnet . cord a . core . flows .* Ċ import Ġnet . cord a . core . identity . Party Ċ import Ġnet . cord a . core . transactions . Signed Transaction Ċ import Ġnet . cord a . core . transactions . Wire Transaction Ċ import Ġnet . cord a . core . utilities . unwrap Ċ import Ġjava . util .* Ċ Ċ @ Initi ating Flow Ċ @ Start able By RPC Ċ class ĠRequest Transfer Flow ( ĊĠĠĠĠĠĠĠ Ġprivate Ġval Ġorigin : ĠParty , ĊĠĠĠĠĠĠĠ Ġprivate Ġval Ġamount : ĠAmount < Currency > Ċ ) Ġ: ĠBase Flow < Transfer State >() Ġ{ ĊĊĠĠĠ Ġ@ Suspend able ĊĠĠĠ Ġoverride Ġfun Ġcall (): ĠTransfer State Ġ{ ĊĠĠĠĠĠĠĠ Ġ// Ġinputs ĊĠĠĠĠĠĠĠ Ġval Ġdestination Wallet State And Ref Ġ= Ġfind My Wallet () ĊĠĠĠĠĠĠĠ Ġdestination Wallet State And Ref . require IsActive () ĊĊĠĠĠĠĠĠĠ Ġval Ġdestination Account State And Ref Ġ= Ġfind Account For Currency ( amount . token ) ĊĊĠĠĠĠĠĠĠ Ġval Ġcounter Party Session Flow Ġ= Ġinitiate Flow ( origin ) ĊĠĠĠĠĠĠĠ Ġcounter Party Session Flow . send ( amount . token ) ĊĊĠĠĠĠĠĠĠ Ġval Ġorigin Wallet State And Ref Ġ= Ġsub Flow ( Receive State And Ref Flow < Wallet State >( counter Party Session Flow )). single () ĊĠĠĠĠĠĠĠ Ġorigin Wallet State And Ref . require IsActive () ĊĊĠĠĠĠĠĠĠ Ġval Ġorigin Account State And Ref Ġ= Ġsub Flow ( Receive State And Ref Flow < Account State >( counter Party Session Flow )). single () ĊĊĠĠĠĠĠĠĠ Ġval Ġorigin Account State Ġ= Ġorigin Account State And Ref . get Contract State () ĊĠĠĠĠĠĠĠ Ġval Ġdestination Account State Ġ= Ġdestination Account State And Ref . get Contract State () ĊĊĠĠĠĠĠĠĠ Ġval Ġtransfer State Ġ= ĠTransfer State ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġorigin Account State . linear Id , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġdestination Account State . linear Id , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠTransfer Status . REQUEST ED , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠDate (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġnull , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġamount , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠlistOf ( our Identity , Ġorigin ) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġbuild Ġtransaction ĊĠĠĠĠĠĠĠ Ġval Ġorigin Key Ġ= Ġorigin . own ing Key ĊĠĠĠĠĠĠĠ Ġval Ġdestination Key Ġ= Ġour Identity . own ing Key ĊĠĠĠĠĠĠĠ Ġval Ġbuild Transaction Ġ= Ġbuild Transaction ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠTransfer Contract . Request Transfer Command () Ġto ĠlistOf ( origin Key , Ġdestination Key ) ĊĠĠĠĠĠĠĠ Ġ). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ// Ġadd Ġoutputs ĊĠĠĠĠĠĠĠĠĠĠĠ Ġadd Output State ( transfer State , ĠTransfer Contract . CONTRACT _ ID ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġval Ġfinal ised Transaction Ġ= Ġcollect Signatures AndUpdate Ledger ( build Transaction , ĠlistOf ( counter Party Session Flow )) ĊĠĠĠĠĠĠĠ Ġreturn Ġfind State ( final ised Transaction ) ĊĠĠĠ Ġ} Ċ } Ċ Ċ @ Initi ated By ( Request Transfer Flow :: class ) Ċ class ĠRequest Transfer Flow Responder ( private Ġval Ġlauncher Session : ĠFlow Session ) Ġ: ĠFlow Logic < Wire Transaction >() Ġ{ ĊĠĠĠ Ġ@ Suspend able ĊĠĠĠ Ġoverride Ġfun Ġcall (): ĠWire Transaction Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcurrency Ġ= Ġlauncher Session . receive < Currency >(). unwrap Ġ{ Ġit Ġ} ĊĠĠĠĠĠĠĠ Ġval Ġwallet State And Ref Ġ= Ġfind My Wallet () ĊĠĠĠĠĠĠĠ Ġval Ġaccount State And Ref Ġ= Ġfind Account For Currency ( currency ) ĊĠĠĠĠĠĠĠ Ġsub Flow ( Send State And Ref Flow ( launcher Session , ĠlistOf ( wallet State And Ref ))) ĊĠĠĠĠĠĠĠ Ġsub Flow ( Send State And Ref Flow ( launcher Session , ĠlistOf ( account State And Ref ))) ĊĊĠĠĠĠĠĠĠ Ġval Ġsign Transaction Flow : ĠSign Transaction Flow Ġ= Ġobject Ġ: ĠSign Transaction Flow ( launcher Session ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġoverride Ġfun Ġcheck Transaction ( st x : ĠSigned Transaction ) Ġ= Ġrequire That Ġ{ Ċ // ĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠEns uring Ġthat Ġthe Ġtransaction Ġreceived Ġis Ġthe Ġexpected Ġtype , Ġi . e . Ġhas Ġthe Ġexpected Ġtype Ġof Ġinputs Ġand Ġoutputs Ċ // ĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠChecking Ġthat Ġthe Ġproperties Ġof Ġthe Ġoutputs Ġare Ġexpected , Ġthis Ġis Ġin Ġthe Ġabsence Ġof Ġintegr ating Ġreference Ġdata Ġsources Ġto Ġfacilitate Ġthis Ċ // ĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠChecking Ġthat Ġthe Ġtransaction Ġis Ġnot Ġincorrectly Ġs pending Ġ( per haps Ġm alic iously ) Ġasset Ġstates , Ġas Ġpotentially Ġthe Ġtransaction Ġcreator Ġhas Ġaccess Ġto Ġsome Ġof Ġsigner âĢĻ s Ġstate Ġreferences ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġval Ġsigned Transaction Ġ= Ġsub Flow ( sign Transaction Flow ). id ĊĠĠĠĠĠĠĠ Ġ// Ġid Ġto Ġverify Ġthat Ġwe Ġreceive Ġthe Ġtransaction Ġwe Ġsigned ĊĠĠĠĠĠĠĠ Ġreturn Ġsub Flow ( Receive Final ity Flow ( launcher Session , Ġsigned Transaction )). tx ĊĠĠĠ Ġ} Ċ }