mirror of
https://github.com/corda/corda.git
synced 2025-02-21 09:51:57 +00:00
Fixed bug in generateSpending whereby Issuer Ref was not being checked.
This commit is contained in:
parent
2744d8abaa
commit
253a70f55e
@ -569,7 +569,7 @@ class CashTests {
|
|||||||
databaseTransaction(database) {
|
databaseTransaction(database) {
|
||||||
|
|
||||||
val tx = TransactionType.General.Builder(DUMMY_NOTARY)
|
val tx = TransactionType.General.Builder(DUMMY_NOTARY)
|
||||||
vault.generateSpend(tx, 80.DOLLARS, ALICE_PUBKEY, setOf(MINI_CORP))
|
vault.generateSpend(tx, 80.DOLLARS, ALICE_PUBKEY, setOf(MINI_CORP.ref(1)))
|
||||||
|
|
||||||
assertEquals(vaultService.states.elementAt(2).ref, tx.inputStates()[0])
|
assertEquals(vaultService.states.elementAt(2).ref, tx.inputStates()[0])
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,7 @@ interface VaultService {
|
|||||||
fun generateSpend(tx: TransactionBuilder,
|
fun generateSpend(tx: TransactionBuilder,
|
||||||
amount: Amount<Currency>,
|
amount: Amount<Currency>,
|
||||||
to: PublicKey,
|
to: PublicKey,
|
||||||
onlyFromParties: Set<Party>? = null): Pair<TransactionBuilder, List<PublicKey>>
|
onlyFromIssuers: Set<PartyAndReference>? = null): Pair<TransactionBuilder, List<PublicKey>>
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fun <reified T : LinearState> VaultService.linearHeadsOfType() = linearHeadsOfType_(T::class.java)
|
inline fun <reified T : LinearState> VaultService.linearHeadsOfType() = linearHeadsOfType_(T::class.java)
|
||||||
|
@ -79,8 +79,8 @@ class ServerRPCOps(
|
|||||||
val builder: TransactionBuilder = TransactionType.General.Builder(null)
|
val builder: TransactionBuilder = TransactionType.General.Builder(null)
|
||||||
// TODO: Have some way of restricting this to states the caller controls
|
// TODO: Have some way of restricting this to states the caller controls
|
||||||
try {
|
try {
|
||||||
val (spendTX, keysForSigning) = services.vaultService.generateSpend(builder, req.amount.withoutIssuer(), req.recipient.owningKey)
|
val (spendTX, keysForSigning) = services.vaultService.generateSpend(builder, req.amount.withoutIssuer(), req.recipient.owningKey,
|
||||||
|
setOf(req.amount.token.issuer))
|
||||||
keysForSigning.forEach {
|
keysForSigning.forEach {
|
||||||
val key = services.keyManagementService.keys[it] ?: throw IllegalStateException("Could not find signing key for ${it.toStringShort()}")
|
val key = services.keyManagementService.keys[it] ?: throw IllegalStateException("Could not find signing key for ${it.toStringShort()}")
|
||||||
builder.signWith(KeyPair(it, key))
|
builder.signWith(KeyPair(it, key))
|
||||||
|
@ -120,7 +120,7 @@ class NodeVaultService(private val services: ServiceHub) : SingletonSerializeAsT
|
|||||||
override fun generateSpend(tx: TransactionBuilder,
|
override fun generateSpend(tx: TransactionBuilder,
|
||||||
amount: Amount<Currency>,
|
amount: Amount<Currency>,
|
||||||
to: PublicKey,
|
to: PublicKey,
|
||||||
onlyFromParties: Set<Party>?): Pair<TransactionBuilder, List<PublicKey>> {
|
onlyFromIssuers: Set<PartyAndReference>?): Pair<TransactionBuilder, List<PublicKey>> {
|
||||||
// Discussion
|
// Discussion
|
||||||
//
|
//
|
||||||
// This code is analogous to the Wallet.send() set of methods in bitcoinj, and has the same general outline.
|
// This code is analogous to the Wallet.send() set of methods in bitcoinj, and has the same general outline.
|
||||||
@ -146,8 +146,8 @@ class NodeVaultService(private val services: ServiceHub) : SingletonSerializeAsT
|
|||||||
val currency = amount.token
|
val currency = amount.token
|
||||||
var acceptableCoins = run {
|
var acceptableCoins = run {
|
||||||
val ofCurrency = assetsStates.filter { it.state.data.amount.token.product == currency }
|
val ofCurrency = assetsStates.filter { it.state.data.amount.token.product == currency }
|
||||||
if (onlyFromParties != null)
|
if (onlyFromIssuers != null)
|
||||||
ofCurrency.filter { it.state.data.amount.token.issuer.party in onlyFromParties }
|
ofCurrency.filter { it.state.data.amount.token.issuer.party in onlyFromIssuers }
|
||||||
else
|
else
|
||||||
ofCurrency
|
ofCurrency
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user