public void NullTransactionTypeTest() { AssertTxFormatException(() => { TxFormat.Validate(new StObject { [Field.TransactionType] = null }); }, "`TransactionType` is set to null"); }
public void MissingFieldsTest() { var so = new StObject { [Field.TransactionType] = TransactionType.Payment }; TxFormat.Validate(so); }
public static SignedTx ValidateAndEncode(StObject tx) { try { TxFormat.Validate(tx); } catch (TxFormatValidationException ex) { throw new InvalidTxException("Transaction is not valid.", nameof(tx), ex); } var blob = tx.ToBytes(); var hash = Utils.TransactionId(blob); return(new SignedTx(hash, B16.Encode(blob), tx.ToJsonObject())); }
public void ValidateTest() { var so = new StObject { [Field.TransactionType] = TransactionType.Payment, [Field.Account] = "r9kiSEUEw6iSCNksDVKf9k3AyxjW3r1qPf", [Field.Sequence] = 12000, [Field.SigningPubKey] = Blob.FromHex("02517EB0EEB4424BB01D6D9932F8838D8EF4EC989CF5B8097C9CF675F534EF10BF"), [Field.Fee] = "12000", [Field.Destination] = "r9kiSEUEw6iSCNksDVKf9k3AyxjW3r1qPf", [Field.Amount] = "100" }; // No problems here TxFormat.Validate(so); // But if we set the amount to null so[Field.Amount] = null; AssertTxFormatException(() => { TxFormat.Validate(so); }, "`Amount` is set to null"); }
public void MissingTransactionTypeTest() { AssertTxFormatException(() => { TxFormat.Validate(new StObject()); }, "Missing `TransactionType` field"); }