注入签名操作失败,出现Unrevealed_Key错误
1 个回答
- 投票数
-
- 2019-03-03
在从帐户发送交易之前,必须对该帐户进行"公开"操作.该帐户似乎已被激活,但尚未透露.为了完成这项工作,我们需要在操作列表中包括显示操作:
sotez.rpc.getHead() .then(head => { const operation = { branch: head.hash, contents: [ { kind: 'reveal', fee: '1269', counter: '31204', public_key: keys.pk, source: from, gas_limit: '10000', storage_limit: '0', }, { kind: 'transaction', source: from, fee: '50000', counter: '31205', gas_limit: '10200', storage_limit: '0', amount: amount, destination: to, } ], } ... })
揭露帐户后,以后便无需将其包括在操作中.
SendOperation答案:
const send = (from, to, amount, keys) => { const operation = { kind: 'transaction', source: from, fee: '50000', gas_limit: '10200', storage_limit: '0', amount: `${amount}`, destination: to, }; rpc.sendOperation({ from, operation, keys }) .then(result => console.log(result)); };
Before sending transactions from an account, a 'reveal' operation must be made for the account. It looks like this account may have been activated, but not yet revealed. To make this work we would need to include the reveal operation in the list of operations:
sotez.rpc.getHead() .then(head => { const operation = { branch: head.hash, contents: [ { kind: 'reveal', fee: '1269', counter: '31204', public_key: keys.pk, source: from, gas_limit: '10000', storage_limit: '0', }, { kind: 'transaction', source: from, fee: '50000', counter: '31205', gas_limit: '10200', storage_limit: '0', amount: amount, destination: to, } ], } ... })
After the account has been revealed, the reveal is not needed to be included in the operations thereafter.
SendOperation Answer:
const send = (from, to, amount, keys) => { const operation = { kind: 'transaction', source: from, fee: '50000', gas_limit: '10200', storage_limit: '0', amount: `${amount}`, destination: to, }; rpc.sendOperation({ from, operation, keys }) .then(result => console.log(result)); };
-
谢谢!我添加了显示操作来编辑我的问题.我现在运行它时,它挂起,没有结果或错误.Thanks! I edited my question with the reveal operation added. When I run it now, it just hangs with no result or error.
- 0
- 2019-03-03
- Michael Rodriguez
-
没关系,这是因为计数器增加了.我注意到您的修改,并通过我的方法对其进行了修复.不过,奇怪的是,现在我收到此错误:{" kind":"permanent","id":"proto.003-PsddFKi3.operation.invalid_signature"}Ah nevermind, it was because of the counter increment. I noticed your edit and fixed it in my method. Oddly, though, now I'm getting this error: {"kind":"permanent","id":"proto.003-PsddFKi3.operation.invalid_signature"}
- 0
- 2019-03-03
- Michael Rodriguez
-
您是否使用rpc.sendOperation尝试了相同的传输?sendOperation应该处理事务是否需要显示以及所有用于操作的计数器.Have you tried the same transfer using rpc.sendOperation? sendOperation should handle whether the transaction needs a reveal and all the counters for the operations.
- 0
- 2019-03-04
- AKISH
-
我首先尝试了该方法,但是它没有响应或错误就挂了.然后我以为这样做会更安全,因为我不希望sendOperation将keys对象作为参数,而我希望在不托管自己的节点的情况下构建此应用.但是,现在我已经按照这种方式进行了编写,所以我意识到我仍然在操作中仍然发送pk和sk ...不好!但是要回答您的问题,我确实尝试过了,但是结果还是没问题.I tried that method first, and it just hung with no response or error. Then I thought I would do it this way, thinking it would be more secure, as I didn't like that the sendOperation takes the keys object as a parameter, and I was hoping to build this app without hosting my own node. But now that I've gone through and written it this way, I realized that I am still sending the pk and sk anyhow within the operation... so that's not good! But to answer your question, I did try that, and it just hung.
- 0
- 2019-03-04
- Michael Rodriguez
-
我将不得不查看导致响应挂起的原因,我想我尝试了较早的示例之一,并注意到在sotez中没有正确处理金额键(应该被强制转换为字符串).如果您尝试sendOperation并将金额设置为字符串,并添加可能有效的费用,gas_limit和storage_limit.I'll have to see what is making the responses hang, bit I think I tried one of your examples from earlier and noticed that the amount key wasn't being handled correctly in sotez (was supposed to be coerced into a string). If you try your sendOperation and make the amount a string, as well as adding a fee, gas_limit, and storage_limit that may work.
- 1
- 2019-03-04
- AKISH
-
感谢您的帮助,我非常感谢!我已经更新问题以使用sendOperation.这次没有挂起,返回的是" TypeError:无法读取未定义的属性'种类'"Thanks for your help, I really appreciate it! I've updated my question to use sendOperation. This time it's not hanging, it's returning "TypeError: Cannot read property 'kind' of undefined"
- 0
- 2019-03-04
- Michael Rodriguez
-
我只记得sendOperation接受一个params对象,该对象包含from,操作和键.我已经更新了我的问题,它可以正常工作!I just remembered that sendOperation takes a params object containing the from, the operation, and the keys. I've updated my question, and it worked!
- 1
- 2019-03-04
- Michael Rodriguez
我今天学到了很多东西,如果没有这个StackExchange,我不可能走那么快.我几乎已经完成了发送工作,但我无法终生弄清楚为什么在注入时失败并显示" unrevealed_key"错误.
我知道我应该解码伪造的交易并重新验证值,以确保远程节点没有尝试更改我的交易,但是为了简单起见,我从这篇文章中删除了这一点.
返回:
[{"kind":"branch","id":"proto.003-PsddFKi3.contract.unrevealed_key","contract":"tz1htPf3VPXrHBTX1E7y3tBteib6hA9Teosj"}]
编辑: 因此,我需要先显示此帐户.我修改了send方法,以检查该帐户之前是否已显示过,如果没有,则将该显示添加到操作列表中.现在,我得到
{"kind":"permanent","id":"proto.003-PsddFKi3.operation.invalid_signature"}
.Edit2: 使用sendOperation可以正常工作