package Ġnet . cord a . not ary demo . client Ċ Ċ import Ġnet . cord a . client . rpc . C ord a RPC Client Ċ import Ġnet . cord a . core . crypto . Composite Key Ċ import Ġnet . cord a . core . crypto . Crypto Ċ import Ġnet . cord a . core . crypto . toString Short Ċ import Ġnet . cord a . core . identity . C ord a X 5 0 0 Name Ċ import Ġnet . cord a . core . identity . Party Ċ import Ġnet . cord a . core . messaging . C ord a RP CO ps Ċ import Ġnet . cord a . core . messaging . start Flow Ċ import Ġnet . cord a . core . transactions . Signed Transaction Ċ import Ġnet . cord a . core . utilities . Network Host And Port Ċ import Ġnet . cord a . core . utilities . get OrThrow Ċ import Ġnet . cord a . not ary demo . flows . Dummy Issue And Move Ċ import Ġnet . cord a . not ary demo . flows . RPC Start able Not ary Flow Client Ċ import Ġjava . util . concurrent . Future Ċ Ċ fun Ġmain ( args : ĠArray < String >) Ġ{ ĊĠĠĠ Ġval Ġaddress Ġ= ĠNetwork Host And Port (" localhost ", Ġ 1 0 0 0 3 ) ĊĠĠĠ Ġprintln (" Connecting Ġto Ġthe Ġrecipient Ġnode Ġ($ address )") ĊĠĠĠ ĠC ord a RPC Client ( address ). start (" dem ou ", Ġ" dem op "). use Ġ{ ĊĠĠĠĠĠĠĠ ĠNot ary Demo Client Api ( it . proxy ). not ar ise ( 1 0 ) ĊĠĠĠ Ġ} Ċ } Ċ Ċ /** ĠInterface Ġfor Ġusing Ġthe Ġnot ary Ġdemo ĠAPI Ġfrom Ġa Ġclient . Ġ*/ Ċ private Ġclass ĠNot ary Demo Client Api ( val Ġrpc : ĠC ord a RP CO ps ) Ġ{ ĊĠĠĠ Ġprivate Ġval Ġnot ary Ġby Ġlazy Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġid Ġ= Ġrpc . not ary Id entities (). single OrNull () ĊĠĠĠĠĠĠĠ ĠcheckNotNull ( id ) Ġ{ Ġ" No Ġunique Ġnot ary Ġidentity , Ġtry Ġcleaning Ġthe Ġnode Ġdirectories ." Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ/** ĠA Ġdummy Ġidentity . Ġ*/ ĊĠĠĠ Ġprivate Ġval ĠB OB _ NAME Ġ= ĠC ord a X 5 0 0 Name (" Bob ĠPl c ", Ġ" R ome ", Ġ" IT ") ĊĠĠĠ Ġprivate Ġval Ġcounter party Ġ= ĠParty ( BO B _ NAME , ĠCrypto . generate KeyPair ( Crypto . DEFAULT _ SIGNATURE _ SCHEME ). public ) ĊĊĠĠĠ Ġ/** ĠMakes Ġcalls Ġto Ġthe Ġnode Ġrpc Ġto Ġstart Ġtransaction Ġnot ar isation . Ġ*/ ĊĠĠĠ Ġfun Ġnot ar ise ( count : ĠInt ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġkey Type Ġ= Ġif Ġ( not ary . own ing Key Ġis ĠComposite Key ) Ġ" composite " Ġelse Ġ" public " ĊĠĠĠĠĠĠĠ Ġprintln (" Not ary : Ġ\" ${ not ary . name }\ ", Ġwith Ġ$ key Type Ġkey : Ġ${ not ary . own ing Key . toString Short () }") ĊĠĠĠĠĠĠĠ Ġval Ġtransactions Ġ= Ġbuild Transactions ( count ) ĊĠĠĠĠĠĠĠ Ġprintln (" Not ar ised Ġ${ transactions . size } Ġtransactions :") ĊĠĠĠĠĠĠĠ Ġtransactions . zip ( not ar ise Transactions ( transactions )). forEach Ġ{ Ġ( tx , Ġsign ers Future ) Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġprintln (" Tx Ġ[ ${ tx . tx . id . prefix Chars ()} .. ] Ġsigned Ġby Ġ${ sign ers Future . get OrThrow (). join ToString () }") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ/** ĊĠĠĠĠ Ġ* ĠBuilds Ġa Ġnumber Ġof Ġdummy Ġtransactions Ġ( as Ġspecified Ġby Ġ[ count ]). ĠThe Ġparty Ġfirst Ġself - issues Ġa Ġstate Ġ( asset ), ĊĠĠĠĠ Ġ* Ġand Ġbuilds Ġa Ġtransaction Ġto Ġtransfer Ġthe Ġasset Ġto Ġthe Ġcounter party . ĠThe Ġ* move * Ġtransaction Ġrequires Ġnot ar isation , ĊĠĠĠĠ Ġ* Ġas Ġit Ġconsume s Ġthe Ġoriginal Ġasset Ġand Ġcreates Ġa Ġcopy Ġwith Ġthe Ġnew Ġowner Ġas Ġits Ġoutput . ĊĠĠĠĠ Ġ*/ ĊĠĠĠ Ġprivate Ġfun Ġbuild Transactions ( count : ĠInt ): ĠList < Signed Transaction > Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġflow F utures Ġ= Ġ( 1 .. count ). map Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġrpc . start Flow (:: Dummy Issue And Move , Ġnot ary , Ġcounter party , Ġit ). returnValue ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġreturn Ġflow F utures . map Ġ{ Ġit . get OrThrow () Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ/** ĊĠĠĠĠ Ġ* ĠFor Ġevery Ġtransaction Ġinvoke Ġthe Ġnot ary Ġflow Ġand Ġobt ains Ġa Ġnot ary Ġsignature . ĊĠĠĠĠ Ġ* ĠThe Ġsigner Ġcan Ġbe Ġany Ġof Ġthe Ġnodes Ġin Ġthe Ġnot ary Ġcluster . ĊĠĠĠĠ Ġ* ĊĠĠĠĠ Ġ* Ġ@ return Ġa Ġlist Ġof Ġencoded Ġsigner Ġpublic Ġkeys Ġ- Ġone Ġfor Ġevery Ġtransaction ĊĠĠĠĠ Ġ*/ ĊĠĠĠ Ġprivate Ġfun Ġnot ar ise Transactions ( transactions : ĠList < Signed Transaction >): ĠList < Future < List < String >>> Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġtransactions . map Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġrpc . start Flow (:: RPC Start able Not ary Flow Client , Ġit ). returnValue . to Comp letableFuture (). then Apply Ġ{ Ġit . map Ġ{ Ġit . by . toString Short () Ġ} Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ