Skip to content

Instantly share code, notes, and snippets.

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)
// 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);
case Close =>
 for {
  txn ← Transaction(accn)
    .add(AccountMergeOperation(signerKey))
    .sign(accountKey)
  resp ← txn.submit()
 }
case Close => router.route(Broadcast(Close), self)
def transmit(operations: Seq[PaymentOperation]) = {
 operations.foldLeft(Transaction(accn))(_ add _).sign(accnKey, signerKey)
 txn.submit()
}
case Flush if batch.nonEmpty =>
transmit(batch)
context.become(ready(accnKey, accn.withIncSeq, replyTo))
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 =>
case Pay(recipient, amount) =>
val payment = PaymentOperation(recipient, amount, sourceAccount = Some(signerKey))
case paymentRequest: Pay => router.route(paymentRequest, self)
  ...
  routees = accounts.map { accn =>
   val channelAccount = context.actorOf(Props(classOf[ChannelAccount], signer, accn))
   ActorRefRoutee(channelAccount)
}
} yield Router(RoundRobinRoutingLogic(), routees)