Skip to content

Commit

Permalink
Add a new Tranasction ctor using tx hex
Browse files Browse the repository at this point in the history
  • Loading branch information
Coding-Enthusiast committed Apr 23, 2021
1 parent c06f080 commit d709878
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Src/Autarkysoft.Bitcoin/Blockchain/Transactions/Transaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,21 @@ public Transaction(int ver, TxIn[] txIns, TxOut[] txOuts, LockTime lt, Witness[]
WitnessList = witnesses;
}

/// <summary>
/// Initializes a new instance of <see cref="Transaction"/> using hexadecimal string representation of the transaction.
/// </summary>
/// <exception cref="ArgumentException"/>
/// <param name="hex">Transaction data in hexadecimal format</param>
public Transaction(string hex)
{
byte[] data = Base16.Decode(hex);
var stream = new FastStreamReader(data);
if (!TryDeserialize(stream, out string error))
{
throw new ArgumentException(error);
}
}



private const int MaxTxSize = 4_000_000;
Expand Down

0 comments on commit d709878

Please sign in to comment.