txn:add txn and refactor on xtypes.h