Corda - 确定哪个参与者发起交易

Corda - Determining Which Participant Initiated a Transaction

我一直在研究一些想法来确定 Corda 中交易的发起者。很难证明,因为交易可以由一个(证明微不足道)或多个(难以证明)方签署。

但是我现在想知道交易本身是否有一些固有的东西可以用来简单地确定谁发起了交易。

当创建需要多个签名的交易时,我们调用CollectSignaturesFlow获取对方签名,但是如果我们在自己签署交易之前这样做,我们会得到以下异常:

The Initiator of CollectSignaturesFlow must have signed the transaction.

因此我可以假设交易中的第一个签名 必须 有一些来自发起者。假设 SignedTransaction.sigs[0] 是交易发起人是否安全?

脚注1:上面抛出异常的代码是这样实现的:

require(partiallySignedTx.sigs.any { it.by in myKeys }) {
    "The Initiator of CollectSignaturesFlow must have signed the transaction."
}

这表明应用于交易的一个(或更多)签名将属于发起者。

脚注 2: 事务存储 (serialization/deserialization) 是否会对 sigs 列表的排序产生任何影响? - 如果它的顺序不是确定性的,那么我们不能依赖 sigs[0] 作为发起者。

给 r3 的朋友打电话,来自 Alex Koller

I looked at the question and it's not very clear to me what is Matthew trying to achieve. AFAIK corda doesn't record who initiated a transaction and trying to devise that from the order of the signatures on the tx is probably prone to error now or in the future. A possibility would be to look at the notary and see who requested the notarisation. But that may be suitable in minority of use cases. If the holder of the tx should need to know who initiated it then it may have to be recorded in one of the states. But you obviously cannot prove the correctness of the value in the state from the tx contracts, so it would have to be atested to by the other signers on the tx (in the collect signature responding flow, before the counterparties sign). I think we would need to know more about what he's doing to be able to advise. He should get in touch with Professional Services.