(a) When an interest in real property is conveyed by deed to a person in a trust that is unenforceable under AS 09.25.010 - 09.25.020 and the intended trustee or the trustee's successor in interest holds title but refuses to carry out the trust because of AS 09.25.010 - 09.25.020, the intended trustee or the trustee's successor in interest, except to the extent that the successor in interest is a bona fide purchaser of a legal interest in the real property, shall convey the interest in real property to the settlor or the settlor's successor in interest. A court having jurisdiction may prescribe the conditions for conveying the interest to the settlor or the settlor's successor in interest.
(b) If the intended trustee of an unenforceable trust under (a) of this section transfers part or all of the trustee's interest and the interest is transferred to a bona fide purchaser, the intended trustee is liable to the settlor or the settlor's successor in interest for the value, at the time of the transfer, of the interest transferred, less any offsets that a court determines to be equitable.