diff options
Diffstat (limited to 'data/transactions/logictest/ledger.go')
-rw-r--r-- | data/transactions/logictest/ledger.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/data/transactions/logictest/ledger.go b/data/transactions/logictest/ledger.go index 5d75b210f..51ed94124 100644 --- a/data/transactions/logictest/ledger.go +++ b/data/transactions/logictest/ledger.go @@ -549,6 +549,23 @@ func (l *Ledger) move(from basics.Address, to basics.Address, amount uint64) err return nil } +func (l *Ledger) rekey(tx *transactions.Transaction) error { + // rekeying: update br.auth to tx.RekeyTo if provided + if (tx.RekeyTo != basics.Address{}) { + br, ok := l.balances[tx.Sender] + if !ok { + return fmt.Errorf("no account") + } + if tx.RekeyTo == tx.Sender { + br.auth = basics.Address{} + } else { + br.auth = tx.RekeyTo + } + l.balances[tx.Sender] = br + } + return nil +} + func (l *Ledger) pay(from basics.Address, pay transactions.PaymentTxnFields) error { err := l.move(from, pay.Receiver, pay.Amount.Raw) if err != nil { @@ -706,6 +723,12 @@ func (l *Ledger) Perform(txn *transactions.Transaction, spec transactions.Specia if err != nil { return ad, err } + + err = l.rekey(txn) + if err != nil { + return ad, err + } + switch txn.Type { case protocol.PaymentTx: err = l.pay(txn.Sender, txn.PaymentTxnFields) |