-
Notifications
You must be signed in to change notification settings - Fork 119
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
multi: Allow trezor ticket purchasing on testnet. #2869
Conversation
21ae598
to
b74dddb
Compare
b74dddb
to
7bff921
Compare
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.
Lots of TODO's but hopefully that's ok. This pr only means to get the ball rolling on testnet.
app/actions/TrezorActions.js
Outdated
await signTransactionAttemptTrezor(splitTx, changeIndex)(dispatch, getState); | ||
const refTxs = await walletTxToRefTx(walletService, decodedInp); | ||
|
||
for (const ticket of res.getTicketsList()) { |
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.
Even when specifying number of tickets as more, this only returns one ticket. Am I doing it wrong?
app/actions/TrezorActions.js
Outdated
// TODO: Fill this with deterministic crypto magic. | ||
const privateKeySeed = Buffer.alloc(32); | ||
privateKeySeed[31] = 1; | ||
const net = conToTrezCoinParams(chainParams.trezorCoinName); | ||
const ecp = ECPair.fromPrivateKeyBuffer(privateKeySeed, net); | ||
const votingKey = ecp.toWIF(); | ||
const votingAddr = ecp.getAddress(); |
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.
This will need to be changed but hopefully ok for now.
app/actions/TrezorActions.js
Outdated
// payVSPFee attempts to contact a vst about a ticket and pay the fee if | ||
// necessary. It will search transacitons for a suitable fee transaction before | ||
// attempting to pay if newTicket is false. | ||
async function payVSPFee(host, txHex, votingKey, accountNum, newTicket, dispatch, getState) { |
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.
This will need to be callable from somewhere else eventually. Will need to know the host though, and I'm not where to save that info. I suppose the user can choose per ticket where they think it came from if they still need to pay the fee for some reason. This will require ui changes which I am not comfortable doing in this pr...
// findFeeTx searches unmined and recent transactions for a tx that pays to | ||
// FeeAddr of the amount feeAmt. It stops searching below a resonable depth for | ||
// a ticket. | ||
async function findFeeTx(feeAddr, feeAmt, dispatch, getState) { |
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.
This looks to work well, but if there's a better way please tell me.
This pr should be used with trezor core firmware trezor/trezor-firmware#1249 |
Two more gotchas I forgot to mention:
These are both problems that must be fixed at some point. |
Another "insufficient funds" issue has been popping up. No idea of the cause right now, but it can be temporary solved by sending a normal transaction to yourself. |
26acb57
to
da2c01c
Compare
app/actions/TrezorActions.js
Outdated
for (let i = 0; i < decodedInp.outputs.length; i++) { | ||
changeIndexes.push(i); | ||
}; | ||
await signTransactionAttemptTrezor(splitTx, changeIndexes)(dispatch, getState); |
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.
Cancelling this on trezor doesn't stop the purchase but it should.
app/actions/TrezorActions.js
Outdated
// payVSPFee attempts to contact a vst about a ticket and pay the fee if | ||
// necessary. It will search transacitons for a suitable fee transaction before | ||
// attempting to pay if newTicket is false. | ||
async function payVSPFee(host, txHex, votingKey, accountNum, newTicket, dispatch, getState) { |
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.
Should probably move these functions to helpers.
const { | ||
grpc: { votingService } | ||
} = getState(); | ||
const voteChoicesRes = await wallet.getVoteChoices(votingService); |
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.
I assume this is fetching the default.
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.
Please just drop the binary files and I'll merge this.
Commented on the wrong PR, sorry.
da2c01c
to
f2c984d
Compare
9a01a53
to
4029e18
Compare
4029e18
to
e57246d
Compare
675f7e5
to
bf1b90b
Compare
Should I be worried about these test failures? |
Have you rebased to latest master yet? That might fix it. |
Something is off with the CI, looking into it... |
Yes. I also tried the tests locally, on master, and had some fail. Not sure if there is something to do besides Will do another rebase though, as there are some conflicts now. |
Latest master might resolve the CI troubles. |
bf1b90b
to
4ca3f2f
Compare
This looks like an expected test failure, will fix. |
c3f2f8c
to
2609d15
Compare
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.
Purchasing worked on the latest stable version of the model T emulator (2.4.0). Woop! 🎉
Getting an error like
suddenly. looking into it... f448243 did something It looks like tweaking some nginx fields on the server has fixed it. |
13c33f1
to
cee2ef2
Compare
cee2ef2
to
19b92cb
Compare
19b92cb
to
636b1df
Compare
74fa441
to
de3c3ad
Compare
The values added to the header seem to be necessary for CORS and the diff was supplied by @matheusd |
bf951d2
to
014e931
Compare
014e931
to
80b33e4
Compare
ce81796
to
e13d88a
Compare
e13d88a
to
7c5eb84
Compare
Add purchaseTicketsV3 which purchases tickets using a watching only trezor wallet from a vsp with api v3. Errors if not on testnet. Add separate payVSPFee function that will pay a tickets fee if not already paid, and throws if already paid. Correct purchase ticket button for watching only wallets. It no longer asks for a password. Connect purchasing through trezor when isTrezor is true. Add vsp v3 endpoints "feeaddress" and "payfee" to allowed external requests. Change wallet/control.js to not require an unlocked wallet when signTx is false. Add headers to OPTIONS externalRequest. These are required by CORS when making POST requests.
Seeing a syncing issue after rebase. Looking into it... Silly me, just needed to use a new dcrd. Looks fine. There's some js errors I'm not sure I was seeing before, doesn't seem to affect the purchase, but going to put them here. Need to fix these?:
|
This seems to be related to decrediton/app/main_dev/externalRequests.js Lines 87 to 89 in 208195c
Without this, the communication to trezor does not work though. I think this warning doesn't need to fix, but probably @matheusd could correct me.
I could not reproduce these warnings.
I fixed this in #3784. Thanks for the report. |
Going to be closing this and the other PRs that have sat for quite some time. If you would like to re-open and start to move this PR towards completion, feel free to contact me and I can either reopen this or you may submit another. |
Fix updating firmware with model T by sending binary rather than hex.
In signTransactionAttemptTrezor give spending from stake scripts
inputs specific script types "SPENDSSRTX" and "SPENDSSGEN" rather than
"SPENDADDRESS" as trezor needs this information to process the scripts.
Add purchaseTicketsV3 which purchases tickets using a watching only
trezor wallet from a vsp with api v3. Errors if not on testnet.
Add separate payVSPFee function that will pay a tickets fee if not
already paid, and throws if already paid.
Correct purchase ticket button for watching only wallets. It no longer
asks for a password. Connect purchasing through trezor when isTrezor is
true.
Add vsp v3 endpoints "feeaddress" and "payfee" to allowed external
requests.
Change wallet/control.js to not require an unlocked wallet when signTx
is false.