/// <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)); }
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; }
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); }
/// <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)); }
/// <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)); }
public SignedTx(StdMsg stdMsg, byte[] privateKey, SyncMode mode, string memo = "") { tx = new Tx(stdMsg, privateKey, memo); this.mode = mode.GetSyncMode(); }