查询包含某数据的第一个交易的哈希值
数据用base58解码
using System;
using BsvSimpleLibrary;
using System.Collections.Generic;
using System.Linq;
using NBitcoin;
using NBitcoin.DataEncoders;
using BitcoinSVCryptor;
namespace bsvAddress
{
class Program
{
static void Main(string[] args)
{
string uri = bsvConfiguration_class.RestApiUri;
string network = bsvConfiguration_class.testNetwork;
string privateKeyStr = "cNNfJQD8k2awDySowmH631JEJ9AVeueVkwLs9ihDkELhJhpMJVSt";
string opReturnData = "HquEky7h7KGkUkaccZt1R4";
string destAddress = "mxe34JQpFvKcUjJ2pA6NK2HfAEe5nVuc2j";
Dictionary<string, string> response;
RestApiAddressHistoryTx[] addressHistory = RestApi_class.getAddressHistory(uri, network, destAddress);
string[] txHashes = addressHistory.Select(tx => tx.TxHash).ToArray();
int batchSize = 20;
RestApiTransaction[] txs;
for (int i = 0; i < txHashes.Length; i += batchSize)
{
string[] batchHashes = txHashes.Skip(i).Take(batchSize).ToArray();
txs = RestApi_class.getTransactions(uri, network, batchHashes);
foreach (RestApiTransaction tx in txs)
{
string s = RestApi_class.getOpReturnData(tx, bsvConfiguration_class.encoding);
if (!string.IsNullOrEmpty(s) && s.Contains("HquEky7h7KGkUkaccZt1R4"))
{
Console.WriteLine("第一个交易的哈希地址:" + tx.Hash);
break;
}
}
}
Base58Encoder base58Encoder = new Base58Encoder();
string base58Str = "HquEky7h7KGkUkaccZt1R4";
byte[] encryptedBytes = base58Encoder.DecodeData(base58Str);
string privateKey1Str = "cNNfJQD8k2awDySowmH631JEJ9AVeueVkwLs9ihDkELhJhpMJVSt";
string decryptedStr = AES_class.AesDecrypt(encryptedBytes, privateKey1Str);
Console.WriteLine("Decrypted string: " + decryptedStr);
}
}
}