Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor transaction creating apis #267

Open
KnowWhoami opened this issue Sep 22, 2024 · 1 comment
Open

Refactor transaction creating apis #267

KnowWhoami opened this issue Sep 22, 2024 · 1 comment
Labels
bug Something isn't working enhancement This enhances the code and improves stuffs
Milestone

Comments

@KnowWhoami
Copy link
Collaborator

Currently we have different types of apis which focuses on creating a particular types of transactions.
for eg

  • spend_from_wallet api which is used to general purpose transaction.
  • create_funding_txes -> which creates funding txs for starting coinswap
  • create_fidelity -> creates fidelity bond by first creating , broadcasting the fidelity tx and makes further updates.
  • create_senders_contract_tx -> creates contract tx which spends utxos generated by funding txes.
    and many more...

But all these api's do same work at some level -> i.e they all contain reductant code for creating a transaction , selecting required utxos etc.
This redundancy can be minimised by following proposed structural design:

fn create_signed_tx(fee:Amount, amount:SendAmount, destinations:Destination, coins_to_spend)-> Result<Transaction, WalletError>{
   // private function
   // A general tx generating api which will create any type of transactions , sign it and return tx instance.
   
   // implementation -> same as `spend_from_wallet` api.
   
   return transaction
}

pub create_fedility{

   // do some work  related to fedility.

   // select required utxos for making fidelity bonds.
   let selected_utxos= self.coin_select(..);

   // create tx instance and sign it.  
   let signed_tx= create_signed_tx(...);

   // do some work related to fidelity.   
}


// .... Similarly we can create other specific transaction api which will be wrappers .

Enhancements:

  • Remove reductant code which focuses on creating transaction struct and selecting required utxos.
  • Improve code quality and managability.
@KnowWhoami KnowWhoami changed the title Refactor transaction creating api's Refactor transaction creating apis Sep 22, 2024
@KnowWhoami KnowWhoami added bug Something isn't working enhancement This enhances the code and improves stuffs labels Sep 22, 2024
@KnowWhoami
Copy link
Collaborator Author

I am taking this up.

@KnowWhoami KnowWhoami added this to the v0.1.1 milestone Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement This enhances the code and improves stuffs
Projects
None yet
Development

No branches or pull requests

1 participant