Skip to content

Commit

Permalink
check proof for not active account
Browse files Browse the repository at this point in the history
  • Loading branch information
akos-tk committed Sep 16, 2024
1 parent d4afeb1 commit 10bca54
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions ton/getstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ton
import (
"bytes"
"context"
"errors"
"fmt"
"github.com/xssnick/tonutils-go/address"
"github.com/xssnick/tonutils-go/tl"
Expand Down Expand Up @@ -58,12 +59,6 @@ func (c *APIClient) GetAccount(ctx context.Context, block *BlockIDExt, addr *add
return nil, fmt.Errorf("response with incorrect master block")
}

if t.State == nil {
return &tlb.Account{
IsActive: false,
}, nil
}

if t.Proof == nil {
return nil, fmt.Errorf("no proof")
}
Expand All @@ -87,9 +82,17 @@ func (c *APIClient) GetAccount(ctx context.Context, block *BlockIDExt, addr *add
}

shardAcc, balanceInfo, err := CheckAccountStateProof(addr, block, t.Proof, t.ShardProof, shardHash, c.proofCheckPolicy == ProofCheckPolicyUnsafe)
if errors.Is(err, ErrNoAddrInProof) && t.State == nil {
return &tlb.Account{
IsActive: false,
}, nil
}
if err != nil {
return nil, fmt.Errorf("failed to check acc state proof: %w", err)
}
if t.State == nil {
return nil, fmt.Errorf("state must be presented")
}

if !bytes.Equal(shardAcc.Account.Hash(0), t.State.Hash()) {
return nil, fmt.Errorf("proof hash not match state account hash")
Expand Down

0 comments on commit 10bca54

Please sign in to comment.