Beispiel #1
0
        /// <summary>
        /// $main_password Your Main My wallet password
        /// $second_password Your second My Wallet password if double encryption is enabled.
        /// $days Addresses which have not received any transactions in at least this many days will be consolidated.
        /// https://blockchain.info/merchant/$guid/auto_consolidate?password=$main_password&second_password=$second_password&days=$days
        /// </summary>
        public string GetRequestURL_ConsolidateAddress(int days)
        {
            if (days < 0)
            {
                throw new ArgumentException(string.Format("ConsolidateAddress: Inavlid consolidation days count {0}", days));
            }


            string fsecondpass;

            if (!PasswordSecond.IsNullOrWhiteSpace())
            {
                fsecondpass = string.Format(@"&second_password={0}", PasswordSecond);
            }
            else
            {
                fsecondpass = null;
            }


            string result = string.Format(@"https://blockchain.info/merchant/{0}/auto_consolidate?password={1}{2}&days={3}",
                                          GUID,
                                          PasswordMain,
                                          fsecondpass,
                                          days);

            return(result);
        }
Beispiel #2
0
        /// <summary>
        /// $main_password Your Main My wallet password
        /// $second_password Your second My Wallet password if double encryption is enabled.
        /// $label An optional label to attach to this address.It is recommended this is a human readable string e.g. "Order No : 1234". You May use this as a reference to check balance of an order (documented later)
        /// https://blockchain.info/merchant/$guid/new_address?password=$main_password&second_password=$second_password&label=$label
        /// </summary>
        public string GetRequestURL_GenerateNewAddress(string label = null)
        {
            string fsecondpass;
            string flabel;

            if (!PasswordSecond.IsNullOrWhiteSpace())
            {
                fsecondpass = string.Format(@"&second_password={0}", PasswordSecond);
            }
            else
            {
                fsecondpass = null;
            }

            if (!label.IsNullOrWhiteSpace())
            {
                flabel = string.Format(@"&label={0}", label);
            }
            else
            {
                flabel = null;
            }

            string result = string.Format(@"https://blockchain.info/merchant/{0}/new_address?password={1}{2}{3}",
                                          GUID,
                                          PasswordMain,
                                          fsecondpass,
                                          flabel);

            return(result);
        }
        /// <summary>
        /// $main_password Your Main My wallet password
        /// $second_password Your second My Wallet password if double encryption is enabled.
        /// $address The bitcoin address to unarchive
        /// https://blockchain.info/merchant/$guid/unarchive_address?password=$main_password&second_password=$second_password&address=$address
        /// </summary>
        public string GetRequestURL_UnarchiveAddress(string address = null)
        {
            string fsecondpass;
            string faddress;

            if (!PasswordSecond.IsNullOrWhiteSpace())
            {
                fsecondpass = string.Format(@"&second_password={0}", PasswordSecond);
            }
            else
            {
                fsecondpass = null;
            }

            if (!address.IsNullOrWhiteSpace())
            {
                faddress = string.Format(@"&address={0}", address);
            }
            else
            {
                faddress = null;
            }

            string result = string.Format(@"https://blockchain.info/merchant/{0}/unarchive_address?password={1}{2}{3}",
                                          GUID,
                                          PasswordMain,
                                          fsecondpass,
                                          faddress);

            return(result);
        }
Beispiel #4
0
        /// <summary>
        /// $main_password Your Main My wallet password
        /// $second_password Your second My Wallet password if double encryption is enabled.
        /// $recipients Is a JSON Object using Bitcoin Addresses as keys and the amounts to send as values (See below).
        /// $fee Transaction fee value in satoshi(Must be greater than default fee) (Optional)
        /// https://blockchain.info/merchant/$guid/sendmany?password=$main_password&second_password=$second_password&recipients=$recipients&fee=$fee
        /// </summary>
        public string GetRequestURL_SendManyTransactions(KeyValuePair <string, long>[] recipients, long?fee = null)
        {
            if (recipients == null || recipients.Length <= 0)
            {
                throw new ArgumentException(string.Format("SendManyTransactions: No recipients specified."));
            }


            string frecipients = null;


            for (int i = 0; i < recipients.Length; i++)
            {
                string to     = recipients[i].Key;
                long   amount = recipients[i].Value;

                if (to.IsNullOrWhiteSpace() || amount <= 0)
                {
                    throw new ArgumentException(string.Format("SendManyTransactions: Inavlid recipient adress: {0}, or insufficient amount {1}", to, amount));
                }

                frecipients += string.Format("\"{0}\": {1}", to, amount);

                if (recipients.Length < recipients.Length - 1)
                {
                    frecipients += ",";
                }
            }

            frecipients = "{" + frecipients + "}";


            string fresult;
            string fsecondpass;
            string ffee;

            if (!PasswordSecond.IsNullOrWhiteSpace())
            {
                fsecondpass = string.Format(@"&second_password={0}", PasswordSecond);
            }
            else
            {
                fsecondpass = null;
            }

            if (fee != null && fee.Value > 0)
            {
                ffee = string.Format(@"&fee=", fee.Value);
            }
            else
            {
                ffee = null;
            }


            fresult = string.Format(@"https://blockchain.info/merchant/{0}/sendmany?password={1}&second_password={2}&recipients={3}{4}",
                                    GUID,
                                    PasswordMain,
                                    fsecondpass,
                                    frecipients,
                                    ffee
                                    );

            return(fresult);
        }
Beispiel #5
0
        /// <summary>
        /// $main_password Your Main My wallet password
        /// $second_password Your second My Wallet password if double encryption is enabled.
        /// $to Recipient Bitcoin Address.
        /// $amount Amount to send in satoshi.
        /// $from Send from a specific Bitcoin Address (Optional)
        /// $fee Transaction fee value in satoshi(Must be greater than default fee) (Optional)
        /// $note A public note to include with the transaction -- can only be attached when outputs are greater than 0.005 BTC. (Optional)
        /// https://blockchain.info/merchant/$guid/payment?password=$main_password&second_password=$second_password&to=$address&amount=$amount&from=$from&fee=$fee&note=$note
        /// </summary>
        public string GetRequestURL_OutgoingPayment(string to, long amount, string from = null, long?fee = null, string note = null)
        {
            if (to.IsNullOrWhiteSpace() || amount <= 0)
            {
                throw new ArgumentException(string.Format("OutgoingPayment: Inavlid recipient adress: {0}, or insufficient amount {1}", to, amount));
            }


            if (amount < PublicNoteOutputMinimum)
            {
                note = null;
            }

            string fresult;
            string fsecondpass;
            string ffrom;
            string ffee;
            string fnote;

            if (!PasswordSecond.IsNullOrWhiteSpace())
            {
                fsecondpass = string.Format(@"&second_password={0}", PasswordSecond);
            }
            else
            {
                fsecondpass = null;
            }

            if (!from.IsNullOrWhiteSpace())
            {
                ffrom = string.Format(@"&from=", from);
            }
            else
            {
                ffrom = null;
            }

            if (fee != null && fee.Value > 0)
            {
                ffee = string.Format(@"&fee=", fee.Value);
            }
            else
            {
                ffee = null;
            }

            if (!note.IsNullOrWhiteSpace())
            {
                fnote = string.Format(@"&note=", note);
            }
            else
            {
                fnote = null;
            }


            fresult = string.Format(@"https://blockchain.info/merchant/{0}/payment?password={1}{2}&to={3}&amount={4}{5}{6}{7}",
                                    GUID,
                                    PasswordMain,
                                    fsecondpass,
                                    to,
                                    amount,
                                    ffrom,
                                    ffee,
                                    fnote
                                    );

            return(fresult);
        }