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

Using rpcclient GetNewAddress shows -32600: Invalid request #1843

Closed
leoyzx opened this issue Apr 13, 2022 · 12 comments
Closed

Using rpcclient GetNewAddress shows -32600: Invalid request #1843

leoyzx opened this issue Apr 13, 2022 · 12 comments

Comments

@leoyzx
Copy link

leoyzx commented Apr 13, 2022

my version of btcd/btcwallet:
btcd version 0.22.0-beta
btcwallet version 0.7.0-alpha
After runningbtcd --simnet --rpcuser=rpcuser --rpcpass=rpcpass --rpclisten=0.0.0.0:18556 --listen=0.0.0.0:18555&btcwallet --simnet --username=rpcuser --password=rpcpass the btcwallet RPC server listening on 127.0.0.1:18554
after connecting to btcw rpcserver with the config
connCfg := &rpcclient.ConnConfig{ Host: "localhost:18554", Endpoint: "ws", User: "rpcuser", Pass: "rpcpass", Params: "simnet", Certificates: certs, }
using the api address,err:=client.GetNewAddress("default","legacy") the err shows that-32600: Invalid request.
Does anyone know the possible solution of this situation?
PS: i have tried ListAccounts&GetAddressesByAccount,they can return the correct data.

@chappjc
Copy link
Contributor

chappjc commented Apr 13, 2022

You're using the rpcclient package from master, but the btcwallet from long ago.

In 061aef9, the getnewaddress RPC was given the addess type argument, but corresponding btcwallet change is not merged yet btcsuite/btcwallet#783

Just use the rpcclient package from the v0.22.0-beta tag or right before 061aef9. You should probably also update your btcwallet from 0.7.0 to latest (cli will show 0.11.0, but tag is 0.14.0)

@chappjc
Copy link
Contributor

chappjc commented Apr 13, 2022

BTW, @jcvernaleo and @Roasbeef to keep the rpcclient methods the same as before, we could modify 061aef9 so that the GetNewAddress stays with one arg (and omits the type), and we instead add a GetNewAddressType method with two...

Or the rpcclient method can be modified to have a type of "" be omitted from the request for compatibility with older apps. i.e.

func (c *Client) GetNewAddressAsync(account, addrType string) FutureGetNewAddressResult {
	aType := &addrType
	if addrType == "" {
		aType = nil
	}
	cmd := btcjson.NewGetNewAddressCmd(&account, aType)

(assuming you want rpcclient to work with older versions of the apps like in this issue, debatable)

In any case, the wallet PR btcsuite/btcwallet#783 is needed to actually request different address types.

@leoyzx
Copy link
Author

leoyzx commented Apr 14, 2022

i have update my btcwallet from 0.7.0 to 0.14.0(i didn't modify the code).
Using the new btcw server certificates&connecting to it.
In the code address,err =client.GetNewAddress("test","legacy").
err still returns -32600: Invalid request.

@leoyzx
Copy link
Author

leoyzx commented Apr 14, 2022

You're using the rpcclient package from master, but the btcwallet from long ago.

In 061aef9, the getnewaddress RPC was given the addess type argument, but corresponding btcwallet change is not merged yet btcsuite/btcwallet#783

Just use the rpcclient package from the 0.22.0-beta tag or right before 061aef9. You should probably also update your btcwallet from 0.7.0 to latest (cli will show 0.11.0, but tag is 0.14.0)

i checked the btcctl, usingbtcctl /l,it still shows getnewaddress ("account"),doesn't receive the param 'addrType', do you know in which version or any branches it can receive 'addrType'.(I don't want to use the lower version of rpcclient,cause #1519 shows that it doesn't work in simnet)

@chappjc
Copy link
Contributor

chappjc commented Apr 14, 2022

As I explained, btcwallet does not support the address type argument yet. That PR still needs to be merged. btcwallet does not yet support the address type argument.

@chappjc
Copy link
Contributor

chappjc commented Apr 14, 2022

I don't understand the relevance of #1519. The fix PR was merged long before v0.22.0-beta.

@leoyzx
Copy link
Author

leoyzx commented Apr 16, 2022

ok, i understand your meaning, but face another problem now,when i compile my code it showsbtcsuite\btcd@v0.22.0-beta.0.20220111032746-97732e52810c\txscript\sign.go:296:25: cannot use pubKey (variable of type *secp256k1.PublicKey) as type *btcec.PublicKey in argument to pSig.Verify i will do as your suggestion after i solve it.

@chappjc
Copy link
Contributor

chappjc commented Apr 16, 2022

v0.22.0-beta.0.20220111032746-97732e52810c is past v0.22.0-beta. You need to edit your app's go.mod and have the btcd require line specify exactly v0.22.0-beta (Jun 8, 2021)

@leoyzx
Copy link
Author

leoyzx commented Apr 17, 2022

Sincerely appreciate your help.
i download the source code of v0.22.0-beta(Jun 8, 2021) and replace it in both my goroot&gopath, but now when i compile my code in goland it still shows usedbtcd@v0.22.0-beta.0.20220111032746-97732e52810c, i don't know how to solve it.Each time i rungo mod tidy&go mod download, go mod downloads the version of v0.22.0-beta.0.20220111032746-97732e52810c,if I used replace btcd from v0.22.0-beta.0.20220111032746-97732e52810c to v0.22.0-beta, it shows
image

my go.mod
image

i just want to use v0.22.0-beta directly, but since i use v0.21.0 last time and want to use v0.22.0 again it doesn't work, or can you tell me how to delete all the package and build a whole new project again, i tried it several times but failed.

@chappjc
Copy link
Contributor

chappjc commented Apr 17, 2022

Is that your entire go.mod file? You have no require statement in go.mod for the btcd module. No direct requires at all. Is your code using rpcclient or something indirectly?

Also, you should not need a replace, but that's not the correct syntax for a replace directive. The left side should not specify a version.

Edit your go.mod in a text editor, and then do go mod tidy

@leoyzx

This comment was marked as resolved.

@leoyzx
Copy link
Author

leoyzx commented Apr 18, 2022

it seems that i have solved it now, i'm not sure, i will close this comment as i confirm it was done. Really thanks for your help. : )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants