event icon indicating copy to clipboard operation
event copied to clipboard

feat: WIF private key sweeps

Open a-khushal opened this issue 7 months ago • 9 comments

Description

Relates to issue: ZEUS-2791

This PR aims to implement WIF private key sweeps

This pull request is categorized as a:

  • [x] New feature
  • [ ] Bug fix
  • [ ] Code refactor
  • [ ] Configuration change
  • [ ] Locales update
  • [ ] Quality assurance
  • [ ] Other

Checklist

  • [x] I’ve run yarn run tsc and made sure my code compiles correctly
  • [x] I’ve run yarn run lint and made sure my code didn’t contain any problematic patterns
  • [x] I’ve run yarn run prettier and made sure my code is formatted correctly
  • [x] I’ve run yarn run test and made sure all of the tests pass

Testing

If you modified or added a utility file, did you add new unit tests?

  • [ ] No, I’m a fool
  • [ ] Yes
  • [x] N/A

I have tested this PR on the following platforms (please specify OS version and phone model/VM):

  • [x] Android
  • [ ] iOS

I have tested this PR with the following types of nodes (please specify node version and API version where appropriate):

  • [ ] Embedded LND
  • [ ] LND (REST)
  • [ ] LND (Lightning Node Connect)
  • [x] Core Lightning (CLNRest)
  • [ ] Nostr Wallet Connect
  • [ ] LndHub

Locales

  • [ ] I’ve added new locale text that requires translations
  • [ ] I’m aware that new translations should be made on the ZEUS Transfix page and not directly to this repo

Third Party Dependencies and Packages

  • [ ] Contributors will need to run yarn after this PR is merged in
  • [ ] 3rd party dependencies have been modified:
    • verify that package.json and yarn.lock have been properly updated
    • verify that dependencies are installed for both iOS and Android platforms

Other:

  • [ ] Changes were made that require an update to the README
  • [ ] Changes were made that require an update to onboarding

a-khushal avatar May 03 '25 16:05 a-khushal

@kaloudis, the code rn, validates the WIF entered, the sweeps functionality is pending, please review the current changes.

a-khushal avatar May 03 '25 16:05 a-khushal

@kaloudis, how should the user choose the destination address to sweep the UTXOs to?

a-khushal avatar May 04 '25 01:05 a-khushal

@kaloudis, how should the user choose the destination address to sweep the UTXOs to?

can I use getNewAddress from backendUtils to generate a new address where the UTXOs will be swept?

a-khushal avatar May 04 '25 02:05 a-khushal

@kaloudis, how should the user choose the destination address to sweep the UTXOs to?

can I use getNewAddress from backendUtils to generate a new address where the UTXOs will be swept?

In the new swaps branch we have both a field where a user can input a destination address manually as well as a button to to autogenerate one. This is probably the best approach here as well.

kaloudis avatar May 04 '25 03:05 kaloudis

In the new swaps branch we have both a field where a user can input a destination address manually as well as a button to to autogenerate one. This is probably the best approach here as well.

got it, will check that out.

a-khushal avatar May 04 '25 03:05 a-khushal

@kaloudis, can i use tiny-secp256k1 library, because

import ECPairFactory from 'ecpair';
import * as ecc from '@noble/secp256k1';
const ECPair = ECPairFactory(ecc);

this has an error saying ecc is not of type TinySecp256k1Interface

a-khushal avatar May 04 '25 13:05 a-khushal

i need use it as ECPair.fromWIF(wif) for getting keypair

a-khushal avatar May 04 '25 13:05 a-khushal

Try import ecc from '../zeus_modules/noble_ecc';

kaloudis avatar May 04 '25 18:05 kaloudis

a-khushal avatar May 29 '25 17:05 a-khushal

import ECPairFactory from 'ecpair';
import ecc from '../zeus_modules/noble_ecc';
const ECPair = ECPairFactory(ecc);

@kaloudis i'm using the above, but getting error:

commenting those 3 lines makes the app run.

a-khushal avatar Jun 28 '25 22:06 a-khushal

a-khushal avatar Jun 28 '25 23:06 a-khushal

import ECPairFactory from 'ecpair';
import ecc from '../zeus_modules/noble_ecc';
const ECPair = ECPairFactory(ecc);

@kaloudis i'm using the above, but getting error:

commenting those 3 lines makes the app run.

this has been resolved, in the current code by not using ECPair itself, instead import ecc from '../zeus_modules/noble_ecc'; is sufficient and function calls have been made on it.

a-khushal avatar Jun 29 '25 11:06 a-khushal

@kaloudis can you review this?

a-khushal avatar Jul 04 '25 07:07 a-khushal

https://github.com/user-attachments/assets/f15ff459-8cf0-408a-8d17-09cf2a48f17d

current working of the sweep

a-khushal avatar Jul 11 '25 16:07 a-khushal

@a-khushal Please resolve the conflicts

shubhamkmr04 avatar Jul 17 '25 12:07 shubhamkmr04

@a-khushal Please resolve the conflicts

@shubhamkmr04 done

a-khushal avatar Jul 17 '25 13:07 a-khushal

Should we put it in Tools section? cc @kaloudis

Yes, let's put it under Tools.

kaloudis avatar Jul 17 '25 21:07 kaloudis

Should we put it in Tools section? cc @kaloudis

Yes, let's put it under Tools.

done, i've moved it to tools

a-khushal avatar Jul 18 '25 10:07 a-khushal

Screenshot_1753718369

the generated on-chain address stays on until we refresh the app. I think we should be able to create a new one each time we come on the view

shubhamkmr04 avatar Jul 28 '25 16:07 shubhamkmr04

@shubhamkmr04 it should be fixed now(259892a)

a-khushal avatar Jul 30 '25 17:07 a-khushal

@a-khushal can you add a list of checkboxes in the PR description for us to keep track of which script types have been implemented so far?

kaloudis avatar Aug 25 '25 23:08 kaloudis

@a-khushal can you add a list of checkboxes in the PR description for us to keep track of which script types have been implemented so far?

@kaloudis I have updated

a-khushal avatar Aug 26 '25 15:08 a-khushal

@a-khushal please rebase

Also, thoughts on P2TR sweeps? Is it practical to do? If not, should we just include a disclaimer instead. Is that necessary?

kaloudis avatar Sep 11 '25 13:09 kaloudis

can we have a message stating P2TR sweeps aren't supported yet? if an user is trying to sweep a p2tr addr

a-khushal avatar Sep 11 '25 13:09 a-khushal

can we have a message stating P2TR sweeps aren't supported yet? if an user is trying to sweep a p2tr addr

Yes, create a separate commit for this that includes commented code that links to the issue and/or potential draft PR of the work you started on it, so we can keep track of it.

kaloudis avatar Sep 11 '25 13:09 kaloudis

@kaloudis i've removed the code for p2tr. i will raise another PR specific to p2tr sweep once this PR get's merged.

a-khushal avatar Sep 11 '25 19:09 a-khushal

@kaloudis i've removed the code for p2tr. i will raise another PR specific to p2tr sweep once this PR get's merged.

Still see the P2TR stuff in 627f2b4576e494621ce617b2e316ff744bd87d2d

kaloudis avatar Sep 11 '25 22:09 kaloudis

@kaloudis should be fixed now.

a-khushal avatar Sep 12 '25 05:09 a-khushal

The only thing I would really like to see is some sort of warning when using Mempool.space instead of your own to broadcast

@kaloudis

a-khushal avatar Oct 02 '25 19:10 a-khushal

@a-khushal, i think we should move WIFSweeper.tsx to the tools folder

ajaysehwal avatar Oct 20 '25 12:10 ajaysehwal