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

Add bitcoincash prefix to additional rpc commands #54

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
14 changes: 7 additions & 7 deletions rpc/legacyrpc/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ func addMultiSigAddress(icmd interface{}, w *wallet.Wallet) (interface{}, error)
return nil, err
}

return p2shAddr.EncodeAddress(), nil
return w.ChainParams().CashAddressPrefix + ":" + p2shAddr.EncodeAddress(), nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: Maybe we want EncodeAddressWithPrefix()? Seems we are duplicating this code a lot...

}

// createMultiSig handles an createmultisig request by returning a
Expand Down Expand Up @@ -576,7 +576,7 @@ func getAccountAddress(icmd interface{}, w *wallet.Wallet) (interface{}, error)
return nil, err
}

return addr.EncodeAddress(), err
return w.ChainParams().CashAddressPrefix + ":" + addr.EncodeAddress(), err
}

// getUnconfirmedBalance handles a getunconfirmedbalance extension request
Expand Down Expand Up @@ -734,7 +734,7 @@ func getRawChangeAddress(icmd interface{}, w *wallet.Wallet) (interface{}, error
}

// Return the new payment address string.
return addr.EncodeAddress(), nil
return w.ChainParams().CashAddressPrefix + ":" + addr.EncodeAddress(), nil
}

// getReceivedByAccount handles a getreceivedbyaccount request by returning
Expand Down Expand Up @@ -892,7 +892,7 @@ func getTransaction(icmd interface{}, w *wallet.Wallet) (interface{}, error) {
details.MsgTx.TxOut[cred.Index].PkScript, w.ChainParams())
if err == nil && len(addrs) == 1 {
addr := addrs[0]
address = addr.EncodeAddress()
address = w.ChainParams().CashAddressPrefix + ":" + addr.EncodeAddress()
account, err := w.AccountOfAddress(addr)
if err == nil {
name, err := w.AccountName(waddrmgr.KeyScopeBIP0044, account)
Expand Down Expand Up @@ -1152,7 +1152,7 @@ func listReceivedByAddress(icmd interface{}, w *wallet.Wallet) (interface{}, err
continue
}
for _, addr := range addrs {
addrStr := addr.EncodeAddress()
addrStr := w.ChainParams().CashAddressPrefix + ":" + addr.EncodeAddress()
addrData, ok := allAddrData[addrStr]
if ok {
addrData.amount += cred.Amount
Expand Down Expand Up @@ -1694,7 +1694,7 @@ func signRawTransaction(icmd interface{}, w *wallet.Wallet, chainClient *chain.R
if err != nil {
return nil, DeserializationError{err}
}
keys[addr.EncodeAddress()] = wif
keys[w.ChainParams().CashAddressPrefix+":"+addr.EncodeAddress()] = wif
}
}

Expand Down Expand Up @@ -1772,7 +1772,7 @@ func validateAddress(icmd interface{}, w *wallet.Wallet) (interface{}, error) {
// by checking the type of "addr", however, the reference
// implementation only puts that information if the script is
// "ismine", and we follow that behaviour.
result.Address = addr.EncodeAddress()
result.Address = w.ChainParams().CashAddressPrefix + ":" + addr.EncodeAddress()
result.IsValid = true

ainfo, err := w.AddressInfo(addr)
Expand Down