mirror of
https://github.com/corda/corda.git
synced 2025-06-23 17:53:31 +00:00
Minor: rename some fields in Command to be consistent with AuthenticatedObject, just to simplify the next refactor
This commit is contained in:
@ -12,8 +12,8 @@ import java.io.FileNotFoundException
|
||||
fun WireTransaction.toLedgerTransaction(identityService: IdentityService,
|
||||
attachmentStorage: AttachmentStorage): LedgerTransaction {
|
||||
val authenticatedArgs = commands.map {
|
||||
val institutions = it.pubkeys.mapNotNull { pk -> identityService.partyFromKey(pk) }
|
||||
AuthenticatedObject(it.pubkeys, institutions, it.data)
|
||||
val institutions = it.signers.mapNotNull { pk -> identityService.partyFromKey(pk) }
|
||||
AuthenticatedObject(it.signers, institutions, it.value)
|
||||
}
|
||||
val attachments = attachments.map {
|
||||
attachmentStorage.openAttachment(it) ?: throw FileNotFoundException(it.toString())
|
||||
|
@ -98,8 +98,8 @@ object NodeInterestRates {
|
||||
fun sign(wtx: WireTransaction): DigitalSignature.LegallyIdentifiable {
|
||||
// Extract the fix commands marked as being signable by us.
|
||||
val fixes: List<Fix> = wtx.commands.
|
||||
filter { identity.owningKey in it.pubkeys && it.data is Fix }.
|
||||
map { it.data as Fix }
|
||||
filter { identity.owningKey in it.signers && it.value is Fix }.
|
||||
map { it.value as Fix }
|
||||
|
||||
// Reject this signing attempt if there are no commands of the right kind.
|
||||
if (fixes.isEmpty())
|
||||
|
@ -56,12 +56,12 @@ class NodeTimestamperService(net: MessagingService,
|
||||
// except the relevant command, and a future privacy upgrade should ensure we only get a torn-off command
|
||||
// rather than the full transaction.
|
||||
val tx = req.tx.deserialize()
|
||||
val cmd = tx.commands.filter { it.data is TimestampCommand }.singleOrNull()
|
||||
val cmd = tx.commands.filter { it.value is TimestampCommand }.singleOrNull()
|
||||
if (cmd == null)
|
||||
throw TimestampingError.RequiresExactlyOneCommand()
|
||||
if (!cmd.pubkeys.contains(identity.owningKey))
|
||||
if (!cmd.signers.contains(identity.owningKey))
|
||||
throw TimestampingError.NotForMe()
|
||||
val tsCommand = cmd.data as TimestampCommand
|
||||
val tsCommand = cmd.value as TimestampCommand
|
||||
|
||||
val before = tsCommand.before
|
||||
val after = tsCommand.after
|
||||
|
@ -106,8 +106,8 @@ class CashTests {
|
||||
assertEquals(100.DOLLARS, s.amount)
|
||||
assertEquals(MINI_CORP, s.deposit.party)
|
||||
assertEquals(DUMMY_PUBKEY_1, s.owner)
|
||||
assertTrue(ptx.commands()[0].data is Cash.Commands.Issue)
|
||||
assertEquals(MINI_CORP_PUBKEY, ptx.commands()[0].pubkeys[0])
|
||||
assertTrue(ptx.commands()[0].value is Cash.Commands.Issue)
|
||||
assertEquals(MINI_CORP_PUBKEY, ptx.commands()[0].signers[0])
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -318,7 +318,7 @@ class CashTests {
|
||||
val wtx = makeSpend(100.DOLLARS, THEIR_PUBKEY_1)
|
||||
assertEquals(WALLET[0].ref, wtx.inputs[0])
|
||||
assertEquals(WALLET[0].state.copy(owner = THEIR_PUBKEY_1), wtx.outputs[0])
|
||||
assertEquals(OUR_PUBKEY_1, wtx.commands[0].pubkeys[0])
|
||||
assertEquals(OUR_PUBKEY_1, wtx.commands[0].signers[0])
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -334,7 +334,7 @@ class CashTests {
|
||||
assertEquals(WALLET[0].ref, wtx.inputs[0])
|
||||
assertEquals(WALLET[0].state.copy(owner = THEIR_PUBKEY_1, amount = 10.DOLLARS), wtx.outputs[0])
|
||||
assertEquals(WALLET[0].state.copy(amount = 90.DOLLARS), wtx.outputs[1])
|
||||
assertEquals(OUR_PUBKEY_1, wtx.commands[0].pubkeys[0])
|
||||
assertEquals(OUR_PUBKEY_1, wtx.commands[0].signers[0])
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -343,7 +343,7 @@ class CashTests {
|
||||
assertEquals(WALLET[0].ref, wtx.inputs[0])
|
||||
assertEquals(WALLET[1].ref, wtx.inputs[1])
|
||||
assertEquals(WALLET[0].state.copy(owner = THEIR_PUBKEY_1, amount = 500.DOLLARS), wtx.outputs[0])
|
||||
assertEquals(OUR_PUBKEY_1, wtx.commands[0].pubkeys[0])
|
||||
assertEquals(OUR_PUBKEY_1, wtx.commands[0].signers[0])
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -354,7 +354,7 @@ class CashTests {
|
||||
assertEquals(WALLET[2].ref, wtx.inputs[2])
|
||||
assertEquals(WALLET[0].state.copy(owner = THEIR_PUBKEY_1, amount = 500.DOLLARS), wtx.outputs[0])
|
||||
assertEquals(WALLET[2].state.copy(owner = THEIR_PUBKEY_1), wtx.outputs[1])
|
||||
assertEquals(OUR_PUBKEY_1, wtx.commands[0].pubkeys[0])
|
||||
assertEquals(OUR_PUBKEY_1, wtx.commands[0].signers[0])
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -33,7 +33,7 @@ class DummyTimestamper(var clock: Clock = Clock.fixed(TEST_TX_TIME, ZoneId.syste
|
||||
|
||||
override fun timestamp(wtxBytes: SerializedBytes<WireTransaction>): DigitalSignature.LegallyIdentifiable {
|
||||
val wtx = wtxBytes.deserialize()
|
||||
val timestamp = wtx.commands.mapNotNull { it.data as? TimestampCommand }.single()
|
||||
val timestamp = wtx.commands.mapNotNull { it.value as? TimestampCommand }.single()
|
||||
if (timestamp.before!! until clock.instant() > tolerance)
|
||||
throw TimestampingError.NotOnTimeException()
|
||||
return DummyTimestampingAuthority.key.signWithECDSA(wtxBytes.bits, identity)
|
||||
|
@ -101,7 +101,7 @@ class NodeInterestRatesTest {
|
||||
future.get()
|
||||
|
||||
// We should now have a valid signature over our tx from the oracle.
|
||||
val fix = tx.toSignedTransaction(true).tx.commands.map { it.data as Fix }.first()
|
||||
val fix = tx.toSignedTransaction(true).tx.commands.map { it.value as Fix }.first()
|
||||
assertEquals(fixOf, fix.of)
|
||||
assertEquals("0.678".bd, fix.value)
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ class TransactionSerializationTests {
|
||||
tx.signWith(TestUtils.keypair)
|
||||
val stx = tx.toSignedTransaction()
|
||||
val ltx = stx.verifyToLedgerTransaction(MockIdentityService, MockStorageService().attachments)
|
||||
assertEquals(tx.commands().map { it.data }, ltx.commands.map { it.value })
|
||||
assertEquals(tx.commands().map { it.value }, ltx.commands.map { it.value })
|
||||
assertEquals(tx.inputStates(), ltx.inputs)
|
||||
assertEquals(tx.outputStates(), ltx.outputs)
|
||||
assertEquals(TEST_TX_TIME, ltx.commands.getTimestampBy(DUMMY_TIMESTAMPER.identity)!!.midpoint)
|
||||
|
@ -118,7 +118,7 @@ abstract class AbstractTransactionForTest {
|
||||
open fun output(label: String? = null, s: () -> ContractState) = LabeledOutput(label, s()).apply { outStates.add(this) }
|
||||
|
||||
protected fun commandsToAuthenticatedObjects(): List<AuthenticatedObject<CommandData>> {
|
||||
return commands.map { AuthenticatedObject(it.pubkeys, it.pubkeys.mapNotNull { MockIdentityService.partyFromKey(it) }, it.data) }
|
||||
return commands.map { AuthenticatedObject(it.signers, it.signers.mapNotNull { MockIdentityService.partyFromKey(it) }, it.value) }
|
||||
}
|
||||
|
||||
fun attachment(attachmentID: SecureHash) {
|
||||
@ -341,7 +341,7 @@ class TransactionGroupDSL<T : ContractState>(private val stateType: Class<T>) {
|
||||
|
||||
fun signAll(txnsToSign: List<WireTransaction> = txns, vararg extraKeys: KeyPair): List<SignedTransaction> {
|
||||
return txnsToSign.map { wtx ->
|
||||
val allPubKeys = wtx.commands.flatMap { it.pubkeys }.toMutableSet()
|
||||
val allPubKeys = wtx.commands.flatMap { it.signers }.toMutableSet()
|
||||
val bits = wtx.serialize()
|
||||
require(bits == wtx.serialized)
|
||||
val sigs = ArrayList<DigitalSignature.WithKey>()
|
||||
|
Reference in New Issue
Block a user