/// <summary> /// get asset bytes. /// </summary> /// <returns>asset bytes. blinded is 33 bytes, else is 32 bytes.</returns> public byte[] ToBytes() { if (commitment.Length == (Size * 2)) { var assetBytes = StringUtil.ToBytes(commitment); return(CfdCommon.ReverseBytes(assetBytes)); } return(StringUtil.ToBytes(commitment)); }
public Txid(byte[] bytes) { if ((bytes == null) || (bytes.Length != Size)) { CfdCommon.ThrowError(CfdErrorCode.IllegalArgumentError, "Failed to txid size."); } var txidBytes = CfdCommon.ReverseBytes(bytes); txid = StringUtil.FromBytes(txidBytes); }
/// <summary> /// byte array. /// </summary> /// <returns>byte array</returns> public byte[] ToBytes() { if (hasReverse) { return(CfdCommon.ReverseBytes(StringUtil.ToBytes(data))); } else { return(StringUtil.ToBytes(data)); } }
/// <summary> /// constructor. /// </summary> /// <param name="asset">asset bytes.</param> public ConfidentialAsset(byte[] asset) { if (asset is null) { throw new ArgumentNullException(nameof(asset)); } if ((asset.Length != Size) && (asset.Length != CommitmentSize)) { CfdCommon.ThrowError(CfdErrorCode.IllegalArgumentError, "Failed to asset size."); } if (asset.Length == Size) { var assetBytes = CfdCommon.ReverseBytes(asset); commitment = StringUtil.FromBytes(assetBytes); } else { commitment = StringUtil.FromBytes(asset); } }
public byte[] GetBytes() { var txidBytes = StringUtil.ToBytes(txid); return(CfdCommon.ReverseBytes(txidBytes)); }