Skip to content

Conversation

@achow101
Copy link
Member

Add a new optional parameter to the generate call to mine to a specific address even if it doesn't exist in the wallet.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe use "address" instead of "base58 encoded address" (it would even be wrong because it's a base58 check encoded ripemd hash".

@jonasschnelli
Copy link
Contributor

Nice!
utACK.

@sipa
Copy link
Member

sipa commented Mar 12, 2016

I like the concept, but perhaps we can separate that out to a different RPC (which then can function without wallet support)?

Also, the change in arguments to generate conflicts with #7663.

@achow101
Copy link
Member Author

@sipa How about moving it to a new rpc generatetoaddress?

Done, but there is code duplication since most of it is copied from the generate rpc. I left it duplicated so that it doesn't conflict with #7663.

@luke-jr
Copy link
Member

luke-jr commented Mar 12, 2016

This seems unnecessary. Why not just move GBT->block code from getblocktemplate_proposals.py to blocktools?

@achow101 achow101 changed the title [RPC] Allow mining to a specific address [RPC] Add generatetoaddress rpc to mine to an address Mar 12, 2016
@achow101
Copy link
Member Author

This seems unnecessary.

Why?

Why not just move GBT->block code from getblocktemplate_proposals.py to blocktools?

Not sure what you mean by this.

@laanwj
Copy link
Member

laanwj commented Mar 14, 2016

Concept ACK
Needs rebase after #7507,#7663

I like the concept, but perhaps we can separate that out to a different RPC (which then can function without wallet support)?

Sounds like a good idea to me. Mining without wallet support would be awesome for some tests.

@achow101 achow101 force-pushed the generate-to-addr branch 2 times, most recently from 0115c8f to 0422b5c Compare March 14, 2016 19:42
@achow101
Copy link
Member Author

Rebased

@maflcko
Copy link
Member

maflcko commented Mar 14, 2016

I'd prefer to have rpc tests as part of this pull.

@achow101
Copy link
Member Author

@MarcoFalke Where would be the best place to put such tests?

@maflcko
Copy link
Member

maflcko commented Mar 14, 2016

@achow101 You can either start from scratch (c.f. https://github.com/bitcoin/bitcoin/blob/48f39058315c908c360acb596923cbc090119480/qa/rpc-tests/disablewallet.py) or extend an existing python script in this folder.

@sipa
Copy link
Member

sipa commented Mar 14, 2016

One of the primary use cases for this, I think, would be to have RPC tests where you get an address from one node, and let another node mine directly to it, without the need to generate 100 blocks in between before you can transfer.

@achow101
Copy link
Member Author

I added rpc tests, both with and without wallets.

The wallet RPC Test mines Bitcoin to another node's address and checks that that node has received the Bitcoin.

The RPC test without the wallet mines Bitcoin to an arbitrary address and checks that it works. It then mines to an arbitrary invalid address and checks that that fails.

Copy link
Member

Choose a reason for hiding this comment

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

Nit:

assert("Invalid or non-wallet transaction id" not in errorString)

Copy link
Member

Choose a reason for hiding this comment

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

Actually, you can remove the whole except block?

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, you can remove the whole except block?

Why?

Copy link
Member

Choose a reason for hiding this comment

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

The error string is always empty, so it's dead code? (Correct me if I am wrong)

Copy link
Member Author

Choose a reason for hiding this comment

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

Uh, I don't think so. There is an error from gettransaction and the error string was defined earlier.

Anyways, this should work, right?

except JSONRPCException,e:
            assert("Invalid or non-wallet transaction id" not in e.error['message'])

@achow101
Copy link
Member Author

addressed nits

@laanwj
Copy link
Member

laanwj commented Mar 15, 2016

Random Q: Should this also be able to take an arbitrary scriptPubKey?

One of the primary use cases for this, I think, would be to have RPC tests where you get an address from one node, and let another node mine directly to it,

Also eventually we want to have at least part of the RPC tests usable without wallet.

@achow101
Copy link
Member Author

Random Q: Should this also be able to take an arbitrary scriptPubKey?

Do you think that it should?

@laanwj
Copy link
Member

laanwj commented Mar 16, 2016

Do you think that it should?

I don't deeply care myself. Just a question that came up with me, usually the discussion of custom scripts comes up immediately after allowing arbitrary addresses, as addresses map to a only a subset of the possible output scripts.

So to be clear, I'm ok with just leaving it like this.

@achow101
Copy link
Member Author

OK, I'll just leave it as is.

@sipa
Copy link
Member

sipa commented Mar 17, 2016 via email

@laanwj
Copy link
Member

laanwj commented Mar 21, 2016

Needs rebase.

Creates the generatetoaddress rpc which is virtually identical to the generate rpc except that it takes an argument for the address to mine to. It does not rely on wallet functionality.

The mining code shared by generate and generatetoaddress has been moved to another method to reduce duplication.
@achow101
Copy link
Member Author

rebased

Copy link
Member

Choose a reason for hiding this comment

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

Please remove this line. The variable is unused and I'd prefer not to use it ever again: see 3b4324b#diff-dafb9035fa41af011fcf87041198a05aL309

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

Adds two RPC tests for the generatetoaddress RPC, one in the wallet, and one when the wallet is disabled.

The wallet RPC Test mines Bitcoin to another node's address and checks that that node has received the Bitcoin.

The RPC test without the wallet mines Bitcoin to an arbitrary address and checks that it works. It then mines to an arbitrary invalid address and checks that that fails.
@laanwj laanwj merged commit d5c5c71 into bitcoin:master Mar 23, 2016
laanwj added a commit that referenced this pull request Mar 23, 2016
d5c5c71 RPC tests for generatetoaddress (Andrew C)
fe00ca7 Create generatetoaddress rpc (Andrew C)
@laanwj
Copy link
Member

laanwj commented Mar 23, 2016

ACK fe00ca7

@laanwj laanwj mentioned this pull request Mar 23, 2016
16 tasks
@achow101 achow101 deleted the generate-to-addr branch October 29, 2016 03:34
codablock pushed a commit to codablock/dash that referenced this pull request Dec 19, 2017
…ress

d5c5c71 RPC tests for generatetoaddress (Andrew C)
fe00ca7 Create generatetoaddress rpc (Andrew C)
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants