This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Account A | |
balance: 9 | |
sequence #: 3 | |
low threshold: 1 | |
med threshold: 1 | |
high threshold: 1 | |
TX A: | |
Sequence #5 | |
Pay B 5 XLM | |
(NO SIGNATURE NEEDED) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// encryption | |
const padding = calculatePadding(data); | |
const encryptedMemo = encrypt(data + padding + padding.length, secretKey) | |
.toString('hex'); | |
const memo = StellarSdk.Memo.hash(encryptedMemo); | |
// decryption | |
const decryptedMemo = decrypt(memo.value, secretKey); | |
const paddingSize = decryptedMemo.last(); | |
const originalData = decryptedMemo.remove(paddingSize + 1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case Close => | |
for { | |
txn ← Transaction(accn) | |
.add(AccountMergeOperation(signerKey)) | |
.sign(accountKey) | |
resp ← txn.submit() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case Close => router.route(Broadcast(Close), self) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def transmit(operations: Seq[PaymentOperation]) = { | |
operations.foldLeft(Transaction(accn))(_ add _).sign(accnKey, signerKey) | |
txn.submit() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case Flush if batch.nonEmpty => | |
transmit(batch) | |
context.become(ready(accnKey, accn.withIncSeq, replyTo)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
batch match { | |
// this is the first of the batch | |
case Nil => | |
// add this payment to the batch | |
context.become(ready(accnKey, accn, replyTo, Seq(payment))) | |
// remind myself in 1 second from now to flush the batch | |
context.system.scheduler.scheduleOnce(1.second, self, Flush) | |
// this is the last that can fit inside the batch | |
case _ if batch.size == MaxTxnLength - 1 => |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case Pay(recipient, amount) => | |
val payment = PaymentOperation(recipient, amount, sourceAccount = Some(signerKey)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case paymentRequest: Pay => router.route(paymentRequest, self) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
routees = accounts.map { accn => | |
val channelAccount = context.actorOf(Props(classOf[ChannelAccount], signer, accn)) | |
ActorRefRoutee(channelAccount) | |
} | |
} yield Router(RoundRobinRoutingLogic(), routees) |
NewerOlder