Skip to content

Conversation

luke-jr
Copy link
Member

@luke-jr luke-jr commented Sep 22, 2012

Bugfix: Avoid trying to parse outputs that aren't relevant to CWalletTx::GetAmounts

  • This fixes a warning when an output we aren't concerned with can't be parsed.

Bugfix: Supress "address" key in transaction details, when the destination isn't recognized

  • Previously, it would pass corrupt/random through base58.

Fixes #779 and #1848.

@luke-jr
Copy link
Member Author

luke-jr commented Sep 22, 2012

Needs to be addressed: when the address is unavailable, should the "address" key be absent, null, or something else? Current code here does the "absent" option.

@BitcoinPullTester
Copy link

Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/1a5eb4636d038fdf623924c0d236c915ddcb9bdb for binaries and test log.

static void MaybePushAddress(Object & entry, const CTxDestination &dest)
{
CBitcoinAddress addr;
if (!addr.Set(dest))
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: if (addr.Set(dest)) entry.push_back() would be clearer logic.

@gavinandresen
Copy link
Contributor

This is high risk for breaking existing applications; in addition to careful code review I would really like there to be a test plan, or, even better, until tests that fully exercise all of the code paths in CWalletTx::GetAmounts.

@sipa
Copy link
Member

sipa commented Oct 20, 2012

I hope no application depends on the random data being produced, so I think this should be treated as a bugfix.

if (nDebit > 0)
listSent.push_back(make_pair(address, txout.nValue));

if (pwallet->IsMine(txout))
if (fIsMine)
Copy link
Member

Choose a reason for hiding this comment

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

This if is redundant, if fIsMine is false, we already bailed out.

Copy link
Member Author

Choose a reason for hiding this comment

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

It shouldn't be, thanks for noticing the bug :)

@luke-jr
Copy link
Member Author

luke-jr commented Nov 15, 2012

Fixed the bug @sipa found, and commented CWalletTx::GetAmounts better so the flow is more understandable.

I'll get to tests later.

@BitcoinPullTester
Copy link

Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/d2233dbcf4bf520370ffbd59b1a42718e4f68d27 for binaries and test log.

@sipa
Copy link
Member

sipa commented Nov 27, 2012

Looks like just code movement to me (except the address = CNoDestination()), ACK. I haven't tested though.

@gavinandresen
Copy link
Contributor

Needs a test plan; see https://github.com/bitcoin/QA for a test plan skeleton.

luke-jr added 2 commits July 17, 2013 03:03
…Tx::GetAmounts

This fixes a warning when an output we aren't concerned with can't be parsed.
…ation isn't recognized

Previously, it would pass corrupt/random through base58.
@luke-jr
Copy link
Member Author

luke-jr commented Jul 17, 2013

Fixed @gavinandresen 's nit and a bug I thought @jgarzik reported with it (though it seems to have vanished here...), and rebased.

I am not sure how to create a test plan for these particular fixes. I believe the conditions to trigger the bug can only occur when some other (eg, newer) client has accepted wallet transactions that the currently running version does not understand.

@BitcoinPullTester
Copy link

Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/cc6cfab38fcdd4ec3e4784e01c4407a129289f77 for binaries and test log.
This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/
Contact BlueMatt on freenode if something looks broken.

@Diapolo
Copy link

Diapolo commented Sep 19, 2013

Is this the last version and rebased to current master? If yes I'm going to try if this fixes my problem in #3006.

@Diapolo
Copy link

Diapolo commented Oct 7, 2013

@luke-jr Can you please rebase this or is it mergable?

CTxDestination address;
vector<unsigned char> vchPubKey;
if (!ExtractDestination(txout.scriptPubKey, address))
{
printf("CWalletTx::GetAmounts: Unknown transaction type found, txid %s\n",
Copy link

Choose a reason for hiding this comment

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

This creates a merge-conflict ^^.

@Diapolo
Copy link

Diapolo commented Oct 10, 2013

@luke-jr Are you still around here or don't you participate anymore?

@gavinandresen
Copy link
Contributor

This is on my list of old pulls to get resolved.

After reviewing the code again, I'm planning on:

  1. Tweaking my handy-dandy payment request generator code so I have an easy way of generating transactions that pay to standard-but-not-expressible-as-an-address transactions (I'll teach it to take hex full public keys OR addresses and have it do-the-right-thing; I've been meaning to do that for more payment protocol testing anyway).

  2. Test this code. I waffle on whether it would be better to output "address" : null instead of leaving out "address" for outputs that cannot be expressed as an address. Certainly the current behavior is wrong...

@gavinandresen gavinandresen merged commit cc6cfab into bitcoin:master Oct 22, 2013
@gavinandresen
Copy link
Contributor

Pulled (after testing using https://bitcoincore.org/~gavin/createpaymentrequest.php and fixing the trivial merge conflict).

@luke-jr luke-jr deleted the bugfix_unknownoutputs branch October 19, 2014 22:19
KolbyML pushed a commit to KolbyML/bitcoin that referenced this pull request Dec 5, 2020
…oins selection flow removed.

5935497 Making CPivStake immutable. (furszy)
af1bf37 wallet::CreateCoinStake set missing pindeFrom in stakeInput. (furszy)
f935801 wallet: Implement a slightly different StakeableCoins, initializing and returning CStakeableOutput. (furszy)
bbc7d77 wallet: CheckTXAvailability returning the block index if is requested. (furszy)
d8dbf49 CPivStake: Introducing SetIndexFrom method. (furszy)
9a5c090 wallet: Introducing StakeableOutput class. (furszy)
f9edbd5 wallet: AvailableCoins using the new CheckOutputAvailability method. (furszy)
7212f79 Wallet: new CheckOutputAvailability method implemented.  Decoupling and cleaning the output availability checks from AvailableCoins (furszy)
1128da0 CPivStake: make pindexFrom member const (furszy)
3c27c3d CPivStake: removing unreachable code from GetIndexFrom(). (furszy)
a5c759c CPivStake: store only the needed CTxOut and COutPoint data and not the entire transaction. (furszy)
0cd01a4 CStakeInput: remove unused GetTxFrom method. (furszy)

Pull request description:

  Essentially, this work is removing an unneeded `GetTransaction` call from `CPivStake::GetIndexFrom` for every stakeable output during each cycle of the staking process.
  As `GetTransaction` is a direct access to disk (txindex), this means faster staking.

  Future work, the methods `StakeableCoins` and `AvailableCoins` can be abstracted even more. They are sharing almost the same code with an specific distinction that makes this change possible without introducing an extra blockIndex set into `AvailableCoins`.

ACKs for top commit:
  random-zebra:
    But these are just styling changes, so if you're not happy making them, I'm fine with the PR as is. Tested ACK 5935497
  Fuzzbawls:
    ACK 5935497

Tree-SHA512: cc34443c16f678c51529a5e3cf682ab5c8edadb9c0c307130a93f9f5d1cc0707121cbb278c86197d595c679e479b7850c21180334a196d7e72d064feac267525
@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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CScript::ExtractAddress returns garbage for unrecognised transaction
5 participants