Go-Ethereum
沒有簽名者授權交易
當試圖
boundContract
通過. 我錯過了獲取簽名者的方法。我只看到了簽名者的介面,但沒有辦法得到它的實現。geth-api
@karalabe
aar
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) Caused by: java.lang.Exception: no signer to authorize the transaction with at go.Seq.throwException(Seq.java:52) at org.ethereum.geth.BoundContract.transfer(Native Method) at org.ligi.ewallet.MainActivity$onCreate$function$1.invoke(MainActivity.kt:68) at org.ligi.ewallet.MainActivity$onCreate$function$1.invoke(MainActivity.kt:27) at org.ligi.ewallet.MainActivityKt$sam$OnClickListener$af810d58.onClick(MainActivity.kt:0) at android.view.View.performClick(View.java:5697) at android.view.View$PerformClick.run(View.java:22526) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:158) at android.app.ActivityThread.main(ActivityThread.java:7225) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
當試圖在一個
boundContract
您可以創建一個使用 AccountManager 簽署交易的 Signer 實現。
這是一個假設您的 AccountManager 包含已解鎖帳戶的範例:
final AccountManager am = new AccountManager(this.getFilesDir() + "/keystore", Geth.LightScryptN, Geth.LightScryptP); Signer mySigner = new Signer() { @Override public Transaction sign(Address address, Transaction transaction) throws Exception { byte[] signature = am.sign(address, transaction.getSigHash().getBytes()); return transaction.withSignature(signature); } };
而這個使用密碼字元串代替:
final AccountManager am = new AccountManager(this.getFilesDir() + "/keystore", Geth.LightScryptN, Geth.LightScryptP); Signer mySigner = new Signer() { @Override public Transaction sign(Address address, Transaction transaction) throws Exception { byte[] signature = am.signWithPassphrase(address, "password", transaction.getSigHash().getBytes()); return transaction.withSignature(signature); } };