Akvelon | Case Study: Bitcoin Transaction Optimization
32779
post-template-default,single,single-post,postid-32779,single-format-standard,ajax_fade,page_not_loaded,,qode-theme-ver-8.0,wpb-js-composer js-comp-ver-4.9.2,vc_responsive
 
seattle blockchain Bitcoin Coin Selection with Leverage

08 Jul Case Study: Bitcoin Transaction Optimization

Business Need

  • Develop test workflow, which simulates payment gateway service workflow. It should consists of following parts:
    • generating payment requests from clients
    • combining payment requests into bitcoin transaction (batching payments) and optimizing them
    • predicting expected fee rate to include transaction into the next block of the blockchain
    •  sending optimized transaction into bitcoin network
  • Develop bitcoin transaction optimization algorithm, which allows quickly find optimal set of UTXO’s such that the output change is 0 or is an optimal size for reuse

 Develop ML-algorithm for predicting fee rates required to including transaction into the next block of the blockchain based on DNN approach

Akvelon’s Engagement

  • Deployed test bitcoin full node on AWS EC2 instance for sending transactions into bitcoin test network
  •  Developed Pay Request Generator component, which allows to create test payment requests
  •  Developed Transaction Sender component, which allows to send optimized transactions to bitcoin testnet via test bitcoin full node
  • Developed Transaction Optimizer component implementing the branch and bound algorithm
  • Developed Fee Predictor component consisting of following parts:
  • Data Collector, which collects training data of blockchain and mempool logs for prediction model from open sources
    •  Fee Predictor Trainer, which trains the DNN-model using prepared training data
    • Fee Predictor Service, which predicts an expected value fee per byte, required for including transaction into the next block of blockchain using trained DNN-model and considering current mempool state. It was deployed on AWS EC2 instance and provides expected fee values via REST-API.
  • Implemented algorithms:
    • Within the Transaction Optimizer component there was implemented the branch and bound algorithm which finds an optimal set of UTXOs for received payment requests
    •  Within the Fee Predictor Trainer component there was developed DNN-model using TensorFlow with single input layer, 6 hidden layers and single output layer

Benefits & Results

  • Test workflow simulated work of payment gateway service was developed and documented
  • Developed transaction optimization algorithm based on the branch and bound algorithm, which quite fast finds optimal solution for transferring amounts up to 10 BTC for one batching transaction.  Especially for convenience of testing there were developed request generator, which provides test pay requests with random transferring amounts, and UTXO generator, which provides test set of UTXOs with random amounts.
  • Based on TensorFlow there was developed and trained DNN-model, which provides pretty good results of predicting fee rates. DNN-model was trained on a real historical data of blockchain and mempool. Tests executed on a test sample revealed that predicted fee rates fit into range between median block fee and minimum block fee. It means that the transaction using our predictions with high probability will include into the next block of the blockchain.

 

Technologies Used

Python, TensorFlow, Bitcoin Core, AWS

 

 



Akvelon

Akvelon

We Make BIG Software Happen. Contact Us