验证生成的交易时出错。块密码

时间:2018-09-18 14:44:59

标签: java transactions bitcoin blockcypher

我正在使用https://github.com/blockcypher/java-client

处的blockcypher api

在尝试发送事务时出现异常:

return [ action.show]

这是日志:

    IntermediaryTransaction transaction = context.getTransactionService().
            newTransaction(
                    new ArrayList<>(Arrays.asList("mntg5ArRYYm9PirCaJYNxvHoMKbe2B4Q1b")),
                    new ArrayList<>(Arrays.asList("mzF8NP6rHYG9ehVPYSJBFygu6LSYVqZLZg")), 30000);

    String privateKey = "9acdde15b65eae424f06fd5b5e20572b20c38a25c7daf5b3244508940887dc68";
    SignUtils.signWithHexKeyWithPubKey(transaction, privateKey);

    context.getTransactionService().sendTransaction(transaction);

我正在使用比特币测试网。

1 个答案:

答案 0 :(得分:0)

我找到了解决方案。您必须添加一个公钥到IntermediaryTransaction,然后将仅方法signWithHexKeyNoPubKey (wtf?)与HEX格式的privateKey一起使用。其他变体不起作用。我不知道为什么它起作用,但是它起作用。这是正确的工作代码:

{{1}}