Helper SignedTransaction.buildFilteredTransaction(filtering) (#1394)

This commit is contained in:
Konstantinos Chalkias 2017-09-01 19:26:00 +01:00 committed by GitHub
parent fef8a997f2
commit 39e44382be
3 changed files with 14 additions and 3 deletions

View File

@ -72,7 +72,7 @@ object NotaryFlow {
val tx: Any = if (stx.isNotaryChangeTransaction()) { val tx: Any = if (stx.isNotaryChangeTransaction()) {
stx.notaryChangeTx stx.notaryChangeTx
} else { } else {
stx.tx.buildFilteredTransaction(Predicate { it is StateRef || it is TimeWindow }) stx.buildFilteredTransaction(Predicate { it is StateRef || it is TimeWindow })
} }
sendAndReceiveWithRetry(notaryParty, tx) sendAndReceiveWithRetry(notaryParty, tx)
} }

View File

@ -14,6 +14,7 @@ import java.security.KeyPair
import java.security.PublicKey import java.security.PublicKey
import java.security.SignatureException import java.security.SignatureException
import java.util.* import java.util.*
import java.util.function.Predicate
/** /**
* SignedTransaction wraps a serialized WireTransaction. It contains one or more signatures, each one for * SignedTransaction wraps a serialized WireTransaction. It contains one or more signatures, each one for
@ -50,12 +51,18 @@ data class SignedTransaction(val txBits: SerializedBytes<CoreTransaction>,
/** The id of the contained [WireTransaction]. */ /** The id of the contained [WireTransaction]. */
override val id: SecureHash get() = transaction.id override val id: SecureHash get() = transaction.id
/** Returns the contained [WireTransaction], or throws if this is a notary change transaction */ /** Returns the contained [WireTransaction], or throws if this is a notary change transaction. */
val tx: WireTransaction get() = transaction as WireTransaction val tx: WireTransaction get() = transaction as WireTransaction
/** Returns the contained [NotaryChangeWireTransaction], or throws if this is a normal transaction */ /** Returns the contained [NotaryChangeWireTransaction], or throws if this is a normal transaction. */
val notaryChangeTx: NotaryChangeWireTransaction get() = transaction as NotaryChangeWireTransaction val notaryChangeTx: NotaryChangeWireTransaction get() = transaction as NotaryChangeWireTransaction
/**
* Helper function to directly build a [FilteredTransaction] using provided filtering functions,
* without first accessing the [WireTransaction] [tx].
*/
fun buildFilteredTransaction(filtering: Predicate<Any>) = tx.buildFilteredTransaction(filtering)
/** Helper to access the inputs of the contained transaction */ /** Helper to access the inputs of the contained transaction */
val inputs: List<StateRef> get() = transaction.inputs val inputs: List<StateRef> get() = transaction.inputs
/** Helper to access the notary of the contained transaction */ /** Helper to access the notary of the contained transaction */

View File

@ -114,6 +114,10 @@ UNRELEASED
``createSignature(filteredTransaction: FilteredTransaction, publicKey: PublicKey)`` and ``createSignature(filteredTransaction: FilteredTransaction, publicKey: PublicKey)`` and
``createSignature(filteredTransaction: FilteredTransaction)`` to sign with the legal identity key. ``createSignature(filteredTransaction: FilteredTransaction)`` to sign with the legal identity key.
* A new helper method ``buildFilteredTransaction(filtering: Predicate<Any>)`` is added to ``SignedTransaction`` to
directly build a ``FilteredTransaction`` using provided filtering functions, without first accessing the
``tx: WireTransaction``.
Milestone 14 Milestone 14
------------ ------------