diff --git a/server/migrations/0001_key_data_table.sql b/server/migrations/0001_key_data_table.sql index 68b39bab..082df6cd 100644 --- a/server/migrations/0001_key_data_table.sql +++ b/server/migrations/0001_key_data_table.sql @@ -55,5 +55,6 @@ CREATE TABLE public.tokens ( onchain_address varchar NULL, processor_id varchar NULL, confirmed boolean DEFAULT false, - spent boolean DEFAULT false + spent boolean DEFAULT false, + accepted boolean DEFAULT false ); \ No newline at end of file diff --git a/token-server/src/endpoints/token.rs b/token-server/src/endpoints/token.rs index ce4795f4..1cb8d62b 100644 --- a/token-server/src/endpoints/token.rs +++ b/token-server/src/endpoints/token.rs @@ -120,6 +120,33 @@ pub async fn token_init(token_server: &State) -> status::Custom) -> status::Custom> { + + let token_id = uuid::Uuid::new_v4().to_string(); + + let invoice: Invoice = get_lightning_invoice(token_server, token_id.clone()).await; + + let pod_info = PODInfo { + token_id: token_id.clone(), + fee: token_server.config.fee.clone(), + lightning_invoice: invoice.pr.clone(), + btc_payment_address: invoice.onChainAddr.clone(), + processor_id: invoice.id.clone(), + }; + + insert_new_token(&token_server.pool, &token_id, &invoice.pr.clone(), &invoice.onChainAddr, &invoice.id).await; + + let config = crate::server_config::ServerConfig::load(); + + let response_body = json!({ + "pod_info": pod_info, + "tnc": config.tnc.clone(), + }); + + return status::Custom(Status::Ok, Json(response_body)); +} + #[get("/token/token_verify/")] pub async fn token_verify(token_server: &State, token_id: String) -> status::Custom> { diff --git a/token-server/src/main.rs b/token-server/src/main.rs index 044c1487..fca9dd92 100644 --- a/token-server/src/main.rs +++ b/token-server/src/main.rs @@ -35,6 +35,7 @@ async fn main() { .mount("/", routes![ endpoints::token::token_init, endpoints::token::token_verify, + endpoints::token::token_gen, ]) .register("/", catchers![ not_found, diff --git a/token-server/src/server_config.rs b/token-server/src/server_config.rs index eabe226c..df7d486c 100644 --- a/token-server/src/server_config.rs +++ b/token-server/src/server_config.rs @@ -1,6 +1,6 @@ use config::{Config as ConfigRs, Environment, File}; use serde::{Serialize, Deserialize}; -use std::env; +use std::{env, fs}; /// Config struct storing all StataChain Entity config #[derive(Debug, Serialize, Deserialize)] @@ -17,6 +17,8 @@ pub struct ServerConfig { pub delay: u64, /// Postgres connection string pub connection_string: String, + /// Tnc string + pub tnc: String, } impl Default for ServerConfig { @@ -28,6 +30,7 @@ impl Default for ServerConfig { fee: String::from("10000"), delay: 3600, connection_string: String::from("postgresql://postgres:postgres@localhost/mercury"), + tnc: fs::read_to_string("../tnc.html").unwrap_or_else(|_| String::from("")), } } } @@ -41,6 +44,7 @@ impl From for ServerConfig { fee: config.get::("fee").unwrap_or_else(|_| String::new()), delay: config.get::("delay").unwrap_or(0), connection_string: config.get::("connection_string").unwrap_or_else(|_| String::new()), + tnc: fs::read_to_string("../tnc.html").unwrap_or_else(|_| String::from("")), } } } @@ -73,6 +77,7 @@ impl ServerConfig { fee: get_env_or_config("fee", "FEE"), delay: get_env_or_config("delay", "DELAY").parse::().unwrap(), connection_string: get_env_or_config("connection_string", "CONNECTION_STRING"), + tnc: fs::read_to_string("../tnc.html").unwrap_or_else(|_| String::from("")), } } } diff --git a/token-server/tnc.html b/token-server/tnc.html new file mode 100644 index 00000000..680ae9aa --- /dev/null +++ b/token-server/tnc.html @@ -0,0 +1,98 @@ +
+ Terms of Use +

Users of Mercury Wallet should carefully read the terms of use detailed below. By clicking ‘Agree’ or by accessing or downloading our services a User agrees to be bound by these Terms of Use. These Terms of User are not assignable by the user to anyone else.

+
Definitions
+

"Coinswap Conductor Service" is a service that coordinates atomic statecoin swaps to prevent third parties from linking outputs on the public Bitcoin blockchain;

+

“Layer Two Limited” is a limited liability, International Business Company registered in the Republic of Seychelles. References to Layer Two Limited include references to its holding subsidiaries, affiliates, partners, agents, assignees, employees, licensors, service providers or subcontractors;

+

“Mercury Server” means the Statechain entity and the Coinswap Conductor Service;

+

“Mercury Software” means the software that creates the User’s Wallet and operates the Mercury Server (Statechain Entity and Swap Conductor);

+

“Mercury Wallet” means Mercury Wallet, its subsidiaries and affiliates as owned and operated by Layer Two Limited;

+

“Private Key” means the encrypted information stored locally on the User’s computer in a wallet file which enables access to the wallet;

+

“Recovery words” means those words automatically and randomly generated by the software upon the creation of the wallet for the securing access to the wallet;

+

“Password” means an additional word added optionally by the User for the purpose of recovery of the access to the Wallet;

+

“User” is the individual person or entity using the services provided by Layer Two Limited;

+

“User’s Wallet” is the software creating an individualised wallet application created specifically by and for the User enabling the User to access the Bitcoin network and the Mercury Server without the need or requirement to create or maintain a user account; and

+

“Wallet back up” means the combination of the recovery words and the password.

+
General
+

Layer Two Limited provides, markets and operates Mercury Wallet, offering a freely downloadable, open-source desktop Bitcoin wallet under the GNU General Public License.

+
Application
+

These terms and conditions apply to all use of the services provided by Layer Two Limited. These Terms of Use apply to the download of the User Wallet, any access and use of the User Wallet and Mercury Software, the website at https://mercurywallet.com or its onion mirror at http://mercury32vj43p4ychitp5qgqbcwmz36alalpd76nma3zbcedjmgyoqd.onion and its Statechain Entity and Conductor services (as defined below), and any of the other Services related to or utilizing any of the foregoing, which are referred to in these “Terms of Use” as the “Mercury Services” or “Services”.

+
Security and User responsibility
+

All services provided by Mercury Wallet are on a non-custodial basis. Layer Two Limited and the Mercury Software does not have access to, or the ability to decrypt a User’s Wallet. Only the user can decrypt their stored information in the User Wallet.

+

Layer Two Limited does not keep or store User’s keys. The safekeeping of User’s keys is the sole responsibility of the User.

+

Layer Two Limited will not ask for recovery words, passwords or similar security-related information. Users should never provide any security-critical information to any person purporting to represent Layer Two Limited, its affiliates or partners.

+

The User’s Wallet and the Mercury Server perform timelocked backup transactions automatically. The user bears the sole responsibility for performing the broadcast of such transactions. Layer Two Limited will not be held responsible for failures to perform this function on time.

+

Users use this service in their own discretion and in compliance with all applicable laws and regulations. Users assume full responsibility for the consequences of their use of the service, including the safekeeping of their recovery words, passwords and stored keys, and user uses the services at their own risk.

+

Layer Two Limited is unable to monitor or regulate the User’s use of the services.

+
User warranties
+

The User confirms and warrants that:

+
    +
  • Where they are representing a legal entity or company, that they have the authorisation and power to bind the legal entity or company to the terms of service agreement and/or to use this service on behalf of that entity or company.
  • +
  • That they have legal capacity to accept these terms and conditions and enter into this agreement. The Software is not available to persons under the age of 18 years old. Users who do not qualify are not permitted to use the Mercury Software unless specifically permitted to contract under their applicable domestic law.
  • +
  • That they have legal capacity to enter into the transactions using the Mercury Wallet.
  • +
  • They are using the services in compliance with their own local laws and jurisdiction.
  • +
  • The user is aware that national taxation laws may apply to Bitcoin transactions. The User undertakes sole responsibility for determining, calculating and paying any taxes or duties applicable to their transactions under the laws or regulations applicable to their use of the service. Layer Two Limited will not calculate, determine, pay, collect any revenue on behalf of any national government or user.
  • +
  • Users are aware that investment in Bitcoin can lead to loss of money over time. Layer Two Limited will not be held liable for damages or loss due to the fluctuations in the value of Bitcoin.
  • +
  • Users assume use of the service at their own risk. Layer Two Limited is not liable for the actions, decisions or other behaviour of the user taken in reliance on information provided by third party services.
  • +
+
Reference information on Mercury Wallet website
+

Mercury Wallet provides reference information of a general nature on its website. The information that is provided by Layer Two Limited is not intended to replace professional legal, financial or investment advice.

+

Any indicative exchange prices displayed on the website are provided by third party services and not by Mercury Wallet itself. Layer Two Limited is not liable for reliance on information provided by third party services.

+
Provisions related to Bitcoin
+

Layer Two Limited makes no guarantees that Bitcoins can be exchanged, sold or traded at the price displayed by indicative third party services.

+

Layer Two Limited has no control over the value of Bitcoin or the operation of the underlying software protocols which govern the operation of Bitcoin.

+

Layer Two Limited is not responsible for the functioning of the underlying software protocols which govern the operation of Bitcoin and does not guarantee their functionality, security or availability. Layer Two Limited will not be liable for any loss or damages incurred as a result of the failure or inaccessibility of the underlying protocols.

+
Force Majeure and Acts of God
+

Layer Two Limited and the User agree to not hold liable the other party for any breach of this agreement due to inability to perform as a result of an act of God or an inevitable accident or other events out of the control of the parties, including but not limited to fires, telecommunication interruptions, utility or power failures, equipment failures, labour strikes, riots, war, non-performance of vendors or suppliers, or other causes over which the respective party have no reasonable control, provided that the party concerned has procedures in place to avoid the effects of such events.

+

Damages or losses arising from situations of impossibility to perform under this agreement will be borne by the parties individually.

+
Accessing the wallet
+

The User is granted sole access to its User Wallet which is enabled through the use of recovery words, passwords and encrypted secret keys.

+

Layer Two Limited does not store or otherwise have access to the recovery words, passwords or Private Keys and cannot recover the Wallet Backup in the event of loss of it by the User.

+

The User is solely responsible for ensuring that the Wallet Backup and all passwords are secure. The User should not share this information with any person.

+

Layer Two Limited is not able to restore access to the wallet in any circumstances upon the loss of the Wallet back up.

+

Layer Two Limited is not liable for any losses arising as a result of the User losing access to the wallet for any reason, including the loss of Bitcoin in a wallet occurring due to loss or theft of the Private Key, Password, or Wallet back up.

+
Prohibited Activities
+

Notwithstanding the generality of the foregoing, the User agrees to use Mercury Software in a lawful manner and to refrain from any activity which hinders or otherwise adversely affects the performance of or the provision by Layer Two Limited of its services to the User or any other users.

+

The User undertakes not to "Reverse Engineer", change, modify, hack, translate, copy, distribute, pledge, assign, transfer, make derivative works, exploit, encumber or crack any portion of the Software.

+

The User specifically agrees to defend, indemnify and hold harmless Layer Two Limited against any and all claims, costs, losses, damages, liability, judgments and expenses (including without limitation costs and reasonable attorneys’ fees) in connection with or arising from or in any way related to the use of the Mercury Software by the User in breach of these Terms of Use or use of the Mercury Software.

+

The User undertakes to inform Layer Two Limited immediately, or as early as possible, of any use of the Mercury Software by it, whether advertent or inadvertent which may negatively affect the rights of or cause any loss or damage to, any other person or entity.

+
Fees for services
+

The User will not be charged by Layer Two Limited for downloading the User Wallet, depositing Bitcoin, or transactions of statecoins on the Mercury Server.

+

The User will be liable for transactions fees charged by the Bitcoin network, a third party separate of Layer Two Limited. The User authorises the wallet to automatically deduct transaction fees from the User’s withdrawal amount and transmit the same amount to the Bitcoin network.

+

A percentage fee is only charged by Layer Two Limited upon withdrawal from the service to a third-party wallet, regardless of the number of transfers or coinswaps performed using the Mercury Software.

+

The User acknowledges full knowledge that a transaction fee of 0.5% (point five percent) of the value of the deposit into the wallet is due and payable upon the withdrawal of the Bitcoin from the User Wallet. The User authorises Layer Two Limited to automatically deduct the transaction fees from the value of the Bitcoin on the withdrawal from the wallet.

+

Layer Two Limited reserves the right to alter the percentage charged to the User or to change the fees payable by the User for the services provided by Mercury Wallet with 30 days advance notice of any such chance. Notice will be in writing, published on this website and all best efforts will be undertaken to ensure that the User has knowledge of the change of fees applicable.

+
Inapplicability of financial regulation law
+

Layer Two Limited is not a financial institution for the purposes of the Seychelles Financial Institutions Act 14 of 2004 as amended or any other statue so regulations and does not provide banking services to the User.

+

Layer Two Limited does not perform any acts as a bank, including but not limited to receiving money deposits, extending credit facilities, investment of own or User funds, buying and selling money market instruments, providing money transmission services, buying and selling foreign currency, issuing and administering means of payment, money brokering, safekeeping and administration of valuables, providing portfolio management or advice or in any other way acting as a custodian, possessor or guardian, exchange or financial intermediary of or for the User’s Bitcoins.

+

The User Wallet enables coins to be transferred between owners via the Mercury Server, however, the Mercury Server does not have control or custody over the funds and does not possess, store or transmit value belonging to others.

+

The User accepts full knowledge that Layer Two Limited is not performing the functions of a financial institution or bank and that the transactions undertaken using the Mercury Software are exempt from the provisions of law applying to financial institutions.

+
Intellectual Property Rights
+

The Mercury Software is open-sourcse under the GNU license and permission is hereby granted free of charge, to any person obtaining a copy of this software and associated documentation files to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

+

The User cedes full ownership to any feedback that it provides on the Mercury Wallet services to Layer Two Limited, including the suggestion of content, features or documents. This feedback is non-confidential and shall become the sole property of Layer Two Limited to use or develop without restriction.

+

All trademarks, servicemarks, designs, logos, URLs and trade names including by not limited to ‘Mercury Wallet’, ‘Mercury Server’ and ‘Layer Two Limited’ that are displayed on the Mercury Wallet services are granted to the User on a limited, non-exclusive, revocable, royalty free, non-transferable, non-sublicenceable licence to access and use in relation to the use of the Mercury Software.

+

The User accepts full knowledge that Layer Two Limited is not performing the functions of a financial institution or bank and that the transactions undertaken using the Mercury Software are exempt from the provisions of law applying to financial institutions.

+
Disclaimer of warranties and representations
+

Save as contained in the provisions of this Terms of Use Agreement, use of the Mercury Software by the User is voluntary and without any reliance on warranty, representation or undertaking of any type.

+

Except to the extent that these have been specifically reduced to writing in this Terms of Use Agreement, Layer Two Limited disclaims all warranties, representation and conditions relating to the use of the Mercury Software. It further disclaims any implied warranties relating to title, non-infringement, merchantability and fitness for a particular purpose.

+
Assumption of liability
+

The User assumes the full risk and conditions of liability attaching to the use of the Mercury Software.

+

TO THE MAXIMUM EXTENT PERMITTED BY LAW, UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, DELICT/TORT, CONTRACT OR OTHERWISE, SHALL LAYER TWO LIMITED, MERCURY WALLET OR ANY OF ITS UNDERLYING SERVICE PROVIDERS, BUSINESS PARTNERS, INFORMATION PROVIDERS, ACCOUNT PROVIDERS, LICENSORS, OFFICERS, DIRECTORS, EMPLOYEES, DISTRIBUTORS OR AGENTS; BE LIABLE TO THE USER OR ANY OTHER PERSON FOR ANY MONEY DAMAGES, WHETHER DIRECT, INDIRECT, SPECIAL, INCIDENTAL, COVER, RELIANCE OR CONSEQUENTIAL DAMAGES, EVEN IF LAYER TWO LIMITED SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.

+

IN THE EVENT THAT, NOTWITHSTANDING THE FOREGOING, LAYER TWO LIMITED IS FOUND LIABLE TO THE USER FOR DAMAGES FROM ANY CAUSE WHATSOEVER, AND REGARDLESS OF THE FORM OF THE ACTION [WHETHER IN CONTRACT, TORT (INCLUDING NEGLIGENCE), DELICT, SOFTWARE LIABILITY OR OTHERWISE], THE MAXIMUM AGGREGATE LIABILITY OF LAYER TWO LIMITED TO THE USER ARISING IN CONNECTION WITH THIS AGREEMENT SHALL BE LIMITED TO THE AMOUNT THE USER PAID FOR THE SOFTWARE IN THE TWELVE (12) MONTHS PRIOR TO THE ACCRUAL OF THE APPLICABLE CLAIM, LESS ANY DAMAGES PREVIOUSLY PAID BY LAYER TWO LIMITED TO THE USER IN THAT TWELVE (12) MONTH PERIOD.

+
Links to Third-Party Websites
+

Mercury Website provides users links to third-party websites. These links are provided to users as a convenience, and Layer Two Limited is not responsible for the content of any linked website. Any non-Layer Two Limited website accessed from this website is independent from Layer Two Limited, and Layer Two Limited has no control over the content of that website. In addition, a link to any non-Layer Two Limited website does not imply that Layer Two Limited endorses or accepts any responsibility for the content or use of such website.

+
Entire Agreement
+

These Terms of Use constitute the entire agreement (complete and exclusive) between Layer Two Limited and the User and supersede or replace any previous or contemporaneous terms or agreements, representations, warranties or understandings, whether written or oral.

+

If any provision of the Agreement is found to be unenforceable or invalid, that provision will be limited or eliminated to the minimum extent necessary so that this Agreement will otherwise remain in full force, in effect and enforceable.

+
Assignment
+

The rights and obligations arising under these Terms and Conditions may be assigned to and become binding on the parties’ parent companies, subsidiaries, or legal affiliates and will survive a merger, consolidation, or sale of Layer Two Limited’s assets.

+
No waiver
+

Delayed, late or failed performance by Layer Two Limited to exercise or enforce any right or remedy (or any part thereof) accruing to it under these Terms of Use or by law does not constated a waiver of that or any other right or remedy. Layer Two Limited will not be precluded from further exercising that or any other lawful right or remedy.

+
Governing law and choice of jurisdiction
+

Any dispute or claim arising out of or in connection with the use of Layer Two Limited’s services, including disputes related to or arising from these Terms of Use, shall be governed exclusively by Seychellois law and the courts of Seychelles shall have exclusive jurisdiction to hear and determine any such disputes or claims.

+

Layer Two Limited will not be held liable for actions of its users in breach of foreign laws. End users are solely responsible for ensuring that they comply with the laws of the country in which they are resident, domiciled or otherwise present.

+
Privacy Policy
+

Layer Two Limited’s Privacy Policy is located at (link). By using Mercury Software, the User accepts and agrees to all terms, provisions, and conditions of the Privacy Policy.

+
Additional Information
+

If you have any questions about the use of Mercury Wallet or these Terms of Use, please contact us at (hyperlink applicable email address and physical address for contact)

+
\ No newline at end of file