Exemple #1
0
 /// <summary>
 /// Builds a standard message from a msg that implements the IMsgParams interface
 /// </summary>
 /// <param name="msg"></param>
 /// <returns></returns>
 public static StdMsg BuildStdMsg(this IMsg msg)
 {
     if (msg.msgs != null)
     {
         return(StdMsg.Build(msg.msgs, msg));
     }
     return(StdMsg.Build(msg));
 }
Exemple #2
0
 public Tx(StdMsg stdMsg, byte[] privateKey, string memo = "")
 {
     msg        = stdMsg.input.msgs;
     fee        = stdMsg.input.fee;
     signatures = new List <Signature>()
     {
         new Signature(stdMsg, privateKey)
     };
     this.memo = memo;
 }
Exemple #3
0
        public Signature(StdMsg stdMsg, byte[] privateKey)
        {
            pub_key = new PubKey(privateKey);

            var stdMsgJObj       = JObject.FromObject(stdMsg.input);
            var stdMsgJObjSorted = Utils.JSON.Sort(stdMsgJObj);
            var messageJSON      = JsonConvert.SerializeObject(stdMsgJObjSorted);
            var messageBytes     = Encoding.UTF8.GetBytes(messageJSON);
            var messageHashBytes = SHA256.Create().ComputeHash(messageBytes);
            var signBytes        = Secp256K1Manager.SignCompact(messageHashBytes, privateKey, out _);

            signature = Convert.ToBase64String(signBytes);
        }
Exemple #4
0
 /// <summary>
 /// Sign standard message
 /// </summary>
 /// <param name="stdMsg"></param>
 /// <param name="mode"></param>
 /// <returns></returns>
 public SignedTx Sign(StdMsg stdMsg, SyncMode mode = SyncMode.Sync)
 {
     return(new SignedTx(stdMsg, PrivateKey, mode));
 }
Exemple #5
0
 /// <summary>
 /// Signs a standard message using the provided wallet
 /// </summary>
 /// <param name="stdMsg"></param>
 /// <param name="wallet"></param>
 /// <param name="mode"></param>
 /// <returns></returns>
 public static SignedTx Sign(this StdMsg stdMsg, Wallet wallet, SyncMode mode = SyncMode.Sync)
 {
     return(wallet.Sign(stdMsg, mode));
 }
Exemple #6
0
 public SignedTx(StdMsg stdMsg, byte[] privateKey, SyncMode mode, string memo = "")
 {
     tx        = new Tx(stdMsg, privateKey, memo);
     this.mode = mode.GetSyncMode();
 }