@@ -22,6 +22,7 @@ import {dateId} from "./util/dates";
2222import ReflinkService from "./services/ReflinkService" ;
2323import config from "./util/config" ;
2424import * as ecc from "eosjs-ecc" ;
25+ import BitcoinService from "./services/BitcoinService" ;
2526
2627const bucket = couchbase ( 'scatter' ) ;
2728
@@ -241,33 +242,6 @@ routes.post('/apps', async (req, res) => {
241242
242243routes . post ( '/create_eos' , async ( req , res ) => {
243244 returnResult ( { error :"makeaccounts is no longer valid." } , req , res ) ;
244- // const defaultError = {error:'There was an error creating the account. Please try again later.'};
245- // const {transaction_id, signature, keys, account_name} = req.body;
246- //
247- // if(!keys.hasOwnProperty('active') || !keys.hasOwnProperty('owner') || !keys.active.length || !keys.owner.length){
248- // return returnResult({error:'Invalid keys'}, req, res);
249- // }
250- //
251- // const minimumCost = await AccountService.getAccountMinimumCost();
252- // if(!minimumCost) return returnResult(defaultError, req, res);
253- //
254- // const transactionStatus = await TransactionService.eos(transaction_id, minimumCost, PAYMENT_ACCOUNTS.EOS.NEW_ACCOUNT);
255- // if(!transactionStatus || transactionStatus.hasOwnProperty('error')) return returnResult(transactionStatus.hasOwnProperty('error')
256- // ? {error:transactionStatus.error}
257- // : {error:'The transaction could not be verified.'}, req, res);
258- //
259- //
260- // const [quantity, memo] = transactionStatus;
261- //
262- // const leftForResources = parseFloat(quantity - minimumCost).toFixed(4);
263- // if(!leftForResources || leftForResources <= 0) return returnResult({error:'There was not enough EOS left for resources.'}, req, res);
264- //
265- // if(memo !== keys.active) return returnResult({error:'The signature for account creation did not match the key from the exchange memo'}, req, res);
266- //
267- // const created = await AccountService.createEosAccount(account_name, keys, leftForResources, transaction_id, signature);
268- // if(!created) return returnResult(defaultError, req, res);
269- //
270- // returnResult({created}, req, res);
271245} ) ;
272246
273247routes . post ( '/create_bridge' , async ( req , res ) => {
@@ -306,6 +280,30 @@ routes.get('/machine/:id', async (req, res) => {
306280
307281
308282
283+ /************************************************/
284+ /* */
285+ /* BITCOIN HELPERS */
286+ /* */
287+ /************************************************/
288+
289+
290+ routes . get ( '/btc/balance/:address' , async ( req , res ) => {
291+ const address = req . params . address ;
292+ returnResult ( await BitcoinService . getBalance ( address ) , req , res ) ;
293+ } ) ;
294+
295+ routes . get ( '/btc/unspent/:address' , async ( req , res ) => {
296+ const address = req . params . address ;
297+ returnResult ( await BitcoinService . getUnspent ( address ) , req , res ) ;
298+ } ) ;
299+
300+ routes . post ( '/btc/pushtx' , async ( req , res ) => {
301+ const signed = req . body . signed ;
302+ returnResult ( await BitcoinService . pushTransaction ( signed ) , req , res ) ;
303+ } ) ;
304+
305+
306+
309307routes . all ( '*' , ( req , res ) => res . sendStatus ( 403 ) ) ;
310308
311309export default routes ;
0 commit comments