Updated on 2026-08-14
This commit is contained in:
parent
a19e2e4876
commit
2b18392059
4 changed files with 8 additions and 7 deletions
|
|
@ -10,7 +10,8 @@ data class CardEnvironment(
|
|||
val pin2: String = DEFAULT_PIN2,
|
||||
val cardId: String? = null,
|
||||
val terminalKeys: KeyPair? = null,
|
||||
val encryptionKey: ByteArray? = null
|
||||
val encryptionKey: ByteArray? = null,
|
||||
val cvc: ByteArray? = null
|
||||
) {
|
||||
|
||||
companion object {
|
||||
|
|
|
|||
|
|
@ -137,6 +137,9 @@ class CardManager(
|
|||
fun createWallet(cardId: String,
|
||||
cvc: ByteArray? = null,
|
||||
callback: (result: TaskEvent<CreateWalletResponse>) -> Unit) {
|
||||
|
||||
if (cvc != null) cardEnvironmentRepository[cardId] = fetchCardEnvironment(cardId).copy(cvc = cvc)
|
||||
|
||||
val createWalletCommand = CreateWalletCommand(cardId)
|
||||
val task = SingleCommandTask(createWalletCommand)
|
||||
runTask(task, cardId, callback)
|
||||
|
|
|
|||
|
|
@ -36,11 +36,9 @@ class CreateWalletResponse(
|
|||
* RemainingSignature is set to MaxSignatures.
|
||||
*
|
||||
* @property cardId CID, Unique Tangem card ID number.
|
||||
* @property cvc Optional 3-digit code printed on the card. Required if Use_CVC flag is set in Settings_Mask.
|
||||
*/
|
||||
class CreateWalletCommand(
|
||||
private val cardId: String,
|
||||
private val cvc: ByteArray? = null
|
||||
private val cardId: String
|
||||
) : CommandSerializer<CreateWalletResponse>() {
|
||||
|
||||
override fun serialize(cardEnvironment: CardEnvironment): CommandApdu {
|
||||
|
|
@ -49,8 +47,8 @@ class CreateWalletCommand(
|
|||
Tlv(TlvTag.CardId, cardId.hexToBytes()),
|
||||
Tlv(TlvTag.Pin2, cardEnvironment.pin2.calculateSha256())
|
||||
)
|
||||
if (cvc != null) {
|
||||
tlvData.add(Tlv(TlvTag.Cvc, cvc))
|
||||
if (cardEnvironment.cvc != null) {
|
||||
tlvData.add(Tlv(TlvTag.Cvc, cardEnvironment.cvc))
|
||||
}
|
||||
|
||||
return CommandApdu(Instruction.CreateWallet, tlvData)
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ class PurgeWalletResponse(
|
|||
* If Is_Reusable flag is disabled, the card switches to ‘Purged’ state.
|
||||
* ‘Purged’ state is final, it makes the card useless.
|
||||
* @property cardId CID, Unique Tangem card ID number.
|
||||
* @property cvc Optional 3-digit code printed on the card. Required if Use_CVC flag is set in Settings_Mask.
|
||||
*/
|
||||
class PurgeWalletCommand(
|
||||
private val cardId: String
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue