@@ -19,7 +19,8 @@ const generate = new Command()
19
19
. option ( "-r, --record <record>" , "Record for domain, specified as: <name>[,<ttl>],<type>,<value> (can be specified multiple times)" , { collect : true } )
20
20
. option ( "-s, --source-address <address>" , "Source wallet address to send from (you must be able to sign transactions for this)" , { required : true } )
21
21
. option ( "-d, --dest-address <address>" , "Destination wallet address to send to (this will be read by cdnsd)" , { required : true } )
22
- . action ( async ( { maestroApiKey, domain, nameserver, record, sourceAddress, destAddress } ) => {
22
+ . option ( "-o, --output <file>" , "Output file for generated transaction" )
23
+ . action ( async ( { maestroApiKey, domain, nameserver, record, sourceAddress, destAddress, output } ) => {
23
24
// Merge --nameserver and --record values
24
25
let records = [ ]
25
26
for ( var tmpNameserver of nameserver ) {
@@ -97,8 +98,14 @@ const generate = new Command()
97
98
"description" : "unsigned" ,
98
99
"cborHex" : txOut . toString ( ) ,
99
100
} ;
100
- console . log ( `\nTX (unsigned):\n` ) ;
101
- console . log ( JSON . stringify ( txJsonObj ) ) ;
101
+ const txJson = JSON . stringify ( txJsonObj )
102
+
103
+ if ( output === undefined ) {
104
+ output = `./tx-cdnsd-test-data-${ domain } -${ txOut . toHash ( ) } .json`
105
+ }
106
+ Deno . writeTextFileSync ( output , txJson )
107
+
108
+ console . log ( `\nWrote tranaction to output file: ${ output } ` )
102
109
console . log ( `\nNOTE: you must import this transaction into a wallet such as Eternl to sign and submit it` ) ;
103
110
} catch ( e ) {
104
111
console . log ( e ) ;
0 commit comments