コード例 #1
0
 public StdTx(List <StdMsg> messages, List <StdSignature> signatures, StdFee fee, String memo)
 {
     Trace.Assert(messages != null);
     Trace.Assert((signatures == null) || (signatures.Count > 0));
     Trace.Assert(fee != null);
     this.messages   = messages;
     this.signatures = signatures;
     this.fee        = fee;
     this.memo       = memo;
 }
コード例 #2
0
        // This is different from Dart implementation, as we are not initialising the optional parameters
        public static StdTx buildStdTx(List <StdMsg> stdMsgs, [Optional] String memo, [Optional] StdFee fee)
        {
            // Arrange optional parameters here
            if (memo == null)
            {
                memo = "";
            }
            if (fee == null)
            {
                fee = new StdFee(gas: "200000", amount: new List <StdCoin> {
                });
            }
            StdTx txMsg = new StdTx(messages: stdMsgs,
                                    memo: memo,
                                    fee: fee,
                                    signatures: null);


            return(txMsg);
        }
コード例 #3
0
ファイル: TxSigner.cs プロジェクト: commercionetwork/sacco.cs
        private static StdSignature _getStdSignature(Wallet wallet, AccountData accountData, NodeInfo nodeInfo, List <StdMsg> messages, StdFee fee, String memo)
        {
            // Arrange the msg in a list of Json
            List <Dictionary <String, Object> > msgList = new List <Dictionary <String, Object> >();

            foreach (StdMsg msg in messages)
            {
                msgList.Add(msg.toJson());
            }

            StdSignatureMessage signature = new StdSignatureMessage(
                chainId: nodeInfo.network,
                accountNumber: accountData.accountNumber,
                sequence: accountData.sequence,
                memo: memo,
                fee: fee.toJson(),
                msgs: msgList
                );

            // Convert the signature to a JSON and sort it
            Dictionary <String, Object> jsonSignature = signature.toJson();
            Dictionary <String, Object> sortedJson    = MapSorter.sort(jsonSignature);
            // Encode the sorted JSON to a string
            String jsonData = JsonConvert.SerializeObject(sortedJson);

            byte[] utf8Bytes = Encoding.UTF8.GetBytes(jsonData);

            // Sign the message
            byte[] signatureData = wallet.signTxData(utf8Bytes);

            // Get the compressed Base64 public key
            byte[] pubKeyCompressed = wallet.ecPublicKey.Q.GetEncoded(true);

            // Build the StdSignature
            return(new StdSignature(
                       value: Convert.ToBase64String(signatureData),
                       publicKey: new StdPublicKey(
                           type: "tendermint/PubKeySecp256k1",
                           value: Convert.ToBase64String(pubKeyCompressed)
                           )
                       ));
        }