-
Notifications
You must be signed in to change notification settings - Fork 100
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
client/dcr: Remove GetRawTransaction. #3012
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -450,17 +450,6 @@ func (c *tRPCClient) GetRawMempool(_ context.Context, txType chainjson.GetRawMem | |
return txHashes, nil | ||
} | ||
|
||
func (c *tRPCClient) GetRawTransaction(_ context.Context, txHash *chainhash.Hash) (*dcrutil.Tx, error) { | ||
if c.rawTxErr != nil { | ||
return nil, c.rawTxErr | ||
} | ||
tx, found := c.blockchain.rawTxs[*txHash] | ||
if !found { | ||
return nil, dcrjson.NewRPCError(dcrjson.ErrRPCNoTxInfo, "no test raw tx "+txHash.String()) | ||
} | ||
return dcrutil.NewTx(tx.tx), nil | ||
} | ||
|
||
func (c *tRPCClient) GetBalanceMinConf(_ context.Context, account string, minConfirms int) (*walletjson.GetBalanceResult, error) { | ||
return c.balanceResult, c.balanceErr | ||
} | ||
|
@@ -492,6 +481,18 @@ func (c *tRPCClient) GetTransaction(_ context.Context, txHash *chainhash.Hash) ( | |
if c.walletTxFn != nil { | ||
return c.walletTxFn() | ||
} | ||
c.blockchain.mtx.RLock() | ||
defer c.blockchain.mtx.RUnlock() | ||
if rawTx, has := c.blockchain.rawTxs[*txHash]; has { | ||
b, err := rawTx.tx.Bytes() | ||
if err != nil { | ||
return nil, err | ||
} | ||
walletTx := &walletjson.GetTransactionResult{ | ||
Hex: hex.EncodeToString(b), | ||
} | ||
return walletTx, nil | ||
} | ||
return nil, dcrjson.NewRPCError(dcrjson.ErrRPCNoTxInfo, "no test transaction") | ||
} | ||
|
||
|
@@ -3200,10 +3201,6 @@ func TestFindRedemption(t *testing.T) { | |
Hex: txHex, | ||
} | ||
|
||
node.walletTxFn = func() (*walletjson.GetTransactionResult, error) { | ||
return walletTx, nil | ||
} | ||
|
||
// Add an intermediate block for good measure. | ||
node.blockchain.addRawTx(contractHeight+1, dummyTx()) | ||
|
||
|
@@ -3221,6 +3218,10 @@ func TestFindRedemption(t *testing.T) { | |
t.Fatalf("wrong secret. expected %x, got %x", secret, checkSecret) | ||
} | ||
|
||
node.walletTxFn = func() (*walletjson.GetTransactionResult, error) { | ||
return walletTx, nil | ||
} | ||
|
||
// Move the redemption to a new block and check if wallet.FindRedemption finds it. | ||
_, redeemBlock := node.blockchain.addRawTx(contractHeight+2, makeRawTx(inputs, []dex.Bytes{otherScript})) | ||
_, checkSecret, err = wallet.FindRedemption(tCtx, coinID, nil) | ||
|
@@ -4654,7 +4655,7 @@ func TestFindBond(t *testing.T) { | |
}, { | ||
name: "bad msgtx", | ||
coinID: bond.CoinID, | ||
txRes: txFn(nil, bond.SignedTx[1:]), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have not idea why I had to change this, maybe I should. |
||
txRes: txFn(nil, bond.SignedTx[100:]), | ||
wantErr: true, | ||
}, { | ||
name: "get best block error", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't
getrawtransaction
work for mempool transaction even iftxindex
is not enabled?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, for mempool transactions.
Should we leave it in with a note that it can only be used for mempool?
My reasoning is that if
GetTransaction
is good enough for rpc clients with an spv node, then it's good enough for full nodes.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to note for testing: the dcr simnet test harness node alpha has
--txindex
; node beta does not have a tx index.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
beta wallet is also an --spv wallet so I dont think we have a simnet wallet connecting to beta node