예제 #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));
 }
예제 #2
0
파일: Tx.cs 프로젝트: dropil/NDrop
 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;
 }
예제 #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);
        }
예제 #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));
 }
예제 #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));
 }
예제 #6
0
 public SignedTx(StdMsg stdMsg, byte[] privateKey, SyncMode mode, string memo = "")
 {
     tx        = new Tx(stdMsg, privateKey, memo);
     this.mode = mode.GetSyncMode();
 }