sendTx method
Send a transaction to the network @param {Object} tx Transaction to send
Implementation
Future<TransactionStatus> sendTx(Transaction transaction) async {
final completer = Completer<TransactionStatus>();
var transactionStatus = const TransactionStatus();
try {
final jsonRPCRequest = setJsonRPCRequest(
'send_transaction',
{
'transaction': jsonDecode(
transaction.convertToJSON(),
),
},
);
_logger.fine(
'sendTx: (${transaction.address}) requestHttp.body=$jsonRPCRequest',
);
final responseHttp = await http.post(
Uri.parse('$endpoint/api/rpc'),
body: jsonRPCRequest,
headers: kRequestHeaders,
);
_logger.fine(
'sendTx: (${transaction.address}) responseHttp.body=${responseHttp.body}',
);
final result = getJsonRPCResult(responseHttp.body);
transactionStatus = transactionStatusFromJson(
json.encode(
result,
),
);
completer.complete(transactionStatus);
} catch (e, stack) {
_logger.severe(
'sendTx: (${transaction.address}) failed',
e,
stack,
);
rethrow;
}
return completer.future;
}