Esempio n. 1
0
        public static string ToHex(this ISerializedType st)
        {
            BytesList list = new BytesList();

            st.ToBytes(list);
            return(list.BytesHex());
        }
Esempio n. 2
0
        public void Prepare(IKeyPair keyPair, Amount fee, UInt32 sequence, UInt32 lastLedgerSequence)
        {
            // This won't always be specified
            if (lastLedgerSequence != null)
            {
                Txn.Add(UInt32.LastLedgerSequence, lastLedgerSequence);
            }

            Txn.Add(UInt32.Sequence, sequence);
            Txn.Add(Amount.Fee, fee);
            Txn.Add(VariableLength.SigningPubKey, keyPair.PubBytes());

            if (Transaction.CanonicalFlagDeployed)
            {
                Txn.SetCanonicalSignatureFlag();
            }

            SigningHash = Txn.SigningHash();
            if (PreviousSigningHash != null && SigningHash.Equals(PreviousSigningHash))
            {
                return;
            }

            try
            {
                byte[] signature = keyPair.Sign(SigningHash.Bytes);
                Txn.Add(VariableLength.TxnSignature, signature);

                var blob = new BytesList();
                Hash256.HalfSha512 id = Hash256.Prefixed256(HashPrefix.TransactionId);

                Txn.ToBytesSink(new MultiSink(blob, id));
                TxBlob = blob.BytesHex();
                Hash   = id.Finish();
            }
            catch (Exception e)
            {
                // electric paranoia
                PreviousSigningHash = null;
                throw new ApplicationException("Something went wrong.", e);
            }

            PreviousSigningHash = SigningHash;
        }