示例#1
0
 public static Signature FromJson(JObject json)
 {
     return(new Signature(SigningPayload.FromJson(json["signing_payload"]),
                          PublicKey.FromJson(json["public_key"]),
                          json["signature_type"].ToSignatureType(),
                          json["hex_bytes"].AsString()));
 }
示例#2
0
 public Signature(SigningPayload signingPayload, PublicKey publicKey, SignatureType signatureType, string hexBytes)
 {
     SigningPayload = signingPayload;
     PublicKey      = publicKey;
     SignatureType  = signatureType;
     HexBytes       = hexBytes;
 }
示例#3
0
 public Signature(SigningPayload signingPayload, PublicKey publicKey, SignatureType signatureType, byte[] bytes)
 {
     SigningPayload = signingPayload;
     PublicKey      = publicKey;
     SignatureType  = signatureType;
     Bytes          = bytes;
 }
示例#4
0
        public JObject ToJson()
        {
            JObject json = new JObject();

            json["signing_payload"] = SigningPayload.ToJson();
            json["public_key"]      = PublicKey.ToJson();
            json["signature_type"]  = SignatureType.AsString();
            json["hex_bytes"]       = HexBytes;
            return(json);
        }
示例#5
0
        /// <summary>
        /// Payloads is called with an array of operations and the response from `/construction/metadata`.
        /// It returns an unsigned transaction blob and a collection of payloads that must be signed by particular addresses using a certain SignatureType.
        /// The array of operations provided in transaction construction often times can not specify all "effects" of a transaction.
        /// However, they can deterministically specify the "intent" of the transaction, which is sufficient for construction.
        /// For this reason, parsing the corresponding transaction in the Data API (when it lands on chain) will contain a superset of whatever operations were provided during construction.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public JObject ConstructionPayloads(ConstructionPayloadsRequest request)
        {
            NeoTransaction neoTx;

            try
            {
                neoTx = ConvertOperations(request.Operations, request.Metadata);
            }
            catch (Exception)
            {
                return(Error.PARAMETER_INVALID.ToJson());
            }
            byte[] unsignedRaw  = (neoTx as IVerifiable).GetHashData();
            var    scriptHashes = neoTx.GetScriptHashesForVerifying(Blockchain.Singleton.GetSnapshot());

            SigningPayload[] signingPayloads = new SigningPayload[scriptHashes.Length];
            for (int i = 0; i < scriptHashes.Length; i++)
            {
                signingPayloads[i] = new SigningPayload(scriptHashes[i].ToAddress(), unsignedRaw);
            }
            ConstructionPayloadsResponse response = new ConstructionPayloadsResponse(unsignedRaw.ToHexString(), signingPayloads);

            return(response.ToJson());
        }