コード例 #1
0
ファイル: ParseTransaction.js プロジェクト: libremoney/main
//super(new APITag[] {APITag.TRANSACTIONS}, "transactionBytes", "transactionJSON");
function ParseTransaction(req, res) {
	var transactionBytes = Convert.EmptyToNull(req.query.transactionBytes);
	var transactionJson = Convert.EmptyToNull(req.query.transactionJson);
	if (!transactionBytes && !transactionJson) {
		return JsonResponses.MissingTransactionBytesOrJson;
	}
	var response;
	try {
		var transaction;
		if (transactionBytes) {
			var bytes = Convert.ParseHexString(transactionBytes);
			transaction = TransactionProcessor.ParseTransaction1(bytes);
		} else {
			transaction = TransactionProcessor.ParseTransaction2(transactionJson);
		}

		transaction.Validate();
		response = JsonData.UnconfirmedTransaction(transaction);
		response.verify = transaction.VerifySignature();
	} catch (e) {
		return JsonResponses.IncorrectTransactionBytes;
		Logger.error('ParseTransaction: Error');
	}
	res.send(response);
}
コード例 #2
0
ファイル: GetTransaction.js プロジェクト: libremoney/main
		Blockchain.GetTransaction(transactionId, function(err, transaction) {
			if (err) {
				Logger.warn(JsonResponses.IncorrectTransaction);
				res.send(JsonResponses.IncorrectTransaction);
				return;
			}
			if (!transaction) {
				transaction = TransactionProcessor.GetUnconfirmedTransaction(transactionId);
				if (!transaction) {
					res.send(JsonResponses.UnknownTransaction);
					return false;
				}
				res.send(JsonData.UnconfirmedTransaction(transaction));
				return;
			}
			Logger.debug(transaction.GetAmountMilliLm());
			res.send(JsonData.Transaction(transaction));
		});