@@ -13,15 +13,17 @@ import (
1313)
1414
1515type localTxSubmissionFlags struct {
16- flagset * flag.FlagSet
17- txFile string
16+ flagset * flag.FlagSet
17+ txFile string
18+ rawTxFile string
1819}
1920
2021func newLocalTxSubmissionFlags () * localTxSubmissionFlags {
2122 f := & localTxSubmissionFlags {
2223 flagset : flag .NewFlagSet ("local-tx-submission" , flag .ExitOnError ),
2324 }
2425 f .flagset .StringVar (& f .txFile , "tx-file" , "" , "path to the JSON transaction file to submit" )
26+ f .flagset .StringVar (& f .rawTxFile , "raw-tx-file" , "" , "path to the raw transaction file to submit" )
2527 return f
2628}
2729
@@ -36,6 +38,10 @@ func testLocalTxSubmission(f *globalFlags) {
3638 fmt .Printf ("failed to parse subcommand args: %s\n " , err )
3739 os .Exit (1 )
3840 }
41+ if localTxSubmissionFlags .txFile == "" && localTxSubmissionFlags .rawTxFile == "" {
42+ fmt .Printf ("you must specify -tx-file or -raw-tx-file\n " )
43+ os .Exit (1 )
44+ }
3945
4046 conn := createClientConnection (f )
4147 errorChan := make (chan error )
@@ -60,23 +66,32 @@ func testLocalTxSubmission(f *globalFlags) {
6066 }
6167 o .LocalTxSubmission .Client .Start ()
6268
63- txData , err := ioutil .ReadFile (localTxSubmissionFlags .txFile )
64- if err != nil {
65- fmt .Printf ("Failed to load transaction file: %s\n " , err )
66- os .Exit (1 )
67- }
69+ var txBytes []byte
70+ if localTxSubmissionFlags .txFile != "" {
71+ txData , err := ioutil .ReadFile (localTxSubmissionFlags .txFile )
72+ if err != nil {
73+ fmt .Printf ("Failed to load transaction file: %s\n " , err )
74+ os .Exit (1 )
75+ }
6876
69- var jsonData map [string ]string
70- err = json .Unmarshal (txData , & jsonData )
71- if err != nil {
72- fmt .Printf ("failed to parse transaction file: %s\n " , err )
73- os .Exit (1 )
74- }
77+ var jsonData map [string ]string
78+ err = json .Unmarshal (txData , & jsonData )
79+ if err != nil {
80+ fmt .Printf ("failed to parse transaction file: %s\n " , err )
81+ os .Exit (1 )
82+ }
7583
76- txBytes , err := hex .DecodeString (jsonData ["cborHex" ])
77- if err != nil {
78- fmt .Printf ("failed to decode transaction: %s\n " , err )
79- os .Exit (1 )
84+ txBytes , err = hex .DecodeString (jsonData ["cborHex" ])
85+ if err != nil {
86+ fmt .Printf ("failed to decode transaction: %s\n " , err )
87+ os .Exit (1 )
88+ }
89+ } else {
90+ txBytes , err = ioutil .ReadFile (localTxSubmissionFlags .rawTxFile )
91+ if err != nil {
92+ fmt .Printf ("Failed to load transaction file: %s\n " , err )
93+ os .Exit (1 )
94+ }
8095 }
8196
8297 if err = o .LocalTxSubmission .Client .SubmitTx (ledger .TX_TYPE_ALONZO , txBytes ); err != nil {
0 commit comments