package Ġcom . template . flows čĊč Ċ import Ġco . parallel universe . fib ers . Suspend able č Ċ import Ġcom . r 3 . cord a . lib . tokens . contracts . states . F ung ible Token č Ċ import Ġcom . r 3 . cord a . lib . tokens . contracts . utilities . of č Ċ import Ġcom . r 3 . cord a . lib . tokens . workflows . flows . move . add Move F ung ible Tokens č Ċ import Ġcom . r 3 . cord a . lib . tokens . workflows . flows . move . add Move Tokens č Ċ import Ġcom . r 3 . cord a . lib . tokens . workflows . internal . flows . distribution . Update Distribution List Flow č Ċ import Ġcom . template . states . Coin State č Ċ 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 . services . query By č Ċ import Ġnet . cord a . core . transactions . Signed Transaction č Ċ import Ġnet . cord a . core . transactions . Transaction Builder č Ċ import Ġnet . cord a . core . utilities . Progress Tracker č Ċ import Ġnet . cord a . core . utilities . unwrap čĊč Ċ @ Start able By RPC č Ċ @ Initi ating Flow č Ċ class ĠTransfer Coin O verse as Flow ( val Ġforeign Bank : ĠParty , čĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġamount : ĠInt ) Ġ: ĠFlow Logic < String >() Ġ{ čĊčĊĠĠĠ Ġoverride Ġval Ġprogress Tracker Ġ= ĠProgress Tracker () čĊčĊĠĠĠ Ġ@ Suspend able čĊĠĠĠ Ġoverride Ġfun Ġcall (): ĠString Ġ{ čĊĠĠĠĠĠĠĠ Ġ/* ĠChoose Ġthe Ġnot ary Ġfor Ġthe Ġtransaction Ġ*/ čĊĠĠĠĠĠĠĠ Ġval Ġnot ary Ġ= Ġservice Hub . network Map Cache . not ary Id entities [ 0 ] čĊčĊĠĠĠĠĠĠĠ Ġ// Ġtake Ġthe Ġtoken Ġfrom Ġthe Ġvault čĊĠĠĠĠĠĠĠ Ġval Ġcoin State And Ref : ĠState And Ref < Coin State > Ġ= Ġservice Hub . vault Service . query By < Coin State >(). states . single () čĊĠĠĠĠĠĠĠ Ġval Ġcoin State Ġ= Ġcoin State And Ref . state . data čĊčĊĠĠĠĠĠĠĠ Ġ/* ĠBuild Ġthe Ġtransaction Ġwith Ġa Ġnot ary Ġ*/ čĊĠĠĠĠĠĠĠ Ġval Ġtx Builder Ġ= ĠTransaction Builder ( not ary ) čĊčĊĠĠĠĠĠĠĠ Ġval Ġtoken To Transfer Ġ= Ġamount Ġof Ġcoin State . to Pointer ( coin State . java Class ) čĊčĊĠĠĠĠĠĠĠ Ġ/* ĠInit iate Ġa Ġsession Ġwith Ġthe Ġcounter party Ġ*/ čĊĠĠĠĠĠĠĠ Ġval Ġsession Ġ= Ġinitiate Flow ( foreign Bank ) čĊčĊĠĠĠĠĠĠĠ Ġ// Ġsend Ġthe Ġamount Ġof Ġtoken Ġto Ġtransfer Ġto Ġthe Ġcounter party čĊĠĠĠĠĠĠĠ Ġsession . send ( token To Transfer ) čĊčĊĠĠĠĠĠĠĠ Ġ// Ġretrieve Ġthe ĠState And Ref Ġor Ġthe Ġmoney Ġfrom Ġthe Ġcounter party čĊĠĠĠĠĠĠĠ Ġval Ġinputs Ġ= Ġsub Flow ( Receive State And Ref Flow < F ung ible Token >( session )) čĊčĊĠĠĠĠĠĠĠ Ġ// Ġretrieve Ġthe Ġactual Ġmoney Ġfrom Ġthe Ġcounter party čĊĠĠĠĠĠĠĠ Ġval Ġmoney Received : ĠList < F ung ible Token > Ġ= Ġsession . receive < List < F ung ible Token >> (). unwrap Ġ{ Ġit Ġ-> Ġit Ġ} čĊčĊĠĠĠĠĠĠĠ Ġ// ĠProposal Ġto Ġmove Ġthe Ġtokens Ġto Ġcounter party Ġ( the Ġnew Ġholder ) čĊĠĠĠĠĠĠĠ Ġadd Move F ung ible Tokens ( tx Builder , Ġservice Hub , Ġtoken To Transfer , Ġforeign Bank , Ġour Identity ) čĊčĊĠĠĠĠĠĠĠ Ġ// Ġpropose Ġto Ġmove Ġthe Ġmoney Ġto Ġmyself čĊĠĠĠĠĠĠĠ Ġadd Move Tokens ( tx Builder , Ġinputs , Ġmoney Received ) čĊčĊĠĠĠĠĠĠĠ Ġ/* ĠSign Ġthe Ġtransaction Ġwith Ġyour Ġprivate Ġ*/ čĊĠĠĠĠĠĠĠ Ġval Ġinitial Signed Tr nx Ġ= Ġservice Hub . sign Initial Transaction ( tx Builder ) čĊčĊĠĠĠĠĠĠĠ Ġ/* ĠCall Ġthe ĠCollect Signatures Flow Ġto Ġrec ieve Ġsignature Ġof Ġthe Ġbuy er Ġ*/ čĊĠĠĠĠĠĠĠ Ġval Ġf tx Ġ= Ġsub Flow ( Collect Signatures Flow ( initial Signed Tr nx , ĠlistOf ( session ))) čĊčĊĠĠĠĠĠĠĠ Ġ/* ĠDistribution Ġlist Ġis Ġa Ġlist Ġof Ġident ities Ġthat Ġshould Ġreceive Ġupdates . ĠFor Ġthis Ġmechanism Ġto Ġbehave Ġcorrectly Ġwe Ġcall Ġthe ĠUpdate Distribution List Flow Ġflow Ġ*/ čĊĠĠĠĠĠĠĠ Ġsub Flow ( Update Distribution List Flow ( ft x )) čĊčĊĠĠĠĠĠĠĠ Ġ/* ĠCall Ġfinal ity Ġflow Ġto Ġnot ar ise Ġthe Ġtransaction Ġ*/ čĊĠĠĠĠĠĠĠ Ġval Ġst x Ġ= Ġsub Flow ( Final ity Flow ( ft x , ĠlistOf ( session ))) čĊĠĠĠĠĠĠĠ Ġreturn Ġ(" \ n Con grat ulations ! Ġ" Ġ+ Ġamount Ġ+ Ġ" Ġof Ġ" Ġ+ Ġcoin State . name Ġ+ Ġ" Ġhave Ġbeen Ġsold Ġto Ġ" Ġ+ Ġforeign Bank . name . organisation Ġ+ Ġ"\ n Transaction ĠID : Ġ" čĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ+ Ġst x . id ) čĊĠĠĠ Ġ} čĊčĊčĊĠĠĠ Ġ@ Initi ated By ( Transfer Coin O verse as Flow :: class ) čĊĠĠĠ Ġclass ĠHouse Sale Responder ( val Ġcounter party Session : ĠFlow Session ) Ġ: ĠFlow Logic < Signed Transaction >() Ġ{ čĊĠĠĠĠĠĠĠ Ġ@ Suspend able čĊĠĠĠĠĠĠĠ Ġoverride Ġfun Ġcall (): ĠSigned Transaction Ġ{ čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ/* ĠReceive Ġthe Ġvalue Ġin Ġfi at Ġcurrency Ġof Ġthe Ġtoken Ġto Ġbuy Ġ*/ čĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġtoken Amount Ġ= Ġcounter party Session . receive < F ung ible Token >(). unwrap Ġ{ Ġit Ġ} čĊčĊĠĠĠĠĠĠĠĠĠĠĠ Ġ// Ġretrieve Ġthe Ġmoney Ġfrom Ġthe Ġvault Ġ( stored Ġas ĠF ung ible Token Ġfrom Ġprevious Ġflow ) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġmoney State Ref Ġ= Ġservice Hub . vault Service . query By < F ung ible Token >(). states . single () čĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġmoney Ġ= Ġmoney State Ref . state . data čĊčĊĠĠĠĠĠĠĠĠĠĠĠ Ġsub Flow ( Send State And Ref Flow ( counter party Session , ĠlistOf ( money State Ref ))) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġcounter party Session . send ( listOf ( money )) čĊčĊĠĠĠĠĠĠĠĠĠĠĠ Ġ// signing čĊĠĠĠĠĠĠĠĠĠĠĠ Ġsub Flow ( object Ġ: ĠSign Transaction Flow ( counter party Session ) Ġ{ čĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ@ Throws ( Flow Exception :: class ) čĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġoverride Ġfun Ġcheck Transaction ( st x : ĠSigned Transaction ) Ġ= ĠUnit čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ}) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn Ġsub Flow ( Receive Final ity Flow ( counter party Session )) čĊĠĠĠĠĠĠĠ Ġ} čĊĠĠĠ Ġ} č Ċ }