Skip to content

Commit

Permalink
Merge remote-tracking branch 'benma/ltclegacy'
Browse files Browse the repository at this point in the history
  • Loading branch information
benma committed Dec 5, 2019
2 parents af07b20 + 5ec2ceb commit 982e154
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 38 deletions.
2 changes: 0 additions & 2 deletions backend/accounts/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package accounts

import (
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/digitalbitbox/bitbox-wallet-app/backend/coins/coin"
"github.com/digitalbitbox/bitbox-wallet-app/backend/keystore"
"github.com/digitalbitbox/bitbox-wallet-app/backend/rates"
Expand Down Expand Up @@ -49,7 +48,6 @@ type Interface interface {
GetUnusedReceiveAddresses() []Address
CanVerifyAddresses() (bool, bool, error)
VerifyAddress(addressID string) (bool, error)
ConvertToLegacyAddress(addressID string) (btcutil.Address, error)
Keystores() *keystore.Keystores
RateUpdater() *rates.RateUpdater
}
Expand Down
17 changes: 0 additions & 17 deletions backend/coins/btc/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -716,23 +716,6 @@ func (account *Account) CanVerifyAddresses() (bool, bool, error) {
return account.Keystores().CanVerifyAddresses(account.signingConfiguration, account.Coin())
}

// ConvertToLegacyAddress converts a ltc p2sh address to the legacy format (starting with
// '3'). Returns an error for non litecoin p2sh accounts.
func (account *Account) ConvertToLegacyAddress(addressID string) (btcutil.Address, error) {
account.synchronizer.WaitSynchronized()
defer account.RLock()()
scriptHashHex := blockchain.ScriptHashHex(addressID)
address := account.receiveAddresses.LookupByScriptHashHex(scriptHashHex)
if address == nil {
return nil, errp.New("unknown address not found")
}
if account.coin.Net() != &ltc.MainNetParams || address.Configuration.ScriptType() != signing.ScriptTypeP2WPKHP2SH {
return nil, errp.New("must be an ltc p2sh address")
}
hash := address.Address.(*btcutil.AddressScriptHash).Hash160()
return btcutil.NewAddressScriptHashFromHash(hash[:], &chaincfg.MainNetParams)
}

// Keystores returns the keystores of the account.
func (account *Account) Keystores() *keystore.Keystores {
return account.keystores
Expand Down
13 changes: 0 additions & 13 deletions backend/coins/btc/handlers/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ func NewHandlers(
handleFunc("/can-verify-extended-public-key", handlers.ensureAccountInitialized(handlers.getCanVerifyExtendedPublicKey)).Methods("GET")
handleFunc("/verify-extended-public-key", handlers.ensureAccountInitialized(handlers.postVerifyExtendedPublicKey)).Methods("POST")
handleFunc("/has-secure-output", handlers.ensureAccountInitialized(handlers.getHasSecureOutput)).Methods("GET")
handleFunc("/convert-to-legacy-address", handlers.ensureAccountInitialized(handlers.postConvertToLegacyAddress)).Methods("POST")
return handlers
}

Expand Down Expand Up @@ -500,15 +499,3 @@ func (handlers *Handlers) getHasSecureOutput(r *http.Request) (interface{}, erro
"optional": optional,
}, nil
}

func (handlers *Handlers) postConvertToLegacyAddress(r *http.Request) (interface{}, error) {
var addressID string
if err := json.NewDecoder(r.Body).Decode(&addressID); err != nil {
return nil, errp.WithStack(err)
}
address, err := handlers.account.ConvertToLegacyAddress(addressID)
if err != nil {
return nil, err
}
return address.EncodeAddress(), nil
}
6 changes: 0 additions & 6 deletions backend/coins/eth/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"time"

"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/digitalbitbox/bitbox-wallet-app/backend/accounts"
"github.com/digitalbitbox/bitbox-wallet-app/backend/accounts/errors"
"github.com/digitalbitbox/bitbox-wallet-app/backend/coins/btc/synchronizer"
Expand Down Expand Up @@ -683,11 +682,6 @@ func (account *Account) CanVerifyAddresses() (bool, bool, error) {
return account.Keystores().CanVerifyAddresses(account.signingConfiguration, account.Coin())
}

// ConvertToLegacyAddress implements accounts.Interface.
func (account *Account) ConvertToLegacyAddress(string) (btcutil.Address, error) {
panic("not used")
}

// Keystores implements accounts.Interface.
func (account *Account) Keystores() *keystore.Keystores {
return account.keystores
Expand Down

0 comments on commit 982e154

Please sign in to comment.