我遇到了现金状况问题。基本上,我有一个节点,该节点自行发行货币,并且无法访问现有状态以用于付款/任何操作。假设这个状态是5美元,如果我再发行10美元,则rpcOps和servicehub getCashBalances
都会说我有15美元。但是,任何尝试使用10美元以上的现金流量都会告诉我我的余额不足。
我已经为该节点设置了api端点,甚至可以退出现金,但是这将表明我退出的人数超过了我。当我使用QueryCriteria.VaultQueryCriteria(Vault.StateStatus.UNCONSUMED)
查询保管库时,我可以看到状态存在,并且似乎没有任何东西可以将不可访问状态与任何后续可访问状态区分开。
我在这里可以俯瞰什么吗?发行人是相同的,所有者是经过哈希处理的,但也应该相同。
fun selfIssueTime(@QueryParam(value = "amount") amount: Long,
@QueryParam(value = "currency") currency: String): Response {
// 1. Prepare issue request.
val issueAmount = Amount(amount.toLong() * 100, Currency.getInstance(currency))
val notary = rpcOps.notaryIdentities().firstOrNull() ?: throw IllegalStateException("Could not find a notary.")
val issueRef = OpaqueBytes.of(0)
val issueRequest = CashIssueFlow.IssueRequest(issueAmount, issueRef, notary)
val self = myIdentity
// 2. Start flow and wait for response.
val (status, message) = try {
val flowHandle = rpcOps.startFlowDynamic(
CashIssueFlow::class.java,
issueRequest
)
flowHandle.use { it.returnValue.getOrThrow() }
CREATED to "$issueAmount issued to $self."
} catch (e: Exception) {
BAD_REQUEST to e.message
}
// 3. Return the response.
return Response.status(status).entity(message).build()
}
答案 0 :(得分:1)
我认为这是通过更高版本的Corda Finance Jars解决的。我们使用currency
类开发了另外两个CorDapps示例,但没有遇到任何问题。例如:https://github.com/corda/samples-java/blob/master/Tokens/dollartohousetoken/workflows/src/main/java/net/corda/examples/dollartohousetoken/flows/FiatCurrencyIssueFlow.java#L39
此外,随着Corda TokenSDk的发布,Corda上的Currency实际上具有一种新的获取,转移和赎回的方式。这是通过以下方式完成的:
/* Create an instance of the fiat currency token */
TokenType token = FiatCurrency.Companion.getInstance(currency);
/* Create an instance of IssuedTokenType for the fiat currency */
IssuedTokenType issuedTokenType = new IssuedTokenType(getOurIdentity(), token);
/* Create an instance of FungibleToken for the fiat currency to be issued */
FungibleToken fungibleToken = new FungibleToken(new Amount<>(amount, issuedTokenType), recipient, null);
/* Issue the required amount of the token to the recipient */
return subFlow(new IssueTokens(ImmutableList.of(fungibleToken), ImmutableList.of(recipient)));