Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions libwallet/assets/btc/account_mixer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package btc

import sharedW "github.com/crypto-power/cryptopower/libwallet/assets/wallet"

const (
smalletSplitPoint = 000.00262144
MixedAccountBranch = 0
)

func (asset *Asset) AddAccountMixerNotificationListener(accountMixerNotificationListener *AccountMixerNotificationListener, uniqueIdentifier string) error {

Check warning on line 10 in libwallet/assets/btc/account_mixer.go

View workflow job for this annotation

GitHub Actions / Build

unused-parameter: parameter 'accountMixerNotificationListener' seems to be unused, consider removing or renaming it as _ (revive)

Check failure on line 10 in libwallet/assets/btc/account_mixer.go

View workflow job for this annotation

GitHub Actions / Build

unused-parameter: parameter 'accountMixerNotificationListener' seems to be unused, consider removing or renaming it as _ (revive)

Check warning on line 10 in libwallet/assets/btc/account_mixer.go

View workflow job for this annotation

GitHub Actions / Build

unused-parameter: parameter 'accountMixerNotificationListener' seems to be unused, consider removing or renaming it as _ (revive)

Check failure on line 10 in libwallet/assets/btc/account_mixer.go

View workflow job for this annotation

GitHub Actions / Build

unused-parameter: parameter 'accountMixerNotificationListener' seems to be unused, consider removing or renaming it as _ (revive)
return nil
}

func (asset *Asset) RemoveAccountMixerNotificationListener(uniqueIdentifier string) {

Check warning on line 14 in libwallet/assets/btc/account_mixer.go

View workflow job for this annotation

GitHub Actions / Build

unused-parameter: parameter 'uniqueIdentifier' seems to be unused, consider removing or renaming it as _ (revive)

Check failure on line 14 in libwallet/assets/btc/account_mixer.go

View workflow job for this annotation

GitHub Actions / Build

unused-parameter: parameter 'uniqueIdentifier' seems to be unused, consider removing or renaming it as _ (revive)

Check warning on line 14 in libwallet/assets/btc/account_mixer.go

View workflow job for this annotation

GitHub Actions / Build

unused-parameter: parameter 'uniqueIdentifier' seems to be unused, consider removing or renaming it as _ (revive)

Check failure on line 14 in libwallet/assets/btc/account_mixer.go

View workflow job for this annotation

GitHub Actions / Build

unused-parameter: parameter 'uniqueIdentifier' seems to be unused, consider removing or renaming it as _ (revive)
}

// CreateMixerAccounts creates the two accounts needed for the account mixer. This function
// is added to ease unlocking the wallet before creating accounts. This function should be
// used with auto cspp mixer setup.
func (asset *Asset) CreateMixerAccounts(mixedAccount, unmixedAccount, privPass string) error {

Check warning on line 20 in libwallet/assets/btc/account_mixer.go

View workflow job for this annotation

GitHub Actions / Build

unused-parameter: parameter 'mixedAccount' seems to be unused, consider removing or renaming it as _ (revive)

Check failure on line 20 in libwallet/assets/btc/account_mixer.go

View workflow job for this annotation

GitHub Actions / Build

unused-parameter: parameter 'mixedAccount' seems to be unused, consider removing or renaming it as _ (revive)

Check warning on line 20 in libwallet/assets/btc/account_mixer.go

View workflow job for this annotation

GitHub Actions / Build

unused-parameter: parameter 'mixedAccount' seems to be unused, consider removing or renaming it as _ (revive)

Check failure on line 20 in libwallet/assets/btc/account_mixer.go

View workflow job for this annotation

GitHub Actions / Build

unused-parameter: parameter 'mixedAccount' seems to be unused, consider removing or renaming it as _ (revive)
return nil
}

// SetAccountMixerConfig sets the config for mixed and unmixed account. Private passphrase is verifed
// for security even if not used. This function should be used with manual cspp mixer setup.
func (asset *Asset) SetAccountMixerConfig(mixedAccount, unmixedAccount int32, privPass string) error {

Check warning on line 26 in libwallet/assets/btc/account_mixer.go

View workflow job for this annotation

GitHub Actions / Build

unused-parameter: parameter 'mixedAccount' seems to be unused, consider removing or renaming it as _ (revive)

Check failure on line 26 in libwallet/assets/btc/account_mixer.go

View workflow job for this annotation

GitHub Actions / Build

unused-parameter: parameter 'mixedAccount' seems to be unused, consider removing or renaming it as _ (revive)

Check warning on line 26 in libwallet/assets/btc/account_mixer.go

View workflow job for this annotation

GitHub Actions / Build

unused-parameter: parameter 'mixedAccount' seems to be unused, consider removing or renaming it as _ (revive)

Check failure on line 26 in libwallet/assets/btc/account_mixer.go

View workflow job for this annotation

GitHub Actions / Build

unused-parameter: parameter 'mixedAccount' seems to be unused, consider removing or renaming it as _ (revive)
return nil
}

func (asset *Asset) AccountMixerMixChange() bool {
return false
}

func (asset *Asset) AccountMixerConfigIsSet() bool {
return false
}

func (asset *Asset) MixedAccountNumber() int32 {
return -1
}

func (asset *Asset) UnmixedAccountNumber() int32 {
return asset.ReadInt32ConfigValueForKey(sharedW.AccountMixerUnmixedAccount, -1)
}

func (asset *Asset) ClearMixerConfig() {
}

func (asset *Asset) ReadyToMix(_ int) (bool, error) {
return false, nil
}

// StartAccountMixer starts the automatic account mixer
func (asset *Asset) StartAccountMixer(walletPassphrase string) error {

Check warning on line 54 in libwallet/assets/btc/account_mixer.go

View workflow job for this annotation

GitHub Actions / Build

unused-parameter: parameter 'walletPassphrase' seems to be unused, consider removing or renaming it as _ (revive)

Check failure on line 54 in libwallet/assets/btc/account_mixer.go

View workflow job for this annotation

GitHub Actions / Build

unused-parameter: parameter 'walletPassphrase' seems to be unused, consider removing or renaming it as _ (revive)

Check warning on line 54 in libwallet/assets/btc/account_mixer.go

View workflow job for this annotation

GitHub Actions / Build

unused-parameter: parameter 'walletPassphrase' seems to be unused, consider removing or renaming it as _ (revive)

Check failure on line 54 in libwallet/assets/btc/account_mixer.go

View workflow job for this annotation

GitHub Actions / Build

unused-parameter: parameter 'walletPassphrase' seems to be unused, consider removing or renaming it as _ (revive)
return nil
}

func (asset *Asset) readCSPPConfig() *CSPPConfig {
mixedAccount := asset.MixedAccountNumber()
unmixedAccount := asset.UnmixedAccountNumber()

if mixedAccount == -1 || unmixedAccount == -1 {
// not configured for mixing
return nil
}

return &CSPPConfig{
Mixing: true,
MixedAccount: uint32(mixedAccount),
MixedAccountBranch: uint32(MixedAccountBranch),
ChangeAccount: uint32(unmixedAccount),
TicketSplitAccount: uint32(mixedAccount), // upstream desc: Account to derive fresh addresses from for mixed ticket splits; uses mixedaccount if unset
}
}

// StopAccountMixer stops the active account mixer
func (asset *Asset) StopAccountMixer() error {
return nil
}

func (asset *Asset) accountHasMixableOutput(accountNumber int32) bool {

Check warning on line 81 in libwallet/assets/btc/account_mixer.go

View workflow job for this annotation

GitHub Actions / Build

unused-parameter: parameter 'accountNumber' seems to be unused, consider removing or renaming it as _ (revive)

Check failure on line 81 in libwallet/assets/btc/account_mixer.go

View workflow job for this annotation

GitHub Actions / Build

unused-parameter: parameter 'accountNumber' seems to be unused, consider removing or renaming it as _ (revive)

Check warning on line 81 in libwallet/assets/btc/account_mixer.go

View workflow job for this annotation

GitHub Actions / Build

unused-parameter: parameter 'accountNumber' seems to be unused, consider removing or renaming it as _ (revive)

Check failure on line 81 in libwallet/assets/btc/account_mixer.go

View workflow job for this annotation

GitHub Actions / Build

unused-parameter: parameter 'accountNumber' seems to be unused, consider removing or renaming it as _ (revive)
return false
}

// IsAccountMixerActive returns true if account mixer is active
func (asset *Asset) IsAccountMixerActive() bool {
return false
}

func (asset *Asset) publishAccountMixerStarted(walletID int) {

Check warning on line 90 in libwallet/assets/btc/account_mixer.go

View workflow job for this annotation

GitHub Actions / Build

unused-parameter: parameter 'walletID' seems to be unused, consider removing or renaming it as _ (revive)

Check failure on line 90 in libwallet/assets/btc/account_mixer.go

View workflow job for this annotation

GitHub Actions / Build

unused-parameter: parameter 'walletID' seems to be unused, consider removing or renaming it as _ (revive)

Check warning on line 90 in libwallet/assets/btc/account_mixer.go

View workflow job for this annotation

GitHub Actions / Build

unused-parameter: parameter 'walletID' seems to be unused, consider removing or renaming it as _ (revive)

Check failure on line 90 in libwallet/assets/btc/account_mixer.go

View workflow job for this annotation

GitHub Actions / Build

unused-parameter: parameter 'walletID' seems to be unused, consider removing or renaming it as _ (revive)
}

func (asset *Asset) publishAccountMixerEnded(walletID int) {

Check warning on line 93 in libwallet/assets/btc/account_mixer.go

View workflow job for this annotation

GitHub Actions / Build

unused-parameter: parameter 'walletID' seems to be unused, consider removing or renaming it as _ (revive)

Check failure on line 93 in libwallet/assets/btc/account_mixer.go

View workflow job for this annotation

GitHub Actions / Build

unused-parameter: parameter 'walletID' seems to be unused, consider removing or renaming it as _ (revive)

Check warning on line 93 in libwallet/assets/btc/account_mixer.go

View workflow job for this annotation

GitHub Actions / Build

unused-parameter: parameter 'walletID' seems to be unused, consider removing or renaming it as _ (revive)

Check failure on line 93 in libwallet/assets/btc/account_mixer.go

View workflow job for this annotation

GitHub Actions / Build

unused-parameter: parameter 'walletID' seems to be unused, consider removing or renaming it as _ (revive)
}
18 changes: 18 additions & 0 deletions libwallet/assets/btc/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"github.com/lightninglabs/neutrino"
)



// Amount implements the Asset amount interface for the BTC asset
type Amount btcutil.Amount

Expand Down Expand Up @@ -39,3 +41,19 @@ type ExtraNeutrinoChainService interface {
ConnectedCount() int32
Peers() []*neutrino.ServerPeer
}

type CSPPConfig struct {
// Mixing option activates the new version of the coins mixer which is a
// replacement of the old client-server mechanism. Now peer to peer
// mechanism is in place. Ref: https://github.com/decred/dcrwallet/pull/2351
Mixing bool
MixedAccount uint32
MixedAccountBranch uint32
TicketSplitAccount uint32
ChangeAccount uint32
}

type AccountMixerNotificationListener struct {
OnAccountMixerStarted func(walletID int)
OnAccountMixerEnded func(walletID int)
}
94 changes: 94 additions & 0 deletions libwallet/assets/ltc/account_mixer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package ltc

import sharedW "github.com/crypto-power/cryptopower/libwallet/assets/wallet"

const (
smalletSplitPoint = 000.00262144
MixedAccountBranch = 0
)

func (asset *Asset) AddAccountMixerNotificationListener(accountMixerNotificationListener *AccountMixerNotificationListener, uniqueIdentifier string) error {

Check warning on line 10 in libwallet/assets/ltc/account_mixer.go

View workflow job for this annotation

GitHub Actions / Build

unused-parameter: parameter 'accountMixerNotificationListener' seems to be unused, consider removing or renaming it as _ (revive)

Check failure on line 10 in libwallet/assets/ltc/account_mixer.go

View workflow job for this annotation

GitHub Actions / Build

unused-parameter: parameter 'accountMixerNotificationListener' seems to be unused, consider removing or renaming it as _ (revive)

Check warning on line 10 in libwallet/assets/ltc/account_mixer.go

View workflow job for this annotation

GitHub Actions / Build

unused-parameter: parameter 'accountMixerNotificationListener' seems to be unused, consider removing or renaming it as _ (revive)

Check failure on line 10 in libwallet/assets/ltc/account_mixer.go

View workflow job for this annotation

GitHub Actions / Build

unused-parameter: parameter 'accountMixerNotificationListener' seems to be unused, consider removing or renaming it as _ (revive)
return nil
}

func (asset *Asset) RemoveAccountMixerNotificationListener(uniqueIdentifier string) {

Check failure on line 14 in libwallet/assets/ltc/account_mixer.go

View workflow job for this annotation

GitHub Actions / Build

unused-parameter: parameter 'uniqueIdentifier' seems to be unused, consider removing or renaming it as _ (revive)

Check failure on line 14 in libwallet/assets/ltc/account_mixer.go

View workflow job for this annotation

GitHub Actions / Build

unused-parameter: parameter 'uniqueIdentifier' seems to be unused, consider removing or renaming it as _ (revive)
}

// CreateMixerAccounts creates the two accounts needed for the account mixer. This function
// is added to ease unlocking the wallet before creating accounts. This function should be
// used with auto cspp mixer setup.
func (asset *Asset) CreateMixerAccounts(mixedAccount, unmixedAccount, privPass string) error {
return nil
}

// SetAccountMixerConfig sets the config for mixed and unmixed account. Private passphrase is verifed
// for security even if not used. This function should be used with manual cspp mixer setup.
func (asset *Asset) SetAccountMixerConfig(mixedAccount, unmixedAccount int32, privPass string) error {
return nil
}

func (asset *Asset) AccountMixerMixChange() bool {
return false
}

func (asset *Asset) AccountMixerConfigIsSet() bool {
return false
}

func (asset *Asset) MixedAccountNumber() int32 {
return -1
}

func (asset *Asset) UnmixedAccountNumber() int32 {
return asset.ReadInt32ConfigValueForKey(sharedW.AccountMixerUnmixedAccount, -1)
}

func (asset *Asset) ClearMixerConfig() {
}

func (asset *Asset) ReadyToMix(_ int) (bool, error) {
return false, nil
}

// StartAccountMixer starts the automatic account mixer
func (asset *Asset) StartAccountMixer(walletPassphrase string) error {
return nil
}

func (asset *Asset) readCSPPConfig() *CSPPConfig {
mixedAccount := asset.MixedAccountNumber()
unmixedAccount := asset.UnmixedAccountNumber()

if mixedAccount == -1 || unmixedAccount == -1 {
// not configured for mixing
return nil
}

return &CSPPConfig{
Mixing: true,
MixedAccount: uint32(mixedAccount),
MixedAccountBranch: uint32(MixedAccountBranch),
ChangeAccount: uint32(unmixedAccount),
TicketSplitAccount: uint32(mixedAccount), // upstream desc: Account to derive fresh addresses from for mixed ticket splits; uses mixedaccount if unset
}
}

// StopAccountMixer stops the active account mixer
func (asset *Asset) StopAccountMixer() error {
return nil
}

func (asset *Asset) accountHasMixableOutput(accountNumber int32) bool {
return false
}

// IsAccountMixerActive returns true if account mixer is active
func (asset *Asset) IsAccountMixerActive() bool {
return false
}

func (asset *Asset) publishAccountMixerStarted(walletID int) {
}

func (asset *Asset) publishAccountMixerEnded(walletID int) {
}
16 changes: 16 additions & 0 deletions libwallet/assets/ltc/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,19 @@ func (a Amount) MulF64(f float64) sharedW.AssetAmount {
func (a Amount) ToInt() int64 {
return int64(ltcutil.Amount(a))
}

type CSPPConfig struct {
// Mixing option activates the new version of the coins mixer which is a
// replacement of the old client-server mechanism. Now peer to peer
// mechanism is in place. Ref: https://github.com/decred/dcrwallet/pull/2351
Mixing bool
MixedAccount uint32
MixedAccountBranch uint32
TicketSplitAccount uint32
ChangeAccount uint32
}

type AccountMixerNotificationListener struct {
OnAccountMixerStarted func(walletID int)
OnAccountMixerEnded func(walletID int)
}
10 changes: 10 additions & 0 deletions libwallet/assets/wallet/asset_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,14 @@ type Asset interface {
RemoveSendDestination(id int)
SendDestination(id int) *TransactionDestination
UpdateSendDestination(id int, address string, atomAmount int64, sendMax bool) error

CreateMixerAccounts(mixedAccount, unmixedAccount, privPass string) error
IsAccountMixerActive() bool
UnmixedAccountNumber() int32
MixedAccountNumber() int32
StartAccountMixer(walletPassphrase string) error
StopAccountMixer() error
// AddAccountMixerNotificationListener(accountMixerNotificationListener *AccountMixerNotificationListener, uniqueIdentifier string) error
RemoveAccountMixerNotificationListener(uniqueIdentifier string)
// SetAccountMixerConfig(mixedAccount, unmixedAccount int32, privPass string) error
}
5 changes: 5 additions & 0 deletions libwallet/assets/wallet/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,3 +445,8 @@ func (s WordSeedType) AllWords() []string {
return []string{}
}
}

type AccountMixerNotificationListener struct {
OnAccountMixerStarted func(walletID int)
OnAccountMixerEnded func(walletID int)
}
Loading
Loading