Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.
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
45 changes: 42 additions & 3 deletions wallet/wallet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ contract multiowned {
uint ownerIndexBit = 2**ownerIndex;
return !(pending.ownersDone & ownerIndexBit == 0);
}

// INTERNAL METHODS
Copy link

Choose a reason for hiding this comment

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

I feel the extra line was for visibility. Check line 50 above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

alright, i'll leave it in


function confirmAndCheck(bytes32 _operation) internal returns (bool) {
Expand Down Expand Up @@ -363,16 +363,55 @@ contract Wallet is multisig, multiowned, daylimit {
return true;
}
}


// Gets the number of pending transactions
function numPendingTransactions() constant returns (uint _pendingTransactionsCount) {
Copy link

Choose a reason for hiding this comment

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

I feel the extra line was for visibility. Check line 50 above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

_pendingTransactionsCount = 0;
// Use m_pendingIndex.length to get all hashes, then count how many of the
// operations are transactions, because we don't want to store hashes twice
// and this is a local call anyway
for (uint i = 0; i < m_pendingIndex.length; i++) {
Copy link

@veox veox Aug 2, 2016

Choose a reason for hiding this comment

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

m_pendingIndex.length is a dynamically-sized array. i would be an uint8 (as per the docs).

If m_pendingIndex.length > 255, this is an endless loop.

I haven't looked through all the dapp, but can it be guaranteed that this won't end in always-OOG?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is a uint

if (isPendingTransaction(i)) {
_pendingTransactionsCount++;
}
}
}

// Gets the pending operation at a specified index
// Will return a tuple [bytes32 operationHash, uint confirmationsNeeded, address toAddress, uint transactionValue, bytes data]
function getPendingTransaction(uint _index) constant returns (bytes32 _operationHash, uint _confirmationsNeeded, address _toAddress, uint _transactionValue, bytes _data) {
uint pendingTransactionsCount = 0;
// Seek through all of m_pendingIndex (used in the multiowned contract)
// But only count transactions
for (uint i = 0; i < m_pendingIndex.length; i++) {
Copy link

Choose a reason for hiding this comment

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

Same as in numPendingTransactions().

if (isPendingTransaction(i)) {
if (_index == pendingTransactionsCount) {
// Found the pending transaction, return it.
var operationHash = m_pendingIndex[i];
return (operationHash, m_pending[operationHash].yetNeeded, address(m_txs[operationHash].to), m_txs[operationHash].value, m_txs[operationHash].data);
}
pendingTransactionsCount++;
Copy link

Choose a reason for hiding this comment

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

Same as in numPendingTransactions().

}
}
}

// INTERNAL METHODS

function clearPending() internal {
uint length = m_pendingIndex.length;
for (uint i = 0; i < length; ++i)
delete m_txs[m_pendingIndex[i]];
super.clearPending();
}

// Determine if a pending operation index is a pending transaction
function isPendingTransaction(uint _index) constant internal returns (bool) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Future refactoring: Group operations on "pending transaction" into a library.

if (m_txs[m_pendingIndex[_index]].to != 0 || m_txs[m_pendingIndex[_index]].data.length != 0) {
return true;
}
return false;
}

// FIELDS

// pending transactions we have at present.
Expand Down